summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-11-15 22:19:50 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-11-15 22:19:50 +0000
commitf5f37ee546bd05427e37b5e9ab2cbcb2ac72f5cc (patch)
treee3116b8c67637f05f0d264800d5964a12284bf26 /clang/lib
parente5cd5ecd2ec73737cc7a38daeb7a38a4ad165d7a (diff)
downloadbcm5719-llvm-f5f37ee546bd05427e37b5e9ab2cbcb2ac72f5cc.tar.gz
bcm5719-llvm-f5f37ee546bd05427e37b5e9ab2cbcb2ac72f5cc.zip
Revert "Improve handling of __FUNCTION__ and other predefined expression for Objective-C Blocks"
This reverts commit r287039, tests are broken. llvm-svn: 287043
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp23
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp16
2 files changed, 14 insertions, 25 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index fbaa79aac0d..a269c9945e4 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -518,21 +518,20 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
}
return "";
}
- if (isa<BlockDecl>(CurrentDecl)) {
- // For blocks we only emit something if it is enclosed in a function
- // For top-level block we'd like to include the name of variable, but we
- // don't have it at this point.
- auto DC = CurrentDecl->getDeclContext();
- if (DC->isFileContext())
- return "";
-
+ if (auto *BD = dyn_cast<BlockDecl>(CurrentDecl)) {
+ std::unique_ptr<MangleContext> MC;
+ MC.reset(Context.createMangleContext());
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
- if (auto *DCFunc = dyn_cast<FunctionDecl>(DC))
- Out << ComputeName(IT, DCFunc) << "_block_invoke";
+ auto DC = CurrentDecl->getDeclContext();
+ if (DC->isFileContext())
+ MC->mangleGlobalBlock(BD, /*ID*/ nullptr, Out);
+ else if (const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
+ MC->mangleCtorBlock(CD, /*CT*/ Ctor_Complete, BD, Out);
+ else if (const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
+ MC->mangleDtorBlock(DD, /*DT*/ Dtor_Complete, BD, Out);
else
- // For nested blocks, propagate up to the parent.
- Out << ComputeName(IT, cast<BlockDecl>(DC));
+ MC->mangleBlock(DC, BD, Out);
return Out.str();
}
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 6db668204f5..08e1cad5305 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2319,19 +2319,9 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
StringRef NameItems[] = {
PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
- if (auto *BD = dyn_cast<BlockDecl>(CurCodeDecl)) {
- std::string Name = SL->getString();
- if (!Name.empty()) {
- unsigned Discriminator =
- CGM.getCXXABI().getMangleContext().getBlockId(BD, true);
- if (Discriminator)
- Name += "_" + Twine(Discriminator + 1).str();
- auto C = CGM.GetAddrOfConstantCString(Name, GVName.c_str());
- return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
- } else {
- auto C = CGM.GetAddrOfConstantCString(FnName, GVName.c_str());
- return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
- }
+ if (CurCodeDecl && isa<BlockDecl>(CurCodeDecl)) {
+ auto C = CGM.GetAddrOfConstantCString(FnName, GVName.c_str());
+ return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
}
auto C = CGM.GetAddrOfConstantStringFromLiteral(SL, GVName);
return MakeAddrLValue(C, E->getType(), AlignmentSource::Decl);
OpenPOWER on IntegriCloud