]> granicus.if.org Git - clang/commitdiff
Don't mangle names of local variables.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 5 Mar 2009 22:59:19 +0000 (22:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 5 Mar 2009 22:59:19 +0000 (22:59 +0000)
 - For one thing, this adds unneeded overhead; for another, this
   routine can be used to emit unnamed decls which we shouldn't try to
   mangle.

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

lib/CodeGen/CGDecl.cpp
lib/CodeGen/CodeGenModule.cpp
test/Coverage/objc-language-features.inc

index 3dfb1821cc0cff88c55144d5459469e2fefe45fd..e750d8a8d5ba2eb22c8f72bbc859621268874d4e 100644 (file)
@@ -236,8 +236,8 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
       const llvm::Type *LTy = ConvertTypeForMem(Ty);
       if (isByRef)
         LTy = BuildByRefType(Ty, getContext().getDeclAlignInBytes(&D));
-      llvm::AllocaInst *Alloc =
-        CreateTempAlloca(LTy, CGM.getMangledName(&D));
+      llvm::AllocaInst *Alloc = 
+        CreateTempAlloca(LTy, D.getNameAsString().c_str());
       if (isByRef)
         Alloc->setAlignment(std::max(getContext().getDeclAlignInBytes(&D),
                                      getContext().getTypeAlign(getContext().VoidPtrTy) / 8));
index a187f8a51bb4f1046f6d77dc0b980ba984237d3a..3f930feaaa080617217ad04848eb376d6407fd37 100644 (file)
@@ -170,8 +170,10 @@ static void setGlobalVisibility(llvm::GlobalValue *GV,
 const char *CodeGenModule::getMangledName(const NamedDecl *ND) {
   llvm::SmallString<256> Name;
   llvm::raw_svector_ostream Out(Name);
-  if (!mangleName(ND, Context, Out))
+  if (!mangleName(ND, Context, Out)) {
+    assert(ND->getIdentifier() && "Attempt to mangle unnamed decl.");
     return ND->getIdentifier()->getName();
+  }
 
   Name += '\0';
   return MangledNames.GetOrCreateValue(Name.begin(), Name.end())
index 25988f5e53a7161cd440c91f5a572a030ce860dc..3b092ffbf4cf611db6bb2a097d488dcfbc3ffc5e 100644 (file)
@@ -51,6 +51,9 @@
 @implementation A (Cat)
 @end
 
+@interface B
+@end
+
 int f0(id x) {
 #ifndef IRGENABLE_GNU
 #ifndef IRGENABLE
@@ -62,8 +65,13 @@ int f0(id x) {
 #ifndef IRGENABLE_GNU
   @try {
     @throw x;
+
   } @catch(A *e) {
     @throw;
+
+    // @catch param doesn't require name.
+  } @catch(B *) {
+
   } @finally {
     ;
   }