[clang-tools-extra] [clang] [C23] Fix crash with _BitInt running clang-tidy (PR #65889)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 13:30:45 PDT 2023
================
@@ -1333,7 +1333,14 @@ 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());
+
+ QualType T = S->getType();
+ if (auto BitIntT = T->getAs<BitIntType>()) {
+ BitIntT->Profile(ID, BitIntT->isSigned(), BitIntT->getNumBits());
----------------
erichkeane wrote:
Adding `const` there seems fine, it is probably just something I forgot when I write it in the first place. There definitely needs to be a differentiator here between a builtin int and a `_BitInt`, so I think the boolean makes sense to me (as does the non-static profile call). Though, I wonder if we'd be better doing `getTypeClass` instead? It should be the same size (bool is just cast to unsigned), but be more obvious in the long run/more expandable in the future.
WDYT?
https://github.com/llvm/llvm-project/pull/65889
More information about the cfe-commits
mailing list