]> granicus.if.org Git - clang/commitdiff
Don't lose the FoundDecl and template arguments for a DeclRefExpr in
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 27 Aug 2019 01:06:21 +0000 (01:06 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 27 Aug 2019 01:06:21 +0000 (01:06 +0000)
TreeTransform.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369999 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/TreeTransform.h

index 8df18b5c27844bda6a38b770abd1f48939f5c4de..de1339880b1c098905df2ecdb93193bea38bca1b 100644 (file)
@@ -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>::TransformDeclRefExpr(DeclRefExpr *E) {
   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>::TransformDeclRefExpr(DeclRefExpr *E) {
   }
 
   return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
-                                         TemplateArgs);
+                                         Found, TemplateArgs);
 }
 
 template<typename Derived>