[cfe-commits] r77556 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp lib/AST/RecordLayoutBuilder.h lib/CodeGen/CodeGenTypes.cpp test/CodeGenCXX/virt.cpp

Douglas Gregor dgregor at apple.com
Thu Jul 30 08:28:35 PDT 2009


On Jul 29, 2009, at 9:07 PM, Anders Carlsson wrote:

>
>>>
>>> // If this is a C++ class, lay out the nonvirtual bases.
>>> -  if (Ctx.getLangOptions().CPlusPlus)
>>> -    LayoutNonVirtualBases(cast<CXXRecordDecl>(D));
>>> +  if (Ctx.getLangOptions().CPlusPlus) {
>>> +    const CXXRecordDecl *RD = cast<CXXRecordDecl>(D);
>>> +    LayoutVtable(RD);
>>> +    LayoutNonVirtualBases(RD);
>>
>> Why check for c++? Do we get CXXRecordDecl AST in other languages I
>> wonder?
>>
>
> You don't. You can however get RecordDecls back even in CPlusPlus due
> to Objective-C.

Oops. There's a lot of Sema code that assumes that if we're in C++,  
all RecordDecls are really CXXRecordDecls.

> I suggest that we always use dyn_cast<CXXRecordDecl>
> (D) instead of checking CPlusPlus.


At some point, I'm planning to kill off CXXRecordDecl entirely, so  
that we have one kind of RecordDecl that has all of the C and C++  
behavior in it. Of course, it will differentiate between C and C++  
records internally, to save space, but that difference won't be  
visible outside. This is one of those TODO items that keeps getting  
pushed down.

	- Doug



More information about the cfe-commits mailing list