[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 11 05:49:33 PDT 2025


================
@@ -570,23 +572,35 @@ class SMTConv {
   // TODO: Refactor to put elsewhere
   static inline QualType getAPSIntType(ASTContext &Ctx,
                                        const llvm::APSInt &Int) {
-    return Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned());
+    QualType Ty;
+    if (!(Ty = Ctx.getIntTypeForBitwidth(Int.getBitWidth(), Int.isSigned()))
+             .isNull())
----------------
vabridgers wrote:

@steakhal , because I get this error if I follow the precise suggestion. So I modified a little bit to meet what I thought you wanted.

```
In file included from <base>/clang/lib/StaticAnalyzer/Core/Z3CrosscheckVisitor.cpp:18:
<base>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h: In static member function ‘static clang::QualType clang::ento::SMTConv::getAPSIntType(clang::ASTContext&, const llvm::APSInt&)’:
<base>/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h:585:5: error: ‘Ty’ was not declared in this scope
  585 |     Ty = Ctx.getIntTypeForBitwidth(Pow2DestWidth, Int.isSigned());
      |     ^~
ninja: build stopped: subcommand failed.
```


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


More information about the cfe-commits mailing list