[PATCH] -fdelayed-template-parsing: handle cases where a late-parsed function is not a direct member of a template, but rather nested inside a class that's a member of a template (PR19613)

Hans Wennborg hans at chromium.org
Wed Apr 30 09:37:35 PDT 2014


On Tue, Apr 29, 2014 at 8:05 PM, Nico Weber <thakis at chromium.org> wrote:
> On Tue, Apr 29, 2014 at 6:05 PM, Hans Wennborg <hans at chromium.org> wrote:
>> Hi rnk, majnemer,
>>
>> This patch seems to fix the problem. Please take a look.
>>
>> http://reviews.llvm.org/D3555
>>
>> Files:
>>   lib/Parse/ParseTemplate.cpp
>>   test/Parser/DelayedTemplateParsing.cpp
>>
>> Index: lib/Parse/ParseTemplate.cpp
>> ===================================================================
>> --- lib/Parse/ParseTemplate.cpp
>> +++ lib/Parse/ParseTemplate.cpp
>> @@ -1255,15 +1255,23 @@
>>            new ParseScope(this, Scope::TemplateParamScope));
>>        Actions.ActOnReenterTemplateScope(getCurScope(), MD);
>>        ++CurTemplateDepthTracker;
>> -    } else if (CXXRecordDecl *MD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
>> -      bool IsClassTemplate = MD->getDescribedClassTemplate() != 0;
>> +    } else if (CXXRecordDecl *RD = dyn_cast_or_null<CXXRecordDecl>(*II)) {
>> +      ClassTemplateDecl *CTD = RD->getDescribedClassTemplate();
>> +
>> +      if (!CTD) {
>> +        if (CXXRecordDecl *Parent = dyn_cast<CXXRecordDecl>(RD->getParent()))
>
> Is a single if enough here? Could there be more than one nesting level?

It was enough for the cases I tested. We're already walking the
lexical parents, so if for example BitSetType from my test is nested
inside another struct, it still works.



More information about the cfe-commits mailing list