mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-21 13:33:26 +00:00
Teach the LLParser to fail gracefully when it encounters an invalid label name.
Previous it would either assert in +Asserts, or crash in -Asserts. Found by fuzzing LLParser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230935 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dafab60b57
commit
0923ca275b
@ -2270,13 +2270,13 @@ bool LLParser::PerFunctionState::SetInstName(int NameID,
|
|||||||
/// forward reference record if needed.
|
/// forward reference record if needed.
|
||||||
BasicBlock *LLParser::PerFunctionState::GetBB(const std::string &Name,
|
BasicBlock *LLParser::PerFunctionState::GetBB(const std::string &Name,
|
||||||
LocTy Loc) {
|
LocTy Loc) {
|
||||||
return cast_or_null<BasicBlock>(GetVal(Name,
|
return dyn_cast_or_null<BasicBlock>(GetVal(Name,
|
||||||
Type::getLabelTy(F.getContext()), Loc));
|
Type::getLabelTy(F.getContext()), Loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicBlock *LLParser::PerFunctionState::GetBB(unsigned ID, LocTy Loc) {
|
BasicBlock *LLParser::PerFunctionState::GetBB(unsigned ID, LocTy Loc) {
|
||||||
return cast_or_null<BasicBlock>(GetVal(ID,
|
return dyn_cast_or_null<BasicBlock>(GetVal(ID,
|
||||||
Type::getLabelTy(F.getContext()), Loc));
|
Type::getLabelTy(F.getContext()), Loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DefineBB - Define the specified basic block, which is either named or
|
/// DefineBB - Define the specified basic block, which is either named or
|
||||||
@ -4299,7 +4299,9 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
|
BasicBlock *BB = PFS.DefineBB(Name, NameLoc);
|
||||||
if (!BB) return true;
|
if (!BB)
|
||||||
|
return Error(NameLoc,
|
||||||
|
"unable to create block named '" + Name + "'");
|
||||||
|
|
||||||
std::string NameStr;
|
std::string NameStr;
|
||||||
|
|
||||||
|
11
test/Assembler/invalid-label.ll
Normal file
11
test/Assembler/invalid-label.ll
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
; RUN: not llvm-as < %s >/dev/null 2> %t
|
||||||
|
; RUN: FileCheck %s < %t
|
||||||
|
; Test the case where an invalid label name is used
|
||||||
|
|
||||||
|
; CHECK: unable to create block named 'bb'
|
||||||
|
|
||||||
|
define void @test(label %bb) {
|
||||||
|
bb:
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user