[llvm] Improve diagnostic for malformed constant vectors (PR #216253)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 12:52:29 PDT 2026


================
@@ -3178,6 +3178,9 @@ bool LLParser::parseType(Type *&Result, const Twine &Msg, bool AllowVoid) {
   SMLoc TypeLoc = Lex.getLoc();
   switch (Lex.getKind()) {
   default:
+    if (InConstantVector && Lex.getKind() == lltok::APSInt)
----------------
zhangweize9-cyber wrote:

We need to add checks for floating-point numbers. Because I noticed that the test cases included floating-point numbers. (On `llvm/test/Assembler/constant-vector-typed-elements.ll`, line 11)

```
@g2 = constant <2 x float> <float 1.0, float 2.0>
```

You need to add this condition: `Lex.getKind() == lltok::APFloat`

https://github.com/llvm/llvm-project/pull/216253


More information about the llvm-commits mailing list