[llvm-branch-commits] [cfe-branch] r293782 - Merging r293678:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 1 08:59:51 PST 2017


Author: hans
Date: Wed Feb  1 10:59:51 2017
New Revision: 293782

URL: http://llvm.org/viewvc/llvm-project?rev=293782&view=rev
Log:
Merging r293678:
------------------------------------------------------------------------
r293678 | ahatanak | 2017-01-31 11:53:32 -0800 (Tue, 31 Jan 2017) | 9 lines

[Sema] Transform a templated name before looking it up in
FindInstantiatedDecl or passing it to RebuildMemberExpr.

This fixes PR30361.

rdar://problem/17341274

Differential Revision: https://reviews.llvm.org/D24969

------------------------------------------------------------------------

Modified:
    cfe/branches/release_40/   (props changed)
    cfe/branches/release_40/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/branches/release_40/lib/Sema/TreeTransform.h
    cfe/branches/release_40/test/SemaCXX/destructor.cpp

Propchange: cfe/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb  1 10:59:51 2017
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293134,293596
+/cfe/trunk:291850,291853,291865,291871,291877,291879,291881,291907,291955,291964,292032,292052,292183,292194,292247,292265,292497,292555,292558-292559,292561,292590,292800,292847,292874,292991,293134,293596,293678
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_40/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=293782&r1=293781&r2=293782&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/branches/release_40/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Feb  1 10:59:51 2017
@@ -4996,8 +4996,12 @@ NamedDecl *Sema::FindInstantiatedDecl(So
     NamedDecl *Result = nullptr;
     // FIXME: If the name is a dependent name, this lookup won't necessarily
     // find it. Does that ever matter?
-    if (D->getDeclName()) {
-      DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+    if (auto Name = D->getDeclName()) {
+      DeclarationNameInfo NameInfo(Name, D->getLocation());
+      Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+      if (!Name)
+        return nullptr;
+      DeclContext::lookup_result Found = ParentDC->lookup(Name);
       Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
     } else {
       // Since we don't have a name for the entity we're looking for,

Modified: cfe/branches/release_40/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/lib/Sema/TreeTransform.h?rev=293782&r1=293781&r2=293782&view=diff
==============================================================================
--- cfe/branches/release_40/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/release_40/lib/Sema/TreeTransform.h Wed Feb  1 10:59:51 2017
@@ -8818,12 +8818,18 @@ TreeTransform<Derived>::TransformMemberE
   // base (and therefore couldn't do the check) and a
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
+  if (MemberNameInfo.getName()) {
+    MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+    if (!MemberNameInfo.getName())
+      return ExprError();
+  }
 
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
                                         E->isArrow(),
                                         QualifierLoc,
                                         TemplateKWLoc,
-                                        E->getMemberNameInfo(),
+                                        MemberNameInfo,
                                         Member,
                                         FoundDecl,
                                         (E->hasExplicitTemplateArgs()

Modified: cfe/branches/release_40/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_40/test/SemaCXX/destructor.cpp?rev=293782&r1=293781&r2=293782&view=diff
==============================================================================
--- cfe/branches/release_40/test/SemaCXX/destructor.cpp (original)
+++ cfe/branches/release_40/test/SemaCXX/destructor.cpp Wed Feb  1 10:59:51 2017
@@ -431,3 +431,23 @@ class Invalid {
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template <typename T>
+struct C1 {
+  ~C1() {}
+  operator C1<T>* () { return nullptr; }
+  void foo1();
+};
+
+template<typename T>
+void C1<T>::foo1() {
+  C1::operator C1<T>*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1<int> x;
+  x.foo1();
+}
+}




More information about the llvm-branch-commits mailing list