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

Murat B murat8307 at yahoo.com
Mon Aug 23 11:13:59 PDT 2010


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?

Thanks,
Murat

--- On Mon, 8/23/10, Douglas Gregor <dgregor at apple.com> wrote:

From: Douglas Gregor <dgregor at apple.com>
Subject: Re: [cfe-dev] Array with size of an Enum Constant
To: "Murat B" <murat8307 at yahoo.com>
Cc: cfe-dev at cs.uiuc.edu
Date: Monday, August 23, 2010, 1:23 PM


On Aug 23, 2010, at 10:23 AM, Murat B wrote:
Thanks for the reply Doug!

I have following situation, I have a variable T of class Type which is the type of the array size expression.

My function progress following way.
ArrayType *AT = dyn_cast<ArrayType>(T);
if (VariableArrayType::classof(AT)
   ......................
else if (ConstantArrayType::classof(AT) {
    ConstantArrayType *CAT = cast<ConstantArrayType>(AT);
}

For the structure field the type will be ConstantArrayType. Can you tell me how I can get TypeSourceInfo from it.

As I said before, you need to get the TypeSourceInfo from the *field*, i.e., the FieldDecl.
	- Doug


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


More information about the cfe-dev mailing list