[cfe-dev] A problem about builtin-type creation
Reid Kleckner
rnk at google.com
Tue Aug 5 11:19:48 PDT 2014
Typically a Clang tool would read ASTContext::BoolTy. I'm not sure what
you're trying to do, but I would look at other clang tools that use
lib/Tooling.
On Tue, Aug 5, 2014 at 11:05 AM, peterlee <peterlee at cs.utah.edu> wrote:
> Hi Reid
>
> Thanks a lot for your instant reply.
>
> Yes, I am building everything in 32-bit mode, so would you please
> point me out how to create the boolean type in a memory-aligned way?
>
> Thanks
> Peng
>
> 在 2014-08-05 10:48,Reid Kleckner 写道:
>
>> It is asserting that the Type pointer is not 16 byte aligned. Types
>> are generally constructed and uniqued in an ASTContext, which
>> guarantees this alignment. See this at the top of Type.h:
>>
>> enum {
>>
>> TypeAlignmentInBits = 4,
>> TypeAlignment = 1 << TypeAlignmentInBits
>> };
>>
>> Presumably you are building 32-bit code, where the system malloc
>> returns 8 byte aligned chunks.
>>
>> On Tue, Aug 5, 2014 at 10:11 AM, peterlee <peterlee at cs.utah.edu>
>> wrote:
>>
>> Dear All,
>>>
>>> I am using Clang/LLVM-3.3, at present, I am fixing an error about
>>> creating a builtin type, the code is supposed to
>>> generate a "boolean" type with the following code:
>>>
>>> clang::Type* bool_type = new
>>> clang::BuiltinType(clang::BuiltinType::Bool);
>>> params.push_back(klimt::NamedDecl(clang::QualType(bool_type, 0),
>>> pname));
>>>
>>> I always encountered the error:
>>>
>>>
>>> /home/xxx/vendor/llvm-3.3/build32/Release+Asserts/../../
>> include/llvm/ADT/PointerIntPair.h:100:
>>
>>> void llvm::PointerIntPair<PointerTy, IntBits, IntType,
>>> PtrTraits>::initWithPointer(PointerTy) [with PointerTy = void*;
>>> unsigned int IntBits = 1u; IntType = bool; PtrTraits =
>>> llvm::PointerUnionUIntTraits<const clang::Type*, const
>>> clang::ExtQuals*>]: Assertion `(PtrWord & ((1 <<
>>> PtrTraits::NumLowBitsAvailable)-1)) == 0 && "Pointer is not
>>> sufficiently aligned"' failed
>>>
>>> The assertion fails at the BuiltinType creation.
>>>
>>> Any thoughts about how to fix this error is highly appreciated!
>>>
>>> Thanks
>>> Peng
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev [1]
>>>
>>
>>
>>
>> Links:
>> ------
>> [1] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140805/bc0652ef/attachment.html>
More information about the cfe-dev
mailing list