summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-06-26 23:10:48 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-06-26 23:10:48 +0000
commitc69e067668953f764c0a74cca1c55a1cf6b5fbb8 (patch)
tree79957e8e5e0c4b6a55b1b99de7920a63476f5e77 /clang/lib/CodeGen/CodeGenModule.cpp
parent32919a58612669d472bc6d88a80aaf54c20016d1 (diff)
downloadbcm5719-llvm-c69e067668953f764c0a74cca1c55a1cf6b5fbb8.tar.gz
bcm5719-llvm-c69e067668953f764c0a74cca1c55a1cf6b5fbb8.zip
Revert "[MS] Use mangled names and comdats for string merging with ASan"
Depends on r334313, which has been reverted in r335681. llvm-svn: 335684
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 35e9dea37a9..7752dbcc7c2 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4155,13 +4155,15 @@ CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
StringRef GlobalVariableName;
llvm::GlobalValue::LinkageTypes LT;
- // Mangle the string literal if that's how the ABI merges duplicate strings.
- // Don't do it if they are writable, since we don't want writes in one TU to
- // affect strings in another.
- if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) &&
- !LangOpts.WritableStrings) {
+ // Mangle the string literal if the ABI allows for it. However, we cannot
+ // do this if we are compiling with ASan or -fwritable-strings because they
+ // rely on strings having normal linkage.
+ if (!LangOpts.WritableStrings &&
+ !LangOpts.Sanitize.has(SanitizerKind::Address) &&
+ getCXXABI().getMangleContext().shouldMangleStringLiteral(S)) {
llvm::raw_svector_ostream Out(MangledNameBuffer);
getCXXABI().getMangleContext().mangleStringLiteral(S, Out);
+
LT = llvm::GlobalValue::LinkOnceODRLinkage;
GlobalVariableName = MangledNameBuffer;
} else {
OpenPOWER on IntegriCloud