[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 14:44:12 PDT 2016


rsmith added inline comments.


================
Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:4849
+      DeclarationName Name = D->getDeclName();
+      if (auto *DD = dyn_cast<CXXDestructorDecl>(D))
+        Name =
----------------
ahatanak wrote:
> rsmith wrote:
> > Do we need to do this for conversion function names too? (Eg, `operator C1<T>*`)
> I added a definition of "operator C1<T>*" and called it in C1::foo1. I didn't see any crashes or asserts.
> 
> Calls to a destructor and a conversion function create different AST nodes (the former creates a MemberExpr and the latter creates a CXXDependentScopeMemberExpr) and are transformed by different functions of TreeTransform.
Please also check in that testcase.


================
Comment at: lib/Sema/TreeTransform.h:2127
+
+    if (isa<CXXDestructorDecl>(FoundDecl))
+      DNI = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
----------------
I don't see any reason why this should be specific to destructors. But this is the wrong place for this change; by the time we reach `Rebuild*` we should have already transformed everything that we need to transform.

Perhaps the problem is instead...


================
Comment at: lib/Sema/TreeTransform.h:11967-11969
   TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
   DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
                  SemaRef.Context.getCanonicalType(DestroyedType->getType())));
----------------
... that we fail to transform `DestroyedType` here. Can you try fixing this bug and see if that removes the need for your other changes?


https://reviews.llvm.org/D24969





More information about the cfe-commits mailing list