[clang-tools-extra] [clang] [C23] Fix crash with _BitInt running clang-tidy (PR #65889)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 06:25:44 PDT 2023


================
@@ -1333,7 +1333,15 @@ void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
 void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
   VisitExpr(S);
   S->getValue().Profile(ID);
-  ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
+
+  int FoldingSetID = 0;
+
+  if (S->getType()->isBitIntType())
+    FoldingSetID = S->getValue().getSExtValue();
+  else
+    FoldingSetID = S->getType()->castAs<BuiltinType>()->getKind();
+
+  ID.AddInteger(FoldingSetID);
----------------
DonatNagyE wrote:

Very minor nitpick: [`BuiltinType`](https://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html) doesn't have a `Profile` method; the identity of builtin types is determined by the `getKind()` method (as it's used in this code fragment).

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


More information about the cfe-commits mailing list