[cfe-dev] Array with size of an Enum Constant

Douglas Gregor dgregor at apple.com
Mon Aug 23 11:15:43 PDT 2010


On Aug 23, 2010, at 11:13 AM, Murat B wrote:

> Thanks. I still have a problem.
> 
> I modified the field processing in this way:
> void AAPConsumer::HandleRecordFields(const RecordDecl *RD)
> {
>     Type *T;
>     for (RecordDecl::field_iterator I = RD->field_begin(),
>              E = RD->field_end(); I != E; I++) {
>         T = ((*I)->getType()).getTypePtr();
>         if (ArrayType::classof(T)) {
>             llvm::errs() << "Field: "; (*I)->dump(); T->dump();
>             llvm::errs() << "       ";  (*I)->dump();
>             (*I)->getTypeSourceInfo()->getTypeLoc().getTypePtr()->dump();
>         }
>     }
> }
> 
> For the field bitcounter, I get following output:
> Field: int bitcounter[8]: int identifier[8]
>        int bitcounter[8]: int identifier[8]
> 
> In both cases the array size is shown as 8 and the type is ConstantArrayType. I still don't get size MAX_BITCOUNTER_MB. Am I doing something wrong?

You need to actually walk the structure returned by getTypeLoc(), not jump down immediately to the underlying type. ConstantArrayTypeLoc has the information you're looking for.

	- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100823/863f95a9/attachment.html>


More information about the cfe-dev mailing list