https://bugs.kde.org/show_bug.cgi?id=358740
Bug ID: 358740 Summary: Utils::isInitializedExternally: getSingleDecl fails to account for multiple declarations Product: clazy Version: unspecified Platform: Other OS: Linux Status: UNCONFIRMED Severity: crash Priority: NOR Component: general Assignee: unassigned-b...@kde.org Reporter: j...@kde.org CC: smart...@kde.org The following minimal example causes an assertion failure within clang in a code path triggered by the clazy plugin: #include <QtCore/QList> void x() { QList<int> list; int a, b; } Here's the backtrace: (gdb) bt #0 0x00007fffec04989b in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55 #1 0x00007fffec04ae51 in __GI_abort () at abort.c:89 #2 0x00007fffec041fb8 in __assert_fail_base (fmt=0x7fffec18ace0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7fffe4b00fe0 "isSingleDecl() && \"Isn't a declgroup\"", file=file@entry=0x7fffe4b01006 "/usr/include/clang/AST/DeclGroup.h", line=line@entry=88, function=function@entry=0x7fffe4b01029 "clang::Decl *clang::DeclGroupRef::getSingleDecl()") at assert.c:92 #3 0x00007fffec042076 in __GI___assert_fail (assertion=0x7fffe4b00fe0 "isSingleDecl() && \"Isn't a declgroup\"", file=0x7fffe4b01006 "/usr/include/clang/AST/DeclGroup.h", line=88, function=0x7fffe4b01029 "clang::Decl *clang::DeclGroupRef::getSingleDecl()") at assert.c:101 #4 0x00007fffe4a02cea in clang::DeclGroupRef::getSingleDecl() () from /home/jkt/.local/lib64/ClangLazy.so #5 0x00007fffe4a028c9 in clang::DeclStmt::getSingleDecl() () from /home/jkt/.local/lib64/ClangLazy.so #6 0x00007fffe4acb339 in Utils::isInitializedExternally(clang::VarDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #7 0x00007fffe4a0877e in InefficientQListBase::shouldIgnoreVariable(clang::VarDecl*) const () from /home/jkt/.local/lib64/ClangLazy.so #8 0x00007fffe4a08828 in InefficientQListBase::VisitDecl(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #9 0x00007fffe49dbe26 in CheckBase::VisitDeclaration(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #10 0x00007fffe4a45323 in (anonymous namespace)::LazyASTConsumer::VisitDecl(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #11 0x00007fffe4a45285 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::WalkUpFromDecl(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #12 0x00007fffe4a7ba45 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::WalkUpFromNamedDecl(clang::NamedDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #13 0x00007fffe4a7dfa5 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::WalkUpFromValueDecl(clang::ValueDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #14 0x00007fffe4a7def5 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::WalkUpFromDeclaratorDecl(clang::DeclaratorDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #15 0x00007fffe4a7eba5 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::WalkUpFromVarDecl(clang::VarDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #16 0x00007fffe4a4223d in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseVarDecl(clang::VarDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #17 0x00007fffe4a3ecf5 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseDecl(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #18 0x00007fffe4a56654 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseDeclStmt(clang::DeclStmt*) () from /home/jkt/.local/lib64/ClangLazy.so #19 0x00007fffe4a46c41 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseStmt(clang::Stmt*) () from /home/jkt/.local/lib64/ClangLazy.so #20 0x00007fffe4a5641f in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseCompoundStmt(clang::CompoundStmt*) () from /home/jkt/.local/lib64/ClangLazy.so #21 0x00007fffe4a46be7 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseStmt(clang::Stmt*) () from /home/jkt/.local/lib64/ClangLazy.so #22 0x00007fffe4a7e5f0 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseFunctionHelper(clang::FunctionDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #23 0x00007fffe4a41e20 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseFunctionDecl(clang::FunctionDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #24 0x00007fffe4a3eb66 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseDecl(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #25 0x00007fffe4a45215 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseDeclContextHelper(clang::DeclContext*) () from /home/jkt/.local/lib64/ClangLazy.so #26 0x00007fffe4a42e6a in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) () from /home/jkt/.local/lib64/ClangLazy.so #27 0x00007fffe4a3ef68 in clang::RecursiveASTVisitor<(anonymous namespace)::LazyASTConsumer>::TraverseDecl(clang::Decl*) () from /home/jkt/.local/lib64/ClangLazy.so #28 0x00007fffe4a3e05d in (anonymous namespace)::LazyASTConsumer::HandleTranslationUnit(clang::ASTContext&) () from /home/jkt/.local/lib64/ClangLazy.so #29 0x00007fffecbe61e0 in clang::MultiplexConsumer::HandleTranslationUnit (this=<optimized out>, Ctx=...) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/Frontend/MultiplexConsumer.cpp:296 #30 0x00007fffe70161ad in clang::ParseAST (S=..., PrintStats=<optimized out>, SkipFunctionBodies=<optimized out>) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/Parse/ParseAST.cpp:151 #31 0x00007fffecbbc71a in clang::ASTFrontendAction::ExecuteAction (this=this@entry=0x5555557918e0) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/Frontend/FrontendAction.cpp:537 #32 0x00007fffed35bded in clang::CodeGenAction::ExecuteAction (this=0x5555557918e0) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/CodeGen/CodeGenAction.cpp:744 #33 0x00007fffecbbdb6e in clang::FrontendAction::Execute (this=this@entry=0x5555557918e0) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/Frontend/FrontendAction.cpp:439 #34 0x00007fffecb8b109 in clang::CompilerInstance::ExecuteAction (this=this@entry=0x555555783610, Act=...) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/Frontend/CompilerInstance.cpp:820 #35 0x00007fffec907a91 in clang::ExecuteCompilerInvocation (Clang=Clang@entry=0x555555783610) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:222 #36 0x000055555556638f in cc1_main (Argv=..., Argv0=<optimized out>, MainAddr=<optimized out>) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/tools/driver/cc1_main.cpp:116 #37 0x0000555555561755 in ExecuteCC1Tool (Tool=..., argv=...) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/tools/driver/driver.cpp:358 #38 main (argc_=<optimized out>, argv_=<optimized out>) at /var/tmp/portage/sys-devel/llvm-3.7.0-r2/work/llvm-3.7.0.src/tools/clang/tools/driver/driver.cpp:404 Please note that there's also another call to the getSingleDecl somewhere else in clazy's codebase. Reproducible: Always -- You are receiving this mail because: You are watching all bug changes.