diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-06 02:06:40 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-06 02:06:40 +0000 |
commit | 29883866a40279a1e8328b06f0b443493d06a95b (patch) | |
tree | ca47cff3aeb7b42ef03e9ca07652a752771a089b /llvm/lib/AsmParser/LLParser.cpp | |
parent | 2e5973ef74efb0c74815c4f5129cadcac2905b97 (diff) | |
download | llvm-29883866a40279a1e8328b06f0b443493d06a95b.zip llvm-29883866a40279a1e8328b06f0b443493d06a95b.tar.gz llvm-29883866a40279a1e8328b06f0b443493d06a95b.tar.bz2 |
AsmParser: Don't crash on unresolved !tbaa
Instead of crashing, give a nice error. As a drive-by, fix the location
associated with the errors for unresolved metadata (the location was off
by one token).
llvm-svn: 265507
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 3eb52ea..369dbb3 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -100,9 +100,6 @@ void LLParser::restoreParsingState(const SlotMapping *Slots) { /// ValidateEndOfModule - Do final validity and sanity checks at the end of the /// module. bool LLParser::ValidateEndOfModule() { - for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++) - UpgradeInstWithTBAATag(InstsWithTBAATag[I]); - // Handle any function attribute group forward references. for (std::map<Value*, std::vector<unsigned> >::iterator I = ForwardRefAttrGroups.begin(), E = ForwardRefAttrGroups.end(); @@ -205,6 +202,9 @@ bool LLParser::ValidateEndOfModule() { N.second->resolveCycles(); } + for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++) + UpgradeInstWithTBAATag(InstsWithTBAATag[I]); + // Look for intrinsic functions and CallInst that need to be upgraded for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; ) UpgradeCallsToIntrinsic(&*FI++); // must be post-increment, as we remove @@ -601,6 +601,7 @@ bool LLParser::ParseMDString(MDString *&Result) { // ::= '!' MDNodeNumber bool LLParser::ParseMDNodeID(MDNode *&Result) { // !{ ..., !42, ... } + LocTy IDLoc = Lex.getLoc(); unsigned MID = 0; if (ParseUInt32(MID)) return true; @@ -613,7 +614,7 @@ bool LLParser::ParseMDNodeID(MDNode *&Result) { // Otherwise, create MDNode forward reference. auto &FwdRef = ForwardRefMDNodes[MID]; - FwdRef = std::make_pair(MDTuple::getTemporary(Context, None), Lex.getLoc()); + FwdRef = std::make_pair(MDTuple::getTemporary(Context, None), IDLoc); Result = FwdRef.first.get(); NumberedMetadata[MID].reset(Result); |