summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Mangle.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2019-09-25 18:00:31 +0000
committerVedant Kumar <vsk@apple.com>2019-09-25 18:00:31 +0000
commitf6bc251274f39dee5d09f668a56922c88bd027d8 (patch)
tree228442b512d620525a646351763c472c46936f87 /clang/lib/AST/Mangle.cpp
parent4de7ae65325613d8ec75c4cb79730e522a7046c4 (diff)
downloadbcm5719-llvm-f6bc251274f39dee5d09f668a56922c88bd027d8.tar.gz
bcm5719-llvm-f6bc251274f39dee5d09f668a56922c88bd027d8.zip
[Mangle] Add flag to asm labels to disable '\01' prefixing
LLDB synthesizes decls using asm labels. These decls cannot have a mangle different than the one specified in the label name. I.e., the '\01' prefix should not be added. Fixes an expression evaluation failure in lldb's TestVirtual.py on iOS. rdar://45827323 Differential Revision: https://reviews.llvm.org/D67774 llvm-svn: 372903
Diffstat (limited to 'clang/lib/AST/Mangle.cpp')
-rw-r--r--clang/lib/AST/Mangle.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 28de87fde9e..b158fe85a47 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -122,15 +122,21 @@ void MangleContext::mangleName(const NamedDecl *D, raw_ostream &Out) {
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
// If we have an asm name, then we use it as the mangling.
+ // If the label isn't literal, or if this is an alias for an LLVM intrinsic,
+ // do not add a "\01" prefix.
+ if (!ALA->getIsLiteralLabel() || ALA->getLabel().startswith("llvm.")) {
+ Out << ALA->getLabel();
+ return;
+ }
+
// Adding the prefix can cause problems when one file has a "foo" and
// another has a "\01foo". That is known to happen on ELF with the
// tricks normally used for producing aliases (PR9177). Fortunately the
// llvm mangler on ELF is a nop, so we can just avoid adding the \01
- // marker. We also avoid adding the marker if this is an alias for an
- // LLVM intrinsic.
+ // marker.
char GlobalPrefix =
getASTContext().getTargetInfo().getDataLayout().getGlobalPrefix();
- if (GlobalPrefix && !ALA->getLabel().startswith("llvm."))
+ if (GlobalPrefix)
Out << '\01'; // LLVM IR Marker for __asm("foo")
Out << ALA->getLabel();
OpenPOWER on IntegriCloud