[cfe-commits] r156806 - in /cfe/trunk: lib/Sema/TreeTransform.h test/CodeGenCXX/virtual-destructor-calls.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon May 14 23:15:11 PDT 2012


Author: rsmith
Date: Tue May 15 01:15:11 2012
New Revision: 156806

URL: http://llvm.org/viewvc/llvm-project?rev=156806&view=rev
Log:
PR12798: Don't drop part of the nested name specifier when instantiating a
pseudo-destructor expression. This can affect whether virtual dispatch for
the destructor call is bypassed.

Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/CodeGenCXX/virtual-destructor-calls.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=156806&r1=156805&r2=156806&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue May 15 01:15:11 2012
@@ -9268,7 +9268,11 @@
   DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
   NameInfo.setNamedTypeInfo(DestroyedType);
 
-  // FIXME: the ScopeType should be tacked onto SS.
+  // The scope type is now known to be a valid nested name specifier
+  // component. Tack it on to the end of the nested name specifier.
+  if (ScopeType)
+    SS.Extend(SemaRef.Context, SourceLocation(),
+              ScopeType->getTypeLoc(), CCLoc);
 
   SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
   return getSema().BuildMemberReferenceExpr(Base, BaseType,

Modified: cfe/trunk/test/CodeGenCXX/virtual-destructor-calls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-destructor-calls.cpp?rev=156806&r1=156805&r2=156806&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virtual-destructor-calls.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virtual-destructor-calls.cpp Tue May 15 01:15:11 2012
@@ -46,3 +46,14 @@
 // CHECK: call void @_ZdlPv
 
 // Base dtor: just an alias to B's base dtor.
+
+namespace PR12798 {
+  // A qualified call to a base class destructor should not undergo virtual
+  // dispatch. Template instantiation used to lose the qualifier.
+  struct A { virtual ~A(); };
+  template<typename T> void f(T *p) { p->A::~A(); }
+
+  // CHECK: define {{.*}} @_ZN7PR127981fINS_1AEEEvPT_(
+  // CHECK: call void @_ZN7PR127981AD1Ev(
+  template void f(A*);
+}





More information about the cfe-commits mailing list