Skip to content

clang-query crashes when srcloc output mode is enabled #82591

@Endilll

Description

@Endilll

Given the following code:

struct Sema {};

and the following clang-query commands:

enable output srcloc

# All public members of Sema
m decl(allOf(decl(unless(isPrivate())), decl(hasParent(namedDecl(hasName("Sema"))))))

clang-query crashes with the following backtrace:

 #0 0x00000000004c64d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/clang-query+0x4c64d8)
 #1 0x00000000004c426c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f3ab3642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000000e52f30 clang::tooling::GetLocationsImpl(llvm::IntrusiveRefCntPtr<clang::tooling::LocationCall> const&, clang::Decl const*, std::set<std::pair<clang::SourceLocation, llvm::IntrusiveRefCntPtr<clang::tooling::LocationCall>>, clang::tooling::internal::RangeLessThan, std::allocator<std::pair<clang::SourceLocation, llvm::IntrusiveRefCntPtr<clang::tooling::LocationCall>>>>&, std::set<std::pair<clang::SourceRange, llvm::IntrusiveRefCntPtr<clang::tooling::LocationCall>>, clang::tooling::internal::RangeLessThan, std::allocator<std::pair<clang::SourceRange, llvm::IntrusiveRefCntPtr<clang::tooling::LocationCall>>>>&, std::vector<clang::TypeLoc, std::allocator<clang::TypeLoc>>&) (/clang-query+0xe52f30)
 #4 0x0000000000e597e6 clang::tooling::NodeIntrospection::GetLocations(clang::DynTypedNode const&) (/clang-query+0xe597e6)
 #5 0x0000000000ce3df4 clang::query::(anonymous namespace)::dumpLocations(llvm::raw_ostream&, clang::DynTypedNode, clang::ASTContext&, clang::DiagnosticsEngine const&, clang::SourceManager const&) Query.cpp:0:0
 #6 0x0000000000ce6418 clang::query::MatchQuery::run(llvm::raw_ostream&, clang::query::QuerySession&) const (/clang-query+0xce6418)
 #7 0x000000000044535e runCommandsInFile(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, clang::query::QuerySession&) (/clang-query+0x44535e)
 #8 0x000000000040ff04 main (/clang-query+0x40ff04)
 #9 0x00007f3ab3629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#10 0x00007f3ab3629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#11 0x0000000000439d5e _start (/clang-query+0x439d5e)
Program terminated with signal: SIGSEGV

https://gcc.godbolt.org/z/P69MjKeGs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions