[cfe-commits] r132861 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp lib/CodeGen/CodeGenModule.cpp test/CodeGenCXX/internal-linkage.cpp

Eli Friedman eli.friedman at gmail.com
Fri Jun 10 14:53:06 PDT 2011


Author: efriedma
Date: Fri Jun 10 16:53:06 2011
New Revision: 132861

URL: http://llvm.org/viewvc/llvm-project?rev=132861&view=rev
Log:
PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates.

While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp.


Modified:
    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/CodeGenCXX/internal-linkage.cpp

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=132861&r1=132860&r2=132861&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Jun 10 16:53:06 2011
@@ -1757,10 +1757,10 @@
   if (!RD->isPolymorphic())
     return 0;
 
-  // A class inside an anonymous namespace doesn't have a key function.  (Or
+  // A class that is not externally visible doesn't have a key function. (Or
   // at least, there's no point to assigning a key function to such a class;
   // this doesn't affect the ABI.)
-  if (RD->isInAnonymousNamespace())
+  if (RD->getLinkage() != ExternalLinkage)
     return 0;
 
   // Template instantiations don't have key functions,see Itanium C++ ABI 5.2.6.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=132861&r1=132860&r2=132861&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jun 10 16:53:06 2011
@@ -1125,7 +1125,7 @@
 
 llvm::GlobalVariable::LinkageTypes 
 CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
-  if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
+  if (RD->getLinkage() != ExternalLinkage)
     return llvm::GlobalVariable::InternalLinkage;
 
   if (const CXXMethodDecl *KeyFunction

Modified: cfe/trunk/test/CodeGenCXX/internal-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/internal-linkage.cpp?rev=132861&r1=132860&r2=132861&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/internal-linkage.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/internal-linkage.cpp Fri Jun 10 16:53:06 2011
@@ -54,3 +54,11 @@
     // CHECK: @extern_nonconst_xyzzy = global
     return &extern_nonconst_xyzzy;
 }
+
+// PR10120
+template <typename T> class klass {
+    virtual void f();
+};
+namespace { struct S; }
+void foo () { klass<S> x; }
+// CHECK: @_ZTV5klassIN12_GLOBAL__N_11SEE = internal unnamed_addr constant





More information about the cfe-commits mailing list