diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-03-06 19:57:36 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-03-06 19:57:36 +0000 |
| commit | 34b4989658a724111652c3dbe52b9ee42cd54c24 (patch) | |
| tree | bda4b73f6243a197aaf5f7a4a9456b92405acad1 /clang/lib | |
| parent | eeb5195d3a6e6ee0ecd0f9af7e08c37e3b520cbb (diff) | |
| download | bcm5719-llvm-34b4989658a724111652c3dbe52b9ee42cd54c24.tar.gz bcm5719-llvm-34b4989658a724111652c3dbe52b9ee42cd54c24.zip | |
MS ABI: Disambiguate the manglings for global guard variables
If a guard variable will be created for an entity at global scope,
then we cannot rely on the scope depth to disambiguate names for us.
Instead, mangle the entire variable into the guard to ensure it's uniqueness.
llvm-svn: 203151
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/MicrosoftMangle.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 6ef9a39e847..4321777a8b7 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -2280,13 +2280,17 @@ void MicrosoftMangleContextImpl::mangleStaticGuardVariable(const VarDecl *VD, bool Visible = VD->isExternallyVisible(); // <operator-name> ::= ?_B # local static guard Mangler.getStream() << (Visible ? "\01??_B" : "\01?$S1@"); - Mangler.mangleNestedName(VD); + unsigned ScopeDepth = 0; + if (Visible && !getNextDiscriminator(VD, ScopeDepth)) + // If we do not have a discriminator and are emitting a guard variable for + // use at global scope, then mangling the nested name will not be enough to + // remove ambiguities. + Mangler.mangle(VD, ""); + else + Mangler.mangleNestedName(VD); Mangler.getStream() << (Visible ? "@5" : "@4IA"); - if (Visible) { - unsigned ScopeDepth; - getNextDiscriminator(VD, ScopeDepth); + if (ScopeDepth) Mangler.mangleNumber(ScopeDepth); - } } void MicrosoftMangleContextImpl::mangleInitFiniStub(const VarDecl *D, |

