[cfe-commits] r165005 - in /cfe/trunk: lib/Serialization/ASTReaderDecl.cpp test/Modules/Inputs/templates-top.h

Axel Naumann Axel.Naumann at cern.ch
Thu Oct 4 00:49:04 PDT 2012


Hi Doug,

Thanks for your reviews!

On 10/03/2012 08:52 PM, Douglas Gregor wrote:
> 
> On Oct 2, 2012, at 6:06 AM, Axel Naumann <Axel.Naumann at cern.ch> wrote:
> 
>> Author: axel
>> Date: Tue Oct  2 08:06:13 2012
>> New Revision: 165005
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=165005&view=rev
>> Log:
>> Add redecls into their lexical DeclContext: this is what they assert on, and the merging should have set it correctly.
>> This is especially relevant for templatedDecls that might be injected (and thus have their DeclContext set to) somewhere completely different.
>>
>> Modified:
>>    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>    cfe/trunk/test/Modules/Inputs/templates-top.h
>>
>> Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=165005&r1=165004&r2=165005&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
>> +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Oct  2 08:06:13 2012
>> @@ -1775,7 +1775,7 @@
>>   if (!AddResult || Existing)
>>     return;
>>
>> -  DeclContext *DC = New->getDeclContext()->getRedeclContext();
>> +  DeclContext *DC = New->getLexicalDeclContext();
>>   if (DC->isTranslationUnit() && Reader.SemaObj) {
>>     if (Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName()))
>>       Reader.RedeclsAddedToAST.insert(New);
> 
> This isn't quite right. The lexical DeclContext is certainly the
> right place to call addDecl(), for the reason you state. However,
> it's not the right place to make a decision about whether we need to
> call tryAddTopLevelDecl or not. That call should be made when the
> DeclContext's redeclaration context is the translation unit.

I think that's fixed by r165215.

Cheers, Axel.




More information about the cfe-commits mailing list