[cfe-commits] r141350 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CodeGenTypes.cpp test/CodeGenCXX/class-layout.cpp

John McCall rjmccall at apple.com
Wed Jun 13 12:29:47 PDT 2012


On Jun 12, 2012, at 2:47 PM, Nico Weber wrote:
> On Thu, Oct 6, 2011 at 7:39 PM, John McCall <rjmccall at apple.com> wrote:
>> Author: rjmccall
>> Date: Thu Oct  6 21:39:22 2011
>> New Revision: 141350
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=141350&view=rev
>> Log:
>> Record layout requires not just a definition, but a complete
>> definition.  Assert this.  Change IR generation to not try to
>> aggressively emit the IR translation of a record during its
>> own definition.  Fixes PR10912.
>> 
>> 
>> Modified:
>>    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
>>    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
>>    cfe/trunk/test/CodeGenCXX/class-layout.cpp
>> 
>> Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=141350&r1=141349&r2=141350&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
>> +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Thu Oct  6 21:39:22 2011
>> @@ -2007,8 +2007,13 @@
>>  /// position information.
>>  const ASTRecordLayout &
>>  ASTContext::getASTRecordLayout(const RecordDecl *D) const {
>> +  // These asserts test different things.  A record has a definition
>> +  // as soon as we begin to parse the definition.  That definition is
>> +  // not a complete definition (which is what isDefinition() tests)
>> +  // until we *finish* parsing the definition.
>>   D = D->getDefinition();
>>   assert(D && "Cannot get layout of forward declarations!");
>> +  assert(D->isDefinition() && "Cannot layout type before complete!");
> 
> ^ this fails for some invalid inputs, see PR13096

Then those inputs should not be calling getASTRecordLayout;  they should
bail out beforehand.

John.



More information about the cfe-commits mailing list