summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-11-16 07:07:28 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-11-16 07:07:28 +0000
commitdc9bf8fab6365af788976edddfc8221eceecaccb (patch)
treea1f6c8d9ceb7c895f5df00ba3850847c050545fa /clang/lib/AST/Expr.cpp
parent844ab6a0126a6379712e1db5c3c3a93653022f99 (diff)
downloadbcm5719-llvm-dc9bf8fab6365af788976edddfc8221eceecaccb.tar.gz
bcm5719-llvm-dc9bf8fab6365af788976edddfc8221eceecaccb.zip
Improve handling of __FUNCTION__ and other predefined expression for Objective-C Blocks
Instead of always displaying the mangled name, try to do better and get something closer to regular functions. Recommit r287039 (that was reverted in r287039) with a tweak to be more generic, and test fixes! Differential Revision: https://reviews.llvm.org/D26522 llvm-svn: 287085
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index a269c9945e4..6f0b5fe6d51 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -518,20 +518,21 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
}
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 (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())
- 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
- MC->mangleBlock(DC, BD, Out);
+ return "";
+
+ SmallString<256> Buffer;
+ llvm::raw_svector_ostream Out(Buffer);
+ if (auto *DCBlock = dyn_cast<BlockDecl>(DC))
+ // For nested blocks, propagate up to the parent.
+ Out << ComputeName(IT, DCBlock);
+ else if (auto *DCDecl = dyn_cast<Decl>(DC))
+ Out << ComputeName(IT, DCDecl) << "_block_invoke";
return Out.str();
}
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
OpenPOWER on IntegriCloud