]> granicus.if.org Git - clang/commitdiff
Fix mangling for static member variables of classes inside an extern "C"
authorEli Friedman <eli.friedman@gmail.com>
Sun, 18 Jul 2010 20:49:59 +0000 (20:49 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 18 Jul 2010 20:49:59 +0000 (20:49 +0000)
linkage specification.  Not sure if this is the ideal fix, but I'm reasonably
sure it's correct vs. gcc.

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

lib/CodeGen/Mangle.cpp
test/CodeGenCXX/mangle.cpp

index 58b0246e36381ccd5529af4b45c66e4983e804b0..f408849e95e516242732b068f3b5e3da8268657f 100644 (file)
@@ -304,6 +304,10 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) {
       return false;
   }
 
+  // Class members are always mangled.
+  if (D->getDeclContext()->isRecord())
+    return true;
+
   // C functions and "main" are not mangled.
   if ((FD && FD->isMain()) || isInCLinkageSpecification(D))
     return false;
index 814a7592fad0157a17beeb3539d8671fb2a7cc98..37af79b0f9c386daf4603299ffa5bcc4d9c7bdea 100644 (file)
@@ -507,3 +507,14 @@ namespace test13 {
   // CHECK: define weak_odr void @_ZN6test133fooINS_1BEEEvRKNS_1AIT_EE(
   template void foo(const A<B> &a);
 }
+
+namespace test14 {
+  extern "C" {
+    struct S {
+      static int a(), x;
+    };
+    // CHECK: define i32 @_ZN6test141S1aEv
+    // CHECK: load i32* @_ZN6test141S1xE
+    int S::a() { return S::x; }
+  }
+}