diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-03-24 05:53:08 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-03-24 05:53:08 +0000 |
commit | 96bc4b03676655383766ca2337245a8d82f58403 (patch) | |
tree | 245207c6cac977543c4eb0b32f7a6783f56a0f18 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 016d69d29feaa45f10c097e27a081cfa93fe0e2a (diff) | |
download | bcm5719-llvm-96bc4b03676655383766ca2337245a8d82f58403.tar.gz bcm5719-llvm-96bc4b03676655383766ca2337245a8d82f58403.zip |
MS ABI: Add tests, other cleanups for r204562
This commit cleans up a few accidents:
- Do not rely on the order in which StringLiteral lays out bytes.
- Use a more efficient mechanism for handling so-called
"special-mappings" when mangling string literals.
- There is no need to allocate a copy of the mangled name.
- Add the test written for r204562.
Thanks to Richard Smith for pointing these out!
llvm-svn: 204586
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 097e30c71d1..e5a0fa56447 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2595,21 +2595,17 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) { } if (!GV) { + SmallString<256> MangledNameBuffer; StringRef GlobalVariableName; llvm::GlobalValue::LinkageTypes LT; if (!LangOpts.WritableStrings && getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) { - LT = llvm::GlobalValue::LinkOnceODRLinkage; - - SmallString<256> Buffer; - llvm::raw_svector_ostream Out(Buffer); + llvm::raw_svector_ostream Out(MangledNameBuffer); getCXXABI().getMangleContext().mangleStringLiteral(S, Out); Out.flush(); - size_t Length = Buffer.size(); - char *Name = MangledNamesAllocator.Allocate<char>(Length); - std::copy(Buffer.begin(), Buffer.end(), Name); - GlobalVariableName = StringRef(Name, Length); + LT = llvm::GlobalValue::LinkOnceODRLinkage; + GlobalVariableName = MangledNameBuffer; } else { LT = llvm::GlobalValue::PrivateLinkage;; GlobalVariableName = ".str"; |