[llvm] Improve diagnostic for malformed constant vectors (PR #216253)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 23 00:31:23 PDT 2026
================
@@ -4275,6 +4275,12 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
// ValID ::= '<' ConstVector '>' --> Vector.
// ValID ::= '<' '{' ConstVector '}' '>' --> Packed Struct.
Lex.Lex();
+
+ // guard constant vector elements must begin with a type.
+ if (Lex.getKind() == lltok::APSInt || Lex.getKind() == lltok::Type)
+ return error(Lex.getLoc(),
+ "constant vector elements must begin with a type");
----------------
zhangweize9-cyber wrote:
Because there's already a case branch within the function body, writing a condition here won't trigger the logic you wrote.
https://github.com/llvm/llvm-project/pull/216253
More information about the llvm-commits
mailing list