[cfe-commits] r68280 - /cfe/trunk/lib/CodeGen/CGDecl.cpp

Anders Carlsson andersca at mac.com
Wed Apr 1 20:29:49 PDT 2009


Author: andersca
Date: Wed Apr  1 22:29:47 2009
New Revision: 68280

URL: http://llvm.org/viewvc/llvm-project?rev=68280&view=rev
Log:
When compiling C++ code, always mangle the names of static block var decls.

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=68280&r1=68279&r2=68280&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Apr  1 22:29:47 2009
@@ -86,19 +86,25 @@
   QualType Ty = D.getType();
   assert(Ty->isConstantSizeType() && "VLAs can't be static");
 
-  std::string ContextName;
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl))
-    ContextName = CGM.getMangledName(FD);
-  else if (isa<ObjCMethodDecl>(CurFuncDecl))
-    ContextName = std::string(CurFn->getNameStart(), 
-                              CurFn->getNameStart() + CurFn->getNameLen());
-  else
-    assert(0 && "Unknown context for block var decl");
+  std::string Name;
+  if (getContext().getLangOptions().CPlusPlus) {
+    Name = CGM.getMangledName(&D);
+  } else {
+    std::string ContextName;
+    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurFuncDecl))
+      ContextName = CGM.getMangledName(FD);
+    else if (isa<ObjCMethodDecl>(CurFuncDecl))
+      ContextName = std::string(CurFn->getNameStart(), 
+                                CurFn->getNameStart() + CurFn->getNameLen());
+    else
+      assert(0 && "Unknown context for block var decl");
+    
+    Name = ContextName + Separator + D.getNameAsString();
+  }
 
   const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty);
   return new llvm::GlobalVariable(LTy, Ty.isConstant(getContext()), Linkage,
-                                  llvm::Constant::getNullValue(LTy), 
-                                  ContextName + Separator + D.getNameAsString(),
+                                  llvm::Constant::getNullValue(LTy), Name,
                                   &CGM.getModule(), 0, Ty.getAddressSpace());
 }
 





More information about the cfe-commits mailing list