Fix two classes of bugs. First:
validate an invariant so that the asmparser rejects a bad construct
instead of the verifier. Before:
llvm-as: assembly parsed, but does not verify as correct!
Invalid struct return type!
i64 (%struct.Type*, %struct.Type*)* @foo
after:
llvm-as: t.ll:5:8: functions with 'sret' argument must return void
define i64 @foo(%struct.Type* noalias nocapture sret %agg.result, %struct.Type* nocapture byval %t) nounwind {
^
Second, check that void is only used where allowed (in function return types) not in
arbitrary places, fixing PR3747 - Crash in llvm-as with void field in struct. We
now reject that example with:
$ llvm-as t.ll
llvm-as: t.ll:1:12: struct element can not have void type
%x = type {void}
^
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66394 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AsmParser/LLParser.h b/lib/AsmParser/LLParser.h
index f013c63..3fc2fd2 100644
--- a/lib/AsmParser/LLParser.h
+++ b/lib/AsmParser/LLParser.h
@@ -139,10 +139,10 @@
bool ParseAlias(const std::string &Name, LocTy Loc, unsigned Visibility);
// Type Parsing.
- bool ParseType(PATypeHolder &Result);
- bool ParseType(PATypeHolder &Result, LocTy &Loc) {
+ bool ParseType(PATypeHolder &Result, bool AllowVoid = false);
+ bool ParseType(PATypeHolder &Result, LocTy &Loc, bool AllowVoid = false) {
Loc = Lex.getLoc();
- return ParseType(Result);
+ return ParseType(Result, AllowVoid);
}
bool ParseTypeRec(PATypeHolder &H);
bool ParseStructType(PATypeHolder &H, bool Packed);