[llvm-commits] [llvm] r165680 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/Assembler/invalid-fwdref1.ll

Nick Lewycky nicholas at mxc.ca
Wed Oct 10 17:38:25 PDT 2012


Author: nicholas
Date: Wed Oct 10 19:38:25 2012
New Revision: 165680

URL: http://llvm.org/viewvc/llvm-project?rev=165680&view=rev
Log:
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.

Added:
    llvm/trunk/test/Assembler/invalid-fwdref1.ll
Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=165680&r1=165679&r2=165680&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Oct 10 19:38:25 2012
@@ -2795,6 +2795,9 @@
       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!");

Added: llvm/trunk/test/Assembler/invalid-fwdref1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-fwdref1.ll?rev=165680&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-fwdref1.ll (added)
+++ llvm/trunk/test/Assembler/invalid-fwdref1.ll Wed Oct 10 19:38:25 2012
@@ -0,0 +1,4 @@
+; RUN: not llvm-as %s -disable-output 2>&1 | grep "invalid forward reference to function as global value!"
+
+define i8* @test1() { ret i8* @test1a }
+define void @test1a() { }





More information about the llvm-commits mailing list