aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
parenta395f4df5b6d9c2feb661091ca75be2500d07cb0 (diff)
downloadexternal_llvm-64ea275fe4e85f112ccfaf9c7b56fe64e11c771f.zip
external_llvm-64ea275fe4e85f112ccfaf9c7b56fe64e11c771f.tar.gz
external_llvm-64ea275fe4e85f112ccfaf9c7b56fe64e11c771f.tar.bz2
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')
-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 86bc7ac..349dd0d 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!");