]> granicus.if.org Git - clang/commitdiff
The global variable for the VTT might not have external linkage; allow
authorDouglas Gregor <dgregor@apple.com>
Thu, 6 May 2010 22:18:21 +0000 (22:18 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 6 May 2010 22:18:21 +0000 (22:18 +0000)
us to find local variables, too. Fixes the last remaining
Boost.Rational failure.

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

lib/CodeGen/CGVTT.cpp
test/CodeGenCXX/anonymous-namespaces.cpp

index 15e564810f83caacb8cb8061442a63ee955e87d4..61c74230e1183fa9c901ff84a6da09b67c9a648a 100644 (file)
@@ -378,7 +378,7 @@ CodeGenVTables::GenerateVTT(llvm::GlobalVariable::LinkageTypes Linkage,
 
   D1(printf("vtt %s\n", RD->getNameAsCString()));
 
-  llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name);
+  llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
   if (GV == 0 || GV->isDeclaration()) {
     const llvm::Type *Int8PtrTy = 
       llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
index 695f8f59defc93893d58e74e7e0969a3da15e4fe..fb3470ca9bee581841647cc9a1be36ee60b03e53 100644 (file)
@@ -1,6 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
 
-
 int f();
 
 namespace {
@@ -20,6 +19,13 @@ namespace {
   
   int D::d = f();
 
+  // Check for generation of a VTT with internal linkage
+  // CHECK: @_ZTSN12_GLOBAL__N_11X1EE = internal constant
+  struct X { 
+    struct EBase { };
+    struct E : public virtual EBase { virtual ~E() {} };
+  };
+
   // CHECK: define internal i32 @_ZN12_GLOBAL__N_13fooEv()
   int foo() {
     return 32;
@@ -36,3 +42,5 @@ namespace {
 int concrete() {
   return a + foo() + A::foo();
 }
+
+void test_XE() { throw X::E(); }