<p dir="ltr">Ask your ASTContext for it. Don't create types yourself; doing so will break Clang's canonical type system.</p>
<div class="gmail_quote">On 5 Aug 2014 11:26, "peterlee" <<a href="mailto:peterlee@cs.utah.edu">peterlee@cs.utah.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Reid<br>
<br>
Thanks a lot for your instant reply.<br>
<br>
Yes, I am building everything in 32-bit mode, so would you please<br>
point me out how to create the boolean type in a memory-aligned way?<br>
<br>
Thanks<br>
Peng<br>
<br>
在 2014-08-05 10:48,Reid Kleckner 写道:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It is asserting that the Type pointer is not 16 byte aligned. Types<br>
are generally constructed and uniqued in an ASTContext, which<br>
guarantees this alignment.  See this at the top of Type.h:<br>
<br>
  enum {<br>
<br>
    TypeAlignmentInBits = 4,<br>
    TypeAlignment = 1 << TypeAlignmentInBits<br>
  };<br>
<br>
Presumably you are building 32-bit code, where the system malloc<br>
returns 8 byte aligned chunks.<br>
<br>
On Tue, Aug 5, 2014 at 10:11 AM, peterlee <<a href="mailto:peterlee@cs.utah.edu" target="_blank">peterlee@cs.utah.edu</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear All,<br>
<br>
I am using Clang/LLVM-3.3, at present, I am fixing an error about<br>
creating a builtin type, the code is supposed to<br>
generate a "boolean" type with the following code:<br>
<br>
clang::Type* bool_type = new<br>
clang::BuiltinType(clang::<u></u>BuiltinType::Bool);<br>
params.push_back(klimt::<u></u>NamedDecl(clang::QualType(<u></u>bool_type, 0),<br>
pname));<br>
<br>
I always encountered the error:<br>
<br>
<br>
</blockquote>
/home/xxx/vendor/llvm-3.3/<u></u>build32/Release+Asserts/../../<u></u>include/llvm/ADT/<u></u>PointerIntPair.h:100:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
void llvm::PointerIntPair<<u></u>PointerTy, IntBits, IntType,<br>
PtrTraits>::initWithPointer(<u></u>PointerTy) [with PointerTy = void*;<br>
unsigned int IntBits = 1u; IntType = bool; PtrTraits =<br>
llvm::PointerUnionUIntTraits<<u></u>const clang::Type*, const<br>
clang::ExtQuals*>]: Assertion `(PtrWord & ((1 <<<br>
PtrTraits::<u></u>NumLowBitsAvailable)-1)) == 0 && "Pointer is not<br>
sufficiently aligned"' failed<br>
<br>
The assertion fails at the BuiltinType creation.<br>
<br>
Any thoughts about how to fix this error is highly appreciated!<br>
<br>
Thanks<br>
Peng<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a> [1]<br>
</blockquote>
<br>
<br>
<br>
Links:<br>
------<br>
[1] <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div>