llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang-tidy crash in ASTMatcher: Processing bugprone-implicit-widening-of-multiplication-result

Open jackua22 opened this issue 2 years ago • 3 comments

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 avatar Apr 20 '24 22:04 jackua22

@jackua22: Could you please provide reproducer?

EugeneZelenko avatar Apr 21 '24 01:04 EugeneZelenko

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++

ppp.cpp.zip

jackua22 avatar Apr 22 '24 16:04 jackua22

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

PiotrZSL avatar May 13 '24 20:05 PiotrZSL