From: Faisal Vali Date: Thu, 25 Feb 2016 05:09:30 +0000 (+0000) Subject: Twek fix for PR24473 (r261506) - Preserve the template arguments as written X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f527ef16f0653272bb5102185d9388b308002fd;p=clang Twek fix for PR24473 (r261506) - Preserve the template arguments as written (within the DeclRefExpr Node) when creating AST nodes that reference specializations of static data member templates. While we pass the template args through for all non-instance members, they should only be relevant (i.e. non-null) for variable template ids (assertion added for that assumption) Also preserve the FoundDecl that refers to the canonical Decl (the primary VarTemplateDecl for a variable template specialization) that we are referencing in our DeclRefExpr. Not sure why this was not being done for non-variable template-ids. No functionality change - so no tests added. Thanks to Richard Smith for drawing my attention to this! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261823 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprMember.cpp b/lib/Sema/SemaExprMember.cpp index 17e6e16a88..dfe63a86d2 100644 --- a/lib/Sema/SemaExprMember.cpp +++ b/lib/Sema/SemaExprMember.cpp @@ -1100,6 +1100,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, // declaration corresponding to the supplied template arguments // (while emitting diagnostics as necessary) that will be referenced // by this expression. + assert((!TemplateArgs || isa(MemberDecl)) && + "How did we get template arguments here sans a variable template"); if (isa(MemberDecl)) { MemberDecl = getVarTemplateSpecialization( *this, cast(MemberDecl), TemplateArgs, @@ -1107,7 +1109,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType, if (!MemberDecl) return ExprError(); } - return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl); + return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(), MemberDecl, + FoundDecl, TemplateArgs); } SourceLocation Loc = R.getNameLoc(); if (SS.getRange().isValid())