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

    <tr>
        <th>Summary</th>
        <td>
            `clangtk` crashes at clang::Expr::IgnoreImpCasts
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    The bug triggering testcase:
```
#include <limits.h>
#include <stdint.h>
typedef enum omp_allocator_handle_t : uintptr_t {
 omp_default_mem_alloc = 1,
} omp_allocator_handle_t;
int r, bar(int, int *, int);
void foo(void) {
#pragma omp taskgroup task_reduction(+ : r) allocate(omp_default_mem_alloc : r)
#pragma omp task in_reduction(+ : r) allocate(omp_default_mem_alloc : r)
  bar(r, &r, 0);
}
```

When attempting to compile this program using `clangtk` with option `-O0 -fopenmp-simd`, `clangtk` crashes with the following output (can be verified at https://gcc.godbolt.org/z/9K88sazY7):
```
<source>:8:54: error: 'omp_allocator_handle_t' type not found; include <omp.h>
    8 | #pragma omp taskgroup task_reduction(+ : r) allocate(omp_default_mem_alloc : r)
 |                                                      ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd <source>
1.      <source>:11:1: current parser token '}'
2.      <source>:7:16: parsing function body 'foo'
3.      <source>:7:16: in compound statement ('{}')
 #0 0x0000561eb88c716f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362e16f)
 #1 0x0000561eb88c519c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x362c19c)
 #2 0x0000561eb8814e58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f3508428420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x0000561ebbe94d2c clang::Expr::IgnoreImpCasts() (/opt/compiler-explorer/clang-trunk/bin/clang+0x6bfbd2c)
 #5 0x0000561ebb5dc9f9 getAllocatorKind(clang::Sema&, (anonymous namespace)::DSAStackTy*, clang::Expr*) (.part.0) SemaOpenMP.cpp:0:0
 #6 0x0000561ebb63044f clang::Sema::EndOpenMPDSABlock(clang::Stmt*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x639744f)
 #7 0x0000561ebaee662a clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c4d62a)
 #8 0x0000561ebaf0850c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c6f50c)
 #9 0x0000561ebaf0a181 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71181)
#10 0x0000561ebaf0f348 clang::Parser::ParseStatement(clang::SourceLocation*, clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c76348)
#11 0x0000561ebaee65a5 clang::Parser::ParseOpenMPDeclarativeOrExecutableDirective(clang::Parser::ParsedStmtContext, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c4d5a5)
#12 0x0000561ebaf0850c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c6f50c)
#13 0x0000561ebaf0a181 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71181)
#14 0x0000561ebaf0aff9 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c71ff9)
#15 0x0000561ebaf0d2e2 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5c742e2)
#16 0x0000561ebae288d0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b8f8d0)
#17 0x0000561ebae5afdf clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5bc1fdf)
#18 0x0000561ebae22d26 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b89d26)
#19 0x0000561ebae23e8f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0
#20 0x0000561ebae2b90f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b9290f)
#21 0x0000561ebae2ce56 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b93e56)
#22 0x0000561ebae1c39a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x5b8339a)
#23 0x0000561eb9a6020d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47c720d)
#24 0x0000561eb933bd61 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x40a2d61)
#25 0x0000561eb92c1193 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4028193)
#26 0x0000561eb941cd03 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x4183d03)
#27 0x0000561eb613c72c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea372c)
#28 0x0000561eb6137def ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x0000561eb911490d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#30 0x0000561eb88152d7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x357c2d7)
#31 0x0000561eb9114dac clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#32 0x0000561eb90dbc9e clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e42c9e)
#33 0x0000561eb90dc66d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e4366d)
#34 0x0000561eb90e6d3c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3e4dd3c)
#35 0x0000561eb613a2ef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xea12ef)
#36 0x0000561eb60367b5 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xd9d7b5)
#37 0x00007f3507ed6083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#38 0x0000561eb61340ce _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xe9b0ce)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1v2zjW_jXKDWGDImV9XOTCdZp5M9NBi6Z4F3tlUOSRzY1EaikqTebXL0jJsanabqbxFrvYGUwTRSIPz3nOcz4oinWd3CiA62jxLlrcXLHebrW5_irBWK2uSi2er79sAZX9BlkjNxswUm2Qhc5y1kFElxG-ifAySvH4__AnoVLxuheAIrqqZSNtN99G9P2xx50VUtmDx_a5BQEVAtU3SDftmtW15sxqs94yJWpYWxTRJeqlsq017q_s3TDVDxdQsb626waaYSqK6A2KI7Ial89uToiN6ChHKotMRFaoZCYiuVTW_eHuRmQ5XkakeBn_qKVAldYRyd1lRIq9ThGhrWGbhrlFkWXdw8bofrhaGxA9t1KriOQReeftMm76qBxEJD9l0zDy1CJIqotJRyMOHpKIpP43PgQgym6OM8H__NsWFGLWQtNazx-NuG5aWQOyW9mh1uiNYQ3qO_c0SjGvmdrYhyjF6Ku0W6RbZ4V7MvuI0azSLaimnXWyEW4pp1UwiRvWbaEbJtst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