[clang] [clang][analyzer] Correct SMT Layer for _BitInt cases refutations (PR #143310)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 8 07:10:41 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions c,h,cpp -- clang/test/Analysis/bitint-z3.c clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h clang/lib/AST/ASTContext.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
index 2a41202d4..f2ae6f0e9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
@@ -574,7 +574,7 @@ public:
}
static inline bool IsPower2(unsigned bits) {
- return bits > 0 && (bits & (bits-1)) == 0;
+ return bits > 0 && (bits & (bits - 1)) == 0;
}
// Get the QualTy for the input APSInt, and fix it if it has a bitwidth of 1.
@@ -590,9 +590,9 @@ public:
if (APSIntBitwidth == 1 && Ty.isNull()) {
NewInt = Int.extend(Ctx.getTypeSize(Ctx.BoolTy));
Ty = getAPSIntType(Ctx, NewInt);
- } else if ( !IsPower2(APSIntBitwidth) && !getAPSIntType(Ctx, Int).isNull()) {
+ } else if (!IsPower2(APSIntBitwidth) && !getAPSIntType(Ctx, Int).isNull()) {
Ty = getAPSIntType(Ctx, Int);
- NewInt = Int.extend( Ctx.getTypeSize(Ty));
+ NewInt = Int.extend(Ctx.getTypeSize(Ty));
} else
NewInt = Int;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 094264813..4f0849647 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -13211,10 +13211,12 @@ QualType ASTContext::getIntTypeForBitwidth(unsigned DestWidth,
unsigned Signed) const {
// round up to next power of 2 for _BitInt cases
unsigned pow2DestWidth = llvm::bit_ceil(DestWidth);
- //if (pow2DestWidth == 4) pow2DestWidth = 8;
- if (pow2DestWidth < 8) pow2DestWidth = 8;
+ // if (pow2DestWidth == 4) pow2DestWidth = 8;
+ if (pow2DestWidth < 8)
+ pow2DestWidth = 8;
- TargetInfo::IntType Ty = getTargetInfo().getIntTypeByWidth(pow2DestWidth, Signed);
+ TargetInfo::IntType Ty =
+ getTargetInfo().getIntTypeByWidth(pow2DestWidth, Signed);
CanQualType QualTy = getFromTargetType(Ty);
if (!QualTy && pow2DestWidth == 128)
return Signed ? Int128Ty : UnsignedInt128Ty;
``````````
</details>
https://github.com/llvm/llvm-project/pull/143310
More information about the cfe-commits
mailing list