<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/117005>117005</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            A/F: `isInstance() && "No 'this' for static methods!"' in clang-tidy after commit 2c6424e691
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang-tidy
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          dyung
      </td>
    </tr>
</table>

<pre>
    Recently one of our internal tests started to see an assertion failure in clang-tidy which I bisected back to 2c6424e691e32f79bc303203deb1c91634d62286.

Consider the following code:
```c++
struct A {
  static void b();
};
```
When this code is run through clang-tidy that includes 2c6424e691e32f79bc303203deb1c91634d62286, it hits an assertion failure:
```
$ ~/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy test.cpp
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "test.cpp"
No compilation database found in /home/dyung/sandbox/repro10 or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
clang-tidy: /home/dyung/src/upstream/llvm_clean_git/clang/lib/AST/DeclCXX.cpp:2661: clang::QualType clang::CXXMethodDecl::getThisType() const: Assertion `isInstance() && "No 'this' for static methods!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy test.cpp
1.      <eof> parser at end of file
 #0 0x000055e2f401f58f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x4f6158f)
 #1 0x000055e2f401cae4 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f742edd5420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f742e8a800b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #4 0x00007f742e887859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #5 0x00007f742e887729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #6 0x00007f742e887729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #7 0x00007f742e898fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x000055e2f2c27483 clang::CXXMethodDecl::getThisType() const (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x3b69483)
 #9 0x000055e2f0e6334d clang::RecursiveASTVisitor<(anonymous namespace)::UncountedLambdaCapturesChecker::checkASTDecl(clang::TranslationUnitDecl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) const::LocalVisitor>::TraverseDecl(clang::Decl*) (.part.0) UncountedLambdaCapture
sChecker.cpp:0:0
#10 0x000055e2f0e64223 clang::RecursiveASTVisitor<(anonymous namespace)::UncountedLambdaCapturesChecker::checkASTDecl(clang::TranslationUnitDecl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) const::LocalVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) Un
countedLambdaCapturesChecker.cpp:0:0
#11 0x000055e2f0e62b59 clang::RecursiveASTVisitor<(anonymous namespace)::UncountedLambdaCapturesChecker::checkASTDecl(clang::TranslationUnitDecl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) const::LocalVisitor>::TraverseDecl(clang::Decl*) (.part.0) UncountedLambdaCapture
sChecker.cpp:0:0
#12 0x000055e2f0e64223 clang::RecursiveASTVisitor<(anonymous namespace)::UncountedLambdaCapturesChecker::checkASTDecl(clang::TranslationUnitDecl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) const::LocalVisitor>::TraverseDeclContextHelper(clang::DeclContext*) (.part.0) Un
countedLambdaCapturesChecker.cpp:0:0
#13 0x000055e2f0e87119 clang::RecursiveASTVisitor<(anonymous namespace)::UncountedLambdaCapturesChecker::checkASTDecl(clang::TranslationUnitDecl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) const::LocalVisitor>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl*) Un
countedLambdaCapturesChecker.cpp:0:0
#14 0x000055e2f0e8a11d void clang::ento::check::ASTDecl<clang::TranslationUnitDecl>::_checkDecl<(anonymous namespace)::UncountedLambdaCapturesChecker>(void*, clang::Decl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) UncountedLambdaCapturesChecker.cpp:0:0
#15 0x000055e2f0f58aa1 clang::ento::CheckerManager::runCheckersOnASTDecl(clang::Decl const*, clang::ento::AnalysisManager&, clang::ento::BugReporter&) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x1e9aaa1)
#16 0x000055e2f09623de (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) AnalysisConsumer.cpp:0:0
#17 0x000055e2f12a7b20 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x21e9b20)
#18 0x000055e2f156c76c clang::ParseAST(clang::Sema&, bool, bool) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x24ae76c)
#19 0x000055e2f12669d9 clang::FrontendAction::Execute() (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x21a89d9)
#20 0x000055e2f11db81e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x211d81e)
#21 0x000055e2f0928b30 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bi
n/clang-tidy+0x186ab30)
#22 0x000055e2f08c6869 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, llv
m::StringRef)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) ClangTidy.cpp:0:0
#23 0x000055e2f091faa7 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0
x1861aa7)
#24 0x000055e2f0923358 clang::tooling::ToolInvocation::run() (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x1865358)
#25 0x000055e2f0926a41 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x1868a41)
#26 0x000055e2f08d8356 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, llv
m::StringRef) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0x181a356)
#27 0x000055e2efe6d86a clang::tidy::clangTidyMain(int, char const**) (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0xdaf86a)
#28 0x00007f742e889083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#29 0x000055e2efe6379e _start (/home/dyung/src/upstream/2c6424e691e32f79bc303203deb1c91634d62286-linux/bin/clang-tidy+0xda579e)
Aborted (core dumped)
```

A clang-tidy built from the parent commit does not hit an assertion failure:
```
$ ~/src/upstream/06e08696248ac01754c87c22cc8a4b797ef46430-linux/bin/clang-tidy test.cpp
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "test.cpp"
No compilation database found in /home/dyung/sandbox/repro10 or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWluT2ygW_jX0C9Uuge4PfnDc7Zps5bbpnt28uRAc2czI4ALUsV_2t2-BZFty3JlOZsazl6SctoXgnPN95wJCMGvlSgFMUfoKpXc3rHVrbaZi36rVTaXFfvoROCjX7LFWgHWNdWuwVA6MYg12YJ3F1jHjQGCnsQXATGFmLRgntcI1k01rAEuFecPU6tZJscef15Kv8WtcSQvcD60Y_9WPpzxLaAJZSSCmdV5WPI5iGsUCKsJLksWJyCgtsgmK7lA06_7OtbJSgMFuDbjWTaM_S7XCXAtAcd8HZVH34Yi-8p_Qap1pucMzjPK-BXs0TnL8pKXAFaIFoiWK-7sovzv9PkjsLv-5BoXdWtqgF0uLTesbjG5X6yF2t2YOS8WbVoB9MWBE51g6vJbOXiT4S6D9JU3wvxBdWMMRXbRb6wywDaKLlyq-baRqd4guKqkQXQyBgHUTvt12iu6N0cY7tgHszN47wGncaCYww1xvtrJhwWDBHKuYPVk8120jsNIOs9bpWwEOuLs4BNfa4NprQJQe1VPayXmnnxvUKuEDENHFWm8A0UWIb88KU6LSHp2BrdEkwtpgpvZ4ywwoh4U0wJ02-05DLXcgbgdKbgdg8JABvQXlKQgjhpDxO41ty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