]> granicus.if.org Git - clang/commitdiff
Revert "[MS] Use mangled names and comdats for string merging with ASan"
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Tue, 26 Jun 2018 23:10:48 +0000 (23:10 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Tue, 26 Jun 2018 23:10:48 +0000 (23:10 +0000)
Depends on r334313, which has been reverted in r335681.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335684 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp

index 35e9dea37a93c7da64a7d76b48b565a564e6653b..7752dbcc7c261ffb17a0b4d70e3efbc404095804 100644 (file)
@@ -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 {