r369999 - Don't lose the FoundDecl and template arguments for a DeclRefExpr in

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 26 15:26:59 PDT 2019


On Wed, 25 Sep 2019 at 11:48, Peter Collingbourne via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Hi Richard, it looks like this commit caused an assertion failure on the
> following input:
>
> $ cat test2.ii
> # 2 "" 3
> namespace a {
> enum { b };
> }
> template <typename> void c() {
>   auto d = [](auto) {
>     using a::b;
>     b;
>   };
>   d(0);
> }
> void e() { c<int>; }
> $ clang test2.ii
> clang: ../clang/lib/Sema/SemaTemplateInstantiate.cpp:2985:
> llvm::PointerUnion<Decl *, LocalInstantiationScope::DeclArgumentPack *>
> *clang::LocalInstantiationScope::findInstantiationOf(const clang::Decl *):
> Assertion `isa<LabelDecl>(D) && "declaration not instantiated in this
> scope"' failed.
>
> Can you please take a look?
>

Thanks, great testcase. Fixed in r373022.


> Peter
>
> On Mon, Aug 26, 2019 at 6:04 PM Richard Smith via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Aug 26 18:06:21 2019
>> New Revision: 369999
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=369999&view=rev
>> Log:
>> Don't lose the FoundDecl and template arguments for a DeclRefExpr in
>> TreeTransform.
>>
>> Modified:
>>     cfe/trunk/lib/Sema/TreeTransform.h
>>
>> Modified: cfe/trunk/lib/Sema/TreeTransform.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=369999&r1=369998&r2=369999&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/TreeTransform.h (original)
>> +++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 26 18:06:21 2019
>> @@ -2167,13 +2167,12 @@ public:
>>    ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
>>                                  ValueDecl *VD,
>>                                  const DeclarationNameInfo &NameInfo,
>> +                                NamedDecl *Found,
>>                                  TemplateArgumentListInfo *TemplateArgs) {
>>      CXXScopeSpec SS;
>>      SS.Adopt(QualifierLoc);
>> -
>> -    // FIXME: loses template args.
>> -
>> -    return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
>> +    return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
>> +                                              TemplateArgs);
>>    }
>>
>>    /// Build a new expression in parentheses.
>> @@ -9204,6 +9203,14 @@ TreeTransform<Derived>::TransformDeclRef
>>    if (!ND)
>>      return ExprError();
>>
>> +  NamedDecl *Found = ND;
>> +  if (E->getFoundDecl() != E->getDecl()) {
>> +    Found = cast_or_null<NamedDecl>(
>> +        getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
>> +    if (!Found)
>> +      return ExprError();
>> +  }
>> +
>>    DeclarationNameInfo NameInfo = E->getNameInfo();
>>    if (NameInfo.getName()) {
>>      NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
>> @@ -9236,7 +9243,7 @@ TreeTransform<Derived>::TransformDeclRef
>>    }
>>
>>    return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
>> -                                         TemplateArgs);
>> +                                         Found, TemplateArgs);
>>  }
>>
>>  template<typename Derived>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> --
> --
> Peter
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190926/5bef2f32/attachment.html>


More information about the cfe-commits mailing list