diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-21 08:24:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-21 08:24:40 +0000 |
commit | ca3f25c1fb9bbf0d807985baee460670b7f195b4 (patch) | |
tree | 4eefdaba5322484a2fc0bd15c486ed7f0d5301b4 /lib/CodeGen/Mangle.cpp | |
parent | 2d58406872e5af0c924623d9f7c194c4f09936d3 (diff) |
fix several problems with asm renaming, by pulling it into the mangling code:
1. it wasn't applying to definitions, only declarations, e.g. int x __asm("foo")
2. multiple definitions were conflicting, they weren't getting merged.
3. the code was duplicated in several places.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/Mangle.cpp')
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index e760b83fe6..7a7a480bdb 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/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. |