diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-09 21:49:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-09 21:49:17 +0000 |
commit | 1acea2db56e8bef378dc53f732f005ade4205d68 (patch) | |
tree | bbb1226c3ee978073ee4d74f32451533b9579186 /lib/AsmParser/LLParser.cpp | |
parent | 482018007c06507ec667f420ccbccb3d134acc3b (diff) | |
download | llvm-1acea2db56e8bef378dc53f732f005ade4205d68.tar.gz llvm-1acea2db56e8bef378dc53f732f005ade4205d68.tar.bz2 llvm-1acea2db56e8bef378dc53f732f005ade4205d68.tar.xz |
Don't crash on redefinitions.
One error we were not deleting the alias or putting it in the Module. The
end result is that there was an use left of the aliasee when the module was
deleted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208447 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r-- | lib/AsmParser/LLParser.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 32037df958..892cff6f8f 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -673,9 +673,8 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, return Error(AliaseeLoc, "alias must have pointer type"); // Okay, create the alias but do not insert it into the module yet. - GlobalAlias* GA = new GlobalAlias(Aliasee->getType(), - (GlobalValue::LinkageTypes)Linkage, Name, - Aliasee); + std::unique_ptr<GlobalAlias> GA(new GlobalAlias( + Aliasee->getType(), (GlobalValue::LinkageTypes)Linkage, Name, Aliasee)); GA->setVisibility((GlobalValue::VisibilityTypes)Visibility); GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass); @@ -697,15 +696,18 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc, // If they agree, just RAUW the old value with the alias and remove the // forward ref info. - Val->replaceAllUsesWith(GA); + Val->replaceAllUsesWith(GA.get()); Val->eraseFromParent(); ForwardRefVals.erase(I); } // Insert into the module, we know its name won't collide now. - M->getAliasList().push_back(GA); + M->getAliasList().push_back(GA.get()); assert(GA->getName() == Name && "Should not be a name conflict!"); + // The module owns this now + GA.release(); + return false; } |