From e5798893b1fb2468a11e8374d340e6fa2f82a9a5 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 10 Jul 2013 01:13:27 +0000 Subject: [PATCH] Get rid of dead/useless code for block mangling. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185989 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Mangle.h | 3 --- lib/AST/Mangle.cpp | 33 --------------------------------- lib/AST/MicrosoftMangle.cpp | 9 ++++++++- lib/CodeGen/CodeGenModule.cpp | 3 --- 4 files changed, 8 insertions(+), 40 deletions(-) diff --git a/include/clang/AST/Mangle.h b/include/clang/AST/Mangle.h index 98e03f5dec..c13cd257d9 100644 --- a/include/clang/AST/Mangle.h +++ b/include/clang/AST/Mangle.h @@ -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 &); diff --git a/lib/AST/Mangle.cpp b/lib/AST/Mangle.cpp index eb79412449..07c84b2eb4 100644 --- a/lib/AST/Mangle.cpp +++ b/lib/AST/Mangle.cpp @@ -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(MangleContext &Context, Out << "__" << Outer << "_block_invoke_" << discriminator+1; } -static void checkMangleDC(const DeclContext *DC, const BlockDecl *BD) { -#ifndef NDEBUG - const DeclContext *ExpectedDC = BD->getDeclContext(); - while (isa(ExpectedDC) || isa(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(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(const BlockDecl *BD, 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(const CXXConstructorDecl *CD, 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(const CXXDestructorDecl *DD, void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD, raw_ostream &Out) { assert(!isa(DC) && !isa(DC)); - checkMangleDC(DC, BD); SmallString<64> Buffer; llvm::raw_svector_ostream Stream(Buffer); @@ -145,15 +124,3 @@ void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD, 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(DC) || isa(DC)) - DC = DC->getParent(); - if (DC->isFunctionOrMethod()) - mangleBlock(DC, BD, Out); - else - mangleGlobalBlock(BD, ID, Out); -} diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index 8c02b3310d..143472f059 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -556,7 +556,14 @@ void MicrosoftCXXNameMangler::manglePostfix(const DeclContext *DC, return; if (const BlockDecl *BD = dyn_cast(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(DC)) { diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 250442caae..af6a0113f2 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -434,9 +434,6 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) { getCXXABI().getMangleContext().mangleCXXCtor(D, GD.getCtorType(), Out); else if (const CXXDestructorDecl *D = dyn_cast(ND)) getCXXABI().getMangleContext().mangleCXXDtor(D, GD.getDtorType(), Out); - else if (const BlockDecl *BD = dyn_cast(ND)) - getCXXABI().getMangleContext().mangleBlock(BD, Out, - dyn_cast_or_null(initializedGlobalDecl.getDecl())); else getCXXABI().getMangleContext().mangleName(ND, Out); -- 2.40.0