clang-tidy crash in ASTMatcher: Processing bugprone-implicit-widening-of-multiplication-result
clang-tidy llvm-v18.1.4 crashes with an attached stack. It happens during analysis of a header file renamed to .cpp. There is a chance that the header is not self-contained and there are undefined types in it. Multiple headers in the same directory showed the same issue. ua_MHV_Compiler_et6cbl_src_Gig_Gig.hh.log
@jackua22: Could you please provide reproducer?
I am attaching a test case. It is a minimized result of pre-processor output. It does have unresolved symbols. For example, uint is undefined. If you define it, the first line, the crash is gone. Removing any other trash is also makes crashes disappear. To reproduce: /grid/common/test/llvm-v18.1.4d1rh74_lnx86/bin/clang-tidy '--checks=-*,bugprone-implicit-widening-of-multiplication-result' ppp.cpp -- -std=c++17 -stdlib=libc++
Duplicate of #55293. Additionally I see lot of errors.
Problem is with clang::ASTContext::getTypeInfoImpl being called on invalid type. Probably expressions with errors could be excluded to avoid such issues.
Strange thing is that on ubuntu this does not reproduce with llvm 19, but if I compile this locally compiled llvm 19, then it hang.
Crashes on this implicit cast:
-EnumDecl 0x5bf7aeadd8c8 <line:52:3, col:35> col:3
`-EnumConstantDecl 0x5bf7aeadd9b0 <col:10, col:17> col:10 size 'GateDef::(unnamed enum at /fpwork/private1/1.cpp:52:3)'
`-ImplicitCastExpr 0x5bf7aeaddf40 <col:17> 'unsigned int' contains-errors <IntegralCast>
`-RecoveryExpr 0x5bf7aeadd990 <col:17> '<dependent type>' contains-errors lvalue