Fix use-after-free when a C++ thread_local variable gets replaced (because its

type changes when the initializer is attached). Don't hold onto the
GlobalVariable*; recompute it from the VarDecl* instead.

llvm-svn: 254359
This commit is contained in:
Richard Smith
2015-12-01 01:10:48 +00:00
parent 21ed3b13bd
commit 5a99c49d2e
7 changed files with 34 additions and 32 deletions

View File

@@ -1986,7 +1986,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
if (D->getTLSKind()) {
if (D->getTLSKind() == VarDecl::TLS_Dynamic)
CXXThreadLocals.push_back(std::make_pair(D, GV));
CXXThreadLocals.push_back(D);
setTLSMode(GV, *D);
}
@@ -2379,7 +2379,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
if (D->getTLSKind() && !GV->isThreadLocal()) {
if (D->getTLSKind() == VarDecl::TLS_Dynamic)
CXXThreadLocals.push_back(std::make_pair(D, GV));
CXXThreadLocals.push_back(D);
setTLSMode(GV, *D);
}