Commit 1c05651
authored
[clang] [C23] Fix crash with _BitInt running clang-tidy (llvm#65889)
This crash was exposed recently in our randomized testing. _BitInts were
not being handled properly during IntegerLiteral visitation. This patch
addresses the problem for now.
The BitIntType has no getKind() method, so the FoldingSetID is taken
from the APInt value representing the _BitInt(), similar to other
methods in StmtProfile.cpp.
Crash seen (summary form):
clang-tidy: <src-root>/llvm/include/llvm/Support/Casting.h:566:
decltype(auto) llvm::cast(const From&) [with To = clang::BuiltinType;
From = clang::QualType]: Assertion `isa<To>(Val) && "cast<Ty>() argument
of incompatible type!"' failed
```
#9 <address> decltype(auto) llvm::cast<clang::BuiltinType,
clang::QualType>(clang::QualType const&)
<src-root>/llvm/include/llvm/Support/Casting.h:566:3
#10 <address> clang::BuiltinType const* clang::Type::castAs<clang::BuiltinType>() const
<bin-root>/tools/clang/include/clang/AST/TypeNodes.inc:86:1
#11 <address> (anonymous namespace)::StmtProfiler::VisitIntegerLiteral(
clang::IntegerLiteral const*)
<src-root>/clang/lib/AST/StmtProfile.cpp:1362:64
#12 <address> clang::StmtVisitorBase<llvm::make_const_ptr,
(anonymous namespace)::StmtProfiler, void>::Visit(clang::Stmt const*)
<src-root>/clang/include/clang/AST/StmtNodes.inc:1225:1
```
Reviewed By: donat.nagy1 parent 3d422c4 commit 1c05651
File tree
3 files changed
+17
-2
lines changed- clang-tools-extra/test/clang-tidy/checkers/bugprone
- clang
- include/clang/AST
- lib/AST
3 files changed
+17
-2
lines changedLines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6642 | 6642 | | |
6643 | 6643 | | |
6644 | 6644 | | |
6645 | | - | |
| 6645 | + | |
6646 | 6646 | | |
6647 | 6647 | | |
6648 | 6648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1333 | 1333 | | |
1334 | 1334 | | |
1335 | 1335 | | |
1336 | | - | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
1337 | 1343 | | |
1338 | 1344 | | |
1339 | 1345 | | |
| |||
0 commit comments