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

    <tr>
        <th>Summary</th>
        <td>
            clang-tidy: modernize-macro-to-enum crashes when checking for __restrict macro
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    The following valid code snippet triggers an assertion with -checks='-*,modernize-macro-to-enum' enabled:

```
#ifdef __restrict
#endif
```

A check for a __restrict macro can e.g. be found in /usr/lib/regex.h .

```
clang-tidy: clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp:288: void clang::tidy::modernize::{anonymous}::MacroToEnumCallbacks::checkName(const clang::Token&): Assertion `false && "Expected either an identifier or raw identifier token"' failed.
```

This appeared with the new modernize-macro-to-enum check introduced last week by @LegalizeAdulthood .
Could you please have a look? Thanks!

```
Stack dump:
0.      Program arguments: /LLVM-trunk/bin/clang-tidy -checks=-*,modernize-macro-to-enum xCT.cc --
1.      xCT.cc:5:2: current parser token 'ifdef'
 #0 0x000000000401b360 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x0000000004018bbc SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f060700a680 __restore_rt sigaction.c:0:0
 #3 0x00007f0605d5a207 raise (/lib64/libc.so.6+0x36207)
 #4 0x00007f0605d5b8f8 abort (/lib64/libc.so.6+0x378f8)
 #5 0x00007f0605d53026 __assert_fail_base (/lib64/libc.so.6+0x2f026)
 #6 0x00007f0605d530d2 (/lib64/libc.so.6+0x2f0d2)
 #7 0x0000000000da3874 clang::tidy::modernize::(anonymous namespace)::MacroToEnumCallbacks::checkName(clang::Token const&) MacroToEnumCheck.cpp:0:0
 #8 0x0000000003b12dfc clang::Preprocessor::HandleIfdefDirective(clang::Token&, clang::Token const&, bool, bool) (/LLVM-trunk/bin/clang-tidy+0x3b12dfc)
 #9 0x0000000003b1472a clang::Preprocessor::HandleDirective(clang::Token&) (/LLVM-trunk/bin/clang-tidy+0x3b1472a)
#10 0x0000000003ad1fbe clang::Lexer::LexTokenInternal(clang::Token&, bool) (/LLVM-trunk/bin/clang-tidy+0x3ad1fbe)
#11 0x0000000003ad2bd1 clang::Lexer::Lex(clang::Token&) (/LLVM-trunk/bin/clang-tidy+0x3ad2bd1)
#12 0x0000000003b4e1ff clang::Preprocessor::Lex(clang::Token&) (/LLVM-trunk/bin/clang-tidy+0x3b4e1ff)
#13 0x0000000002202c52 clang::Parser::ConsumeToken() (/LLVM-trunk/bin/clang-tidy+0x2202c52)
#14 0x00000000022010f7 clang::ParseAST(clang::Sema&, bool, bool) (/LLVM-trunk/bin/clang-tidy+0x22010f7)
#15 0x0000000001faed39 clang::FrontendAction::Execute() (/LLVM-trunk/bin/clang-tidy+0x1faed39)
#16 0x0000000001f30106 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/LLVM-trunk/bin/clang-tidy+0x1f30106)
#17 0x000000000188263d clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/LLVM-trunk/bin/clang-tidy+0x188263d)
#18 0x0000000001823c4a 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*) ClangTidy.cpp:0:0
#19 0x000000000187bd03 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/LLVM-trunk/bin/clang-tidy+0x187bd03)
#20 0x000000000187e799 clang::tooling::ToolInvocation::run() (/LLVM-trunk/bin/clang-tidy+0x187e799)
#21 0x00000000018809d9 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/LLVM-trunk/bin/clang-tidy+0x18809d9)
#22 0x000000000182ea85 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) (/LLVM-trunk/bin/clang-tidy+0x182ea85)
#23 0x000000000090de0d clang::tidy::clangTidyMain(int, char const**) (/LLVM-trunk/bin/clang-tidy+0x90de0d)
#24 0x00007f0605d463d5 __libc_start_main (/lib64/libc.so.6+0x223d5)
#25 0x00000000009059e9 _start (/LLVM-trunk/bin/clang-tidy+0x9059e9)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWE1v4zYQ_TXKhbAhUbY-Dj54nQ26wG4bNMZeDYqiZDayaJBU4vTXd0jKjqjEToz2UBQNHMsSxTdvZh6HH4UoXxbrLUOVaBrxzNsaPZGGl4iKkiHV8v2eaaQlr2smFSItIkoxqblo0TPXWzShW0YfVRDfBjidBHgZ4NUO-sqW_8kmO0KlmGgxYW23gxcQa0nRsDKIl0F4G4TH7yTsP-4Wx7wqWYU2G8kUGKf61MDaklfv97LfS2QJgT8SkQEAslQQBQ_YtJ6iwrjctSXiLQrwXackfDe8gG_JanaYbtH0AkXakLaeaF6-gCuovxOiURN20JIAyuANfHeKCPz-YYisxVeIyMpQndL9HkBwlhmoJ2GCb_qaGMXL3gR8XjHsbZB-Ia1oX3aiU0F66x4OsUnTFMSmxrTYqPxKdsAgo6JVemhkLR5ZG-AkwLnhsDylGPytSKMYso0JXPDXw55RzUrEIP1MGknwkrWaVx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