summaryrefslogtreecommitdiff
path: root/lib/AsmParser
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-10-11 00:38:25 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-10-11 00:38:25 +0000
commit64ea275fe4e85f112ccfaf9c7b56fe64e11c771f (patch)
tree3528d07725139915c84087c2453458d8916dac58 /lib/AsmParser
parenta395f4df5b6d9c2feb661091ca75be2500d07cb0 (diff)
downloadllvm-64ea275fe4e85f112ccfaf9c7b56fe64e11c771f.tar.gz
llvm-64ea275fe4e85f112ccfaf9c7b56fe64e11c771f.tar.bz2
llvm-64ea275fe4e85f112ccfaf9c7b56fe64e11c771f.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165680 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
-rw-r--r--lib/AsmParser/LLParser.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 86bc7aced1..349dd0dad7 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/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!");