[llvm] r231634 - Fix a bug in the LLParser where we failed to diagnose landingpads with non-constant clause operands.
Owen Anderson
resistor at mac.com
Mon Mar 9 00:13:42 PDT 2015
Author: resistor
Date: Mon Mar 9 02:13:42 2015
New Revision: 231634
URL: http://llvm.org/viewvc/llvm-project?rev=231634&view=rev
Log:
Fix a bug in the LLParser where we failed to diagnose landingpads with non-constant clause operands.
Fixing this also exposed a related issue where the landingpad under construction was not
cleaned up when an error was raised, which would cause bad reference errors before the
error could actually be printed.
Added:
llvm/trunk/test/Assembler/invalid-landingpad.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=231634&r1=231633&r2=231634&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Mar 9 02:13:42 2015
@@ -5041,7 +5041,7 @@ bool LLParser::ParseLandingPad(Instructi
ParseTypeAndValue(PersFn, PersFnLoc, PFS))
return true;
- LandingPadInst *LP = LandingPadInst::Create(Ty, PersFn, 0);
+ std::unique_ptr<LandingPadInst> LP(LandingPadInst::Create(Ty, PersFn, 0));
LP->setCleanup(EatIfPresent(lltok::kw_cleanup));
while (Lex.getKind() == lltok::kw_catch || Lex.getKind() == lltok::kw_filter){
@@ -5055,10 +5055,8 @@ bool LLParser::ParseLandingPad(Instructi
Value *V;
LocTy VLoc;
- if (ParseTypeAndValue(V, VLoc, PFS)) {
- delete LP;
+ if (ParseTypeAndValue(V, VLoc, PFS))
return true;
- }
// A 'catch' type expects a non-array constant. A filter clause expects an
// array constant.
@@ -5070,10 +5068,13 @@ bool LLParser::ParseLandingPad(Instructi
Error(VLoc, "'filter' clause has an invalid type");
}
- LP->addClause(cast<Constant>(V));
+ Constant *CV = dyn_cast<Constant>(V);
+ if (!CV)
+ return Error(VLoc, "clause argument must be a constant");
+ LP->addClause(CV);
}
- Inst = LP;
+ Inst = LP.release();
return false;
}
Added: llvm/trunk/test/Assembler/invalid-landingpad.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-landingpad.ll?rev=231634&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-landingpad.ll (added)
+++ llvm/trunk/test/Assembler/invalid-landingpad.ll Mon Mar 9 02:13:42 2015
@@ -0,0 +1,7 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; CHECK: clause argument must be a constant
+
+define void @test(i32 %in) {
+ landingpad {} personality void()* null filter i32 %in
+}
More information about the llvm-commits
mailing list