Skip to content

crash in modernize-use-std-format tidy check #92896

@kadircet

Description

@kadircet
$ cat preproc.cc
struct Foo {
  Foo(...);
};
namespace absl {
void StrFormat(const Foo &) {
  StrFormat("");
}
}

$ $HOME/repos/llvm/build/bin/clang-tidy -checks="-*,modernize-use-std-format" preproc.cc -- -std=c++20
clang-tidy: /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp:211: clang::tidy::utils::FormatStringConverter::FormatStringConverter(clang::ASTContext *, const clang::CallExpr *, unsigned int, const clang::tidy::utils::FormatStringConverter::Configuration, const clang::LangOptions &): Assertion `FormatExpr' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/local/google/home/kadircet/repos/llvm/build/bin/clang-tidy -checks=-*,modernize-use-std-format preproc.cc -- -std=c++20
1.      <eof> parser at end of file
2.      ASTMatcher: Processing 'modernize-use-std-format' against:
        CallExpr : </usr/local/google/home/kadircet/repos/tmp/clangd_crashes/modernize-use-std-format/preproc.cc:6:3, col:15>
--- Bound Nodes Begin ---
    func_decl - { FunctionDecl absl::StrFormat : </usr/local/google/home/kadircet/repos/tmp/clangd_crashes/modernize-use-std-format/preproc.cc:5:1, line:7:1> }
    strformat - { CallExpr : </usr/local/google/home/kadircet/repos/tmp/clangd_crashes/modernize-use-std-format/preproc.cc:6:3, col:15> }
--- Bound Nodes End ---
 #0 0x00005571c6ceb317 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x00005571c6ce8e5e llvm::sys::RunSignalHandlers() /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00005571c6cebcba SignalHandler(int) /usr/local/google/home/kadircet/repos/llvm/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007f3d7705a510 (/lib/x86_64-linux-gnu/libc.so.6+0x3c510)
 #4 0x00007f3d770a816c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f3d7705a472 raise ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007f3d770444b2 abort ./stdlib/abort.c:81:7
 #7 0x00007f3d770443d5 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #8 0x00007f3d770533a2 (/lib/x86_64-linux-gnu/libc.so.6+0x353a2)
 #9 0x00005571c805dbb7 doit /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:109:5
#10 0x00005571c805dbb7 doit /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:137:12
#11 0x00005571c805dbb7 doit /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:127:12
#12 0x00005571c805dbb7 isPossible /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:255:12
#13 0x00005571c805dbb7 isPossible /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:509:12
#14 0x00005571c805dbb7 isa<clang::Expr, clang::Stmt *> /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:549:10
#15 0x00005571c805dbb7 cast<clang::Expr, clang::Stmt> /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Casting.h:578:3
#16 0x00005571c805dbb7 getCallee /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Expr.h:2971:42
#17 0x00005571c805dbb7 getCalleeDecl /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Expr.h:2986:12
#18 0x00005571c805dbb7 getDirectCallee /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Expr.h:2994:43
#19 0x00005571c805dbb7 castMismatchedIntegerTypes /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp:191:42
#20 0x00005571c805dbb7 clang::tidy::utils::FormatStringConverter::FormatStringConverter(clang::ASTContext*, clang::CallExpr const*, unsigned int, clang::tidy::utils::FormatStringConverter::Configuration, clang::LangOptions const&) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp:205:11
#21 0x00005571c7dca2b8 getTrailingStmts /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Expr.h:2856:51
#22 0x00005571c7dca2b8 getTrailingStmts /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Expr.h:2859:42
#23 0x00005571c7dca2b8 getCallee /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/Expr.h:2971:53
#24 0x00005571c7dca2b8 clang::tidy::modernize::UseStdFormatCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp:82:42
#25 0x00005571c74fddb2 _M_mbegin /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_tree.h:737:64
#26 0x00005571c74fddb2 _M_begin /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_tree.h:741:16
#27 0x00005571c74fddb2 ~_Rb_tree /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_tree.h:986:18
#28 0x00005571c74fddb2 ~map /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_map.h:314:22
#29 0x00005571c74fddb2 ~BoundNodesMap /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:211:7
#30 0x00005571c74fddb2 ~BoundNodes /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/ASTMatchers/ASTMatchers.h:109:7
#31 0x00005571c74fddb2 ~MatchResult /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/ASTMatchers/ASTMatchFinder.h:75:10
#32 0x00005571c74fddb2 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch(clang::ast_matchers::BoundNodes const&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1271:7
#33 0x00005571c753365c _M_mbegin /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_tree.h:737:64
#34 0x00005571c753365c _M_begin /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_tree.h:741:16
#35 0x00005571c753365c ~_Rb_tree /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_tree.h:986:18
#36 0x00005571c753365c ~map /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_map.h:314:22
#37 0x00005571c753365c ~BoundNodesMap /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/ASTMatchers/ASTMatchersInternal.h:211:7
#38 0x00005571c753365c ~BoundNodes /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/ASTMatchers/ASTMatchers.h:109:7
#39 0x00005571c753365c clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchersInternal.cpp:105:5
#40 0x00005571c74fd66a assertHoldsState /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:841:7
#41 0x00005571c74fd66a reset /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:834:7
#42 0x00005571c74fd66a ~CurMatchRAII /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:869:40
#43 0x00005571c74fd66a clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter(clang::DynTypedNode const&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1068:5
#44 0x00005571c75172a5 TraverseStmt /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1483:48
#45 0x00005571c75172a5 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseExprWithCleanups(clang::ExprWithCleanups*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:2787:1
#46 0x00005571c7511263 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseStmt(clang::Stmt*, llvm::SmallVectorImpl<llvm::PointerIntPair<clang::Stmt*, 1u, bool, llvm::PointerLikeTypeTraits<clang::Stmt*>, llvm::PointerIntPairInfo<clang::Stmt*, 1u, llvm::PointerLikeTypeTraits<clang::Stmt*>>>>*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:683:7
#47 0x00005571c7532325 ~ASTNodeNotSpelledInSourceScope /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:971:47
#48 0x00005571c7532325 TraverseStmt /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1484:1
#49 0x00005571c7532325 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionHelper(clang::FunctionDecl*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:2250:5
#50 0x00005571c7504002 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseFunctionDecl(clang::FunctionDecl*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:2261:1
#51 0x00005571c7500e91 TraverseDecl /usr/local/google/home/kadircet/repos/llvm/build/tools/clang/include/clang/AST/DeclNodes.inc:238:1
#52 0x00005571c7500e91 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1471:48
#53 0x00005571c75033fb TraverseDeclContextHelper /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:1529:7
#54 0x00005571c75033fb clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseNamespaceDecl(clang::NamespaceDecl*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:1665:1
#55 0x00005571c7500da1 TraverseDecl /usr/local/google/home/kadircet/repos/llvm/build/tools/clang/include/clang/AST/DeclNodes.inc:170:1
#56 0x00005571c7500da1 clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1471:48
#57 0x00005571c752bceb clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseDeclContextHelper(clang::DeclContext*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:1529:7
#58 0x00005571c7501563 clang::RecursiveASTVisitor<clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/AST/RecursiveASTVisitor.h:1629:1
#59 0x00005571c7500bbf TraverseDecl /usr/local/google/home/kadircet/repos/llvm/build/tools/clang/include/clang/AST/DeclNodes.inc:24:1
#60 0x00005571c7500bbf clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl(clang::Decl*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1471:48
#61 0x00005571c74cbe50 onEndOfTranslationUnit /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:446:30
#62 0x00005571c74cbe50 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/ASTMatchers/ASTMatchFinder.cpp:1700:11
#63 0x00005571c88fa1fc operator++ /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:1111:2
#64 0x00005571c88fa1fc clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/MultiplexConsumer.cpp:326:23
#65 0x00005571c8b339a7 __normal_iterator /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:1077:20
#66 0x00005571c8b339a7 begin /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:871:16
#67 0x00005571c8b339a7 finalize<std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > > > /usr/local/google/home/kadircet/repos/llvm/clang/include/clang/Sema/TemplateInstCallback.h:54:16
#68 0x00005571c8b339a7 clang::ParseAST(clang::Sema&, bool, bool) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Parse/ParseAST.cpp:183:3
#69 0x00005571c885f030 clang::FrontendAction::Execute() /usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/FrontendAction.cpp:1082:10
#70 0x00005571c87c2cdf getPtr /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Error.h:276:42
#71 0x00005571c87c2cdf operator bool /usr/local/google/home/kadircet/repos/llvm/llvm/include/llvm/Support/Error.h:239:16
#72 0x00005571c87c2cdf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Frontend/CompilerInstance.cpp:1061:23
#73 0x00005571c6d6e1bd clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Tooling/Tooling.cpp:465:33
#74 0x00005571c6dc9adc clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/ClangTidy.cpp:581:37
#75 0x00005571c6d6df2e clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Tooling/Tooling.cpp:440:18
#76 0x00005571c6d6c886 clang::tooling::ToolInvocation::run() /usr/local/google/home/kadircet/repos/llvm/clang/lib/Tooling/Tooling.cpp:425:10
#77 0x00005571c6d707cd clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /usr/local/google/home/kadircet/repos/llvm/clang/lib/Tooling/Tooling.cpp:623:11
#78 0x00005571c6dc3bdc clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/ClangTidy.cpp:0:8
#79 0x00005571c6cb7778 clang::tidy::clangTidyMain(int, char const**) /usr/local/google/home/kadircet/repos/llvm/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:674:7
#80 0x00007f3d770456ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#81 0x00007f3d77045785 call_init ./csu/../csu/libc-start.c:128:20
#82 0x00007f3d77045785 __libc_start_main ./csu/../csu/libc-start.c:347:5
#83 0x00005571c6cb2ca1 _start (/usr/local/google/home/kadircet/repos/llvm/build/bin/clang-tidy+0x3a31ca1)
Aborted

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidycrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions