diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-10-11 00:38:25 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-10-11 00:38:25 +0000 |
commit | 686d7cbf70c0dd47a922c775dc71b4cad336b8ff (patch) | |
tree | 52c5d47cdb382e0e0803a35b9801d6d93800b01c /llvm/lib/AsmParser/LLParser.cpp | |
parent | adf42185f6cdf26877921b6eacb9d545f6be8dad (diff) | |
download | bcm5719-llvm-686d7cbf70c0dd47a922c775dc71b4cad336b8ff.tar.gz bcm5719-llvm-686d7cbf70c0dd47a922c775dc71b4cad336b8ff.zip |
Don't crash if a .ll file contains a forward-reference that looks like a global
value but later turns out to be a function.
Unfortunately, we can't fold tests into a single file because we only get one
error out of llvm-as.
llvm-svn: 165680
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 86bc7aced1e..349dd0dad73 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2795,6 +2795,9 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { ForwardRefVals.find(FunctionName); if (FRVI != ForwardRefVals.end()) { Fn = M->getFunction(FunctionName); + if (!Fn) + return Error(FRVI->second.second, "invalid forward reference to " + "function as global value!"); if (Fn->getType() != PFT) return Error(FRVI->second.second, "invalid forward reference to " "function '" + FunctionName + "' with wrong type!"); |