summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp18
-rw-r--r--clang/lib/CodeGen/Mangle.cpp25
-rw-r--r--clang/lib/CodeGen/Mangle.h1
3 files changed, 18 insertions, 26 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index c46db96bad6..97f989dbe38 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -305,11 +305,6 @@ void CodeGenModule::SetGlobalValueAttributes(const Decl *D,
setGlobalVisibility(GV, attr->getVisibility());
// FIXME: else handle -fvisibility
- // Prefaced with special LLVM marker to indicate that the name
- // should not be munged.
- if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>())
- GV->setName("\01" + ALA->getLabel());
-
if (const SectionAttr *SA = D->getAttr<SectionAttr>())
GV->setSection(SA->getName());
@@ -629,12 +624,6 @@ void CodeGenModule::EmitGlobalDefinition(const ValueDecl *D) {
if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>())
GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
- // FIXME: This should be handled by the mangler!
- if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
- // Prefaced with special LLVM marker to indicate that the name
- // should not be munged.
- GV->setName("\01" + ALA->getLabel());
- }
return Entry = GV;
}
@@ -746,13 +735,6 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
setGlobalVisibility(GV, attr->getVisibility());
// FIXME: else handle -fvisibility
- // FIXME: This should be a mangling issue.
- if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
- // Prefaced with special LLVM marker to indicate that the name
- // should not be munged.
- GV->setName("\01" + ALA->getLabel());
- }
-
// Set the llvm linkage type as appropriate.
if (D->getStorageClass() == VarDecl::Static)
GV->setLinkage(llvm::Function::InternalLinkage);
diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp
index e760b83fe6b..7a7a480bdb0 100644
--- a/clang/lib/CodeGen/Mangle.cpp
+++ b/clang/lib/CodeGen/Mangle.cpp
@@ -57,6 +57,15 @@ namespace {
bool CXXNameMangler::mangle(const NamedDecl *D) {
+ // Any decl can be declared with __asm("foo") on it, and this takes
+ // precedence over all other naming in the .o file.
+ if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
+ // If we have an asm name, then we use it as the mangling.
+ Out << '\01'; // LLVM IR Marker for __asm("foo")
+ Out << ALA->getLabel();
+ return true;
+ }
+
// <mangled-name> ::= _Z <encoding>
// ::= <data name>
// ::= <special-name>
@@ -68,15 +77,15 @@ bool CXXNameMangler::mangle(const NamedDecl *D) {
// Clang's "overloadable" attribute extension to C/C++ implies
// name mangling (always).
- if (FD->getAttr<OverloadableAttr>())
+ if (FD->getAttr<OverloadableAttr>()) {
; // fall into mangling code unconditionally.
- else if (// C functions are not mangled
- !Context.getLangOptions().CPlusPlus ||
- // "main" is not mangled in C++
- FD->isMain() ||
- // No mangling in an "implicit extern C" header.
- Context.getSourceManager().getFileCharacteristic(FD->getLocation())
- == SrcMgr::C_ExternCSystem)
+ } else if (// C functions are not mangled
+ !Context.getLangOptions().CPlusPlus ||
+ // "main" is not mangled in C++
+ FD->isMain() ||
+ // No mangling in an "implicit extern C" header.
+ Context.getSourceManager().getFileCharacteristic(FD->getLocation())
+ == SrcMgr::C_ExternCSystem)
return false;
else {
// No name mangling in a C linkage specification.
diff --git a/clang/lib/CodeGen/Mangle.h b/clang/lib/CodeGen/Mangle.h
index 60a5113ccc9..627c16a08ef 100644
--- a/clang/lib/CodeGen/Mangle.h
+++ b/clang/lib/CodeGen/Mangle.h
@@ -14,6 +14,7 @@
// http://www.codesourcery.com/public/cxx-abi/abi.html
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_CLANG_CODEGEN_MANGLE_H
#define LLVM_CLANG_CODEGEN_MANGLE_H
OpenPOWER on IntegriCloud