r185989 - Get rid of dead/useless code for block mangling.

Eli Friedman eli.friedman at gmail.com
Tue Jul 9 18:13:27 PDT 2013


Author: efriedma
Date: Tue Jul  9 20:13:27 2013
New Revision: 185989

URL: http://llvm.org/viewvc/llvm-project?rev=185989&view=rev
Log:
Get rid of dead/useless code for block mangling.

Modified:
    cfe/trunk/include/clang/AST/Mangle.h
    cfe/trunk/lib/AST/Mangle.cpp
    cfe/trunk/lib/AST/MicrosoftMangle.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/include/clang/AST/Mangle.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Mangle.h?rev=185989&r1=185988&r2=185989&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Mangle.h (original)
+++ cfe/trunk/include/clang/AST/Mangle.h Tue Jul  9 20:13:27 2013
@@ -135,9 +135,6 @@ public:
                        const BlockDecl *BD, raw_ostream &Out);
   void mangleBlock(const DeclContext *DC, const BlockDecl *BD,
                    raw_ostream &Out);
-  // Do the right thing.
-  void mangleBlock(const BlockDecl *BD, raw_ostream &Out,
-                   const NamedDecl *ID=0);
 
   void mangleObjCMethodName(const ObjCMethodDecl *MD,
                             raw_ostream &);

Modified: cfe/trunk/lib/AST/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Mangle.cpp?rev=185989&r1=185988&r2=185989&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Mangle.cpp (original)
+++ cfe/trunk/lib/AST/Mangle.cpp Tue Jul  9 20:13:27 2013
@@ -34,8 +34,6 @@ using namespace clang;
 // FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
 // much to be desired. Come up with a better mangling scheme.
 
-namespace {
-
 static void mangleFunctionBlock(MangleContext &Context,
                                 StringRef Outer,
                                 const BlockDecl *BD,
@@ -47,22 +45,6 @@ static void mangleFunctionBlock(MangleCo
     Out << "__" << Outer << "_block_invoke_" << discriminator+1; 
 }
 
-static void checkMangleDC(const DeclContext *DC, const BlockDecl *BD) {
-#ifndef NDEBUG
-  const DeclContext *ExpectedDC = BD->getDeclContext();
-  while (isa<BlockDecl>(ExpectedDC) || isa<EnumDecl>(ExpectedDC))
-    ExpectedDC = ExpectedDC->getParent();
-  // In-class initializers for non-static data members are lexically defined
-  // within the class, but are mangled as if they were specified as constructor
-  // member initializers.
-  if (isa<CXXRecordDecl>(ExpectedDC) && DC != ExpectedDC)
-    DC = DC->getParent();
-  assert(DC == ExpectedDC && "Given decl context did not match expected!");
-#endif
-}
-
-}
-
 void MangleContext::anchor() { }
 
 void MangleContext::mangleGlobalBlock(const BlockDecl *BD,
@@ -85,7 +67,6 @@ void MangleContext::mangleGlobalBlock(co
 void MangleContext::mangleCtorBlock(const CXXConstructorDecl *CD,
                                     CXXCtorType CT, const BlockDecl *BD,
                                     raw_ostream &ResStream) {
-  checkMangleDC(CD, BD);
   SmallString<64> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
   mangleCXXCtor(CD, CT, Out);
@@ -96,7 +77,6 @@ void MangleContext::mangleCtorBlock(cons
 void MangleContext::mangleDtorBlock(const CXXDestructorDecl *DD,
                                     CXXDtorType DT, const BlockDecl *BD,
                                     raw_ostream &ResStream) {
-  checkMangleDC(DD, BD);
   SmallString<64> Buffer;
   llvm::raw_svector_ostream Out(Buffer);
   mangleCXXDtor(DD, DT, Out);
@@ -107,7 +87,6 @@ void MangleContext::mangleDtorBlock(cons
 void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD,
                                 raw_ostream &Out) {
   assert(!isa<CXXConstructorDecl>(DC) && !isa<CXXDestructorDecl>(DC));
-  checkMangleDC(DC, BD);
 
   SmallString<64> Buffer;
   llvm::raw_svector_ostream Stream(Buffer);
@@ -145,15 +124,3 @@ void MangleContext::mangleObjCMethodName
   
   Out << OS.str().size() << OS.str();
 }
-
-void MangleContext::mangleBlock(const BlockDecl *BD,
-                                raw_ostream &Out,
-                                const NamedDecl *ID) {
-  const DeclContext *DC = BD->getDeclContext();
-  while (isa<BlockDecl>(DC) || isa<EnumDecl>(DC))
-    DC = DC->getParent();
-  if (DC->isFunctionOrMethod())
-    mangleBlock(DC, BD, Out);
-  else
-    mangleGlobalBlock(BD, ID, Out);
-}

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=185989&r1=185988&r2=185989&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Jul  9 20:13:27 2013
@@ -556,7 +556,14 @@ void MicrosoftCXXNameMangler::manglePost
     return;
 
   if (const BlockDecl *BD = dyn_cast<BlockDecl>(DC)) {
-    Context.mangleBlock(BD, Out);
+    DiagnosticsEngine Diags = Context.getDiags();
+    unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
+      "cannot mangle a local inside this block yet");
+    Diags.Report(BD->getLocation(), DiagID);
+
+    // FIXME: This is completely, utterly, wrong; see ItaniumMangle
+    // for how this should be done.
+    Out << "__block_invoke" << Context.getBlockId(BD, false);
     Out << '@';
     return manglePostfix(DC->getParent(), NoFunction);
   } else if (isa<CapturedDecl>(DC)) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=185989&r1=185988&r2=185989&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jul  9 20:13:27 2013
@@ -434,9 +434,6 @@ StringRef CodeGenModule::getMangledName(
     getCXXABI().getMangleContext().mangleCXXCtor(D, GD.getCtorType(), Out);
   else if (const CXXDestructorDecl *D = dyn_cast<CXXDestructorDecl>(ND))
     getCXXABI().getMangleContext().mangleCXXDtor(D, GD.getDtorType(), Out);
-  else if (const BlockDecl *BD = dyn_cast<BlockDecl>(ND))
-    getCXXABI().getMangleContext().mangleBlock(BD, Out,
-      dyn_cast_or_null<VarDecl>(initializedGlobalDecl.getDecl()));
   else
     getCXXABI().getMangleContext().mangleName(ND, Out);
 





More information about the cfe-commits mailing list