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

    <tr>
        <th>Summary</th>
        <td>
            [clang] clang crashes at clang::Sema::canThrow(clang::Stmt const*)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            crash-on-invalid,
            clang:frontend:fuzzer
      </td>
    </tr>

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

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

<pre>
    **This testcase is generated by a fuzzer.**

Compiler Explorer: [https://godbolt.org/z/4Kq7c1orP](https://godbolt.org/z/4Kq7c1orP)

This invalid code will crash on Clang Trunk.
```cpp
class NonCopyable {
 NonCopyable(const NonCopyable&) = delete; 
  void foo() {
    const auto &M2 = [this] () -> auto&& {
      noexcept([*this] { return 0; });
    };
  }
};
```

It seems that this goes back to clang-6.

Stack dump:
```
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 -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1.      <source>:5:38: current parser token ';'
2.      <source>:1:1: parsing struct/union/class body 'NonCopyable'
3.      <source>:3:14: parsing function body 'NonCopyable::foo'
4.      <source>:3:14: in compound statement ('{}')
5.      <source>:4:22: lambda expression parsing
6.      <source>:4:42: in compound statement ('{}')
 #0 0x000000000396c6d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x396c6d8)
 #1 0x000000000396a814 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x396a814)
 #2 0x00000000038bb2a8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007572c9642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00000000067f09eb clang::Sema::canThrow(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x67f09eb)
 #5 0x00000000067f0e3d clang::Sema::canThrow(clang::Stmt const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x67f0e3d)
 #6 0x0000000006980208 clang::Sema::ActOnNoexceptExpr(clang::SourceLocation, clang::SourceLocation, clang::Expr*, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6980208)
 #7 0x000000000632dfce clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x632dfce)
 #8 0x000000000632ea5a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x632ea5a)
 #9 0x000000000632ec29 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x632ec29)
#10 0x0000000006333e79 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6333e79)
#11 0x00000000063c03d7 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63c03d7)
#12 0x00000000063b3b17 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b3b17)
#13 0x00000000063b450d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b450d)
#14 0x00000000063b5821 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b5821)
#15 0x000000000634ee72 clang::Parser::ParseLambdaExpressionAfterIntroducer(clang::LambdaIntroducer&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634ee72)
#16 0x000000000635066b clang::Parser::ParseLambdaExpression() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x635066b)
#17 0x000000000632e19d clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x632e19d)
#18 0x000000000632ea5a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x632ea5a)
#19 0x000000000632ec29 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x632ec29)
#20 0x00000000062e7488 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62e7488)
#21 0x00000000062fd20c clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62fd20c)
#22 0x00000000062ffd3a clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62ffd3a)
#23 0x000000000630023f clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x630023f)
#24 0x00000000063b3bb4 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b3bb4)
#25 0x00000000063b450d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b450d)
#26 0x00000000063b5821 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b5821)
#27 0x00000000063b7a4a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63b7a4a)
#28 0x00000000062cbd4e clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62cbd4e)
#29 0x00000000062cb9fd clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62cb9fd)
#30 0x0000000006321e9f clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6321e9f)
#31 0x0000000006324e68 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6324e68)
#32 0x00000000062edfa9 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62edfa9)
#33 0x00000000062abb46 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62abb46)
#34 0x00000000062acd13 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62acd13)
#35 0x00000000062b6612 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62b6612)
#36 0x00000000062b7ea8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62b7ea8)
#37 0x00000000062b83f0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62b83f0)
#38 0x00000000062a6532 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62a6532)
#39 0x00000000042b2fa5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42b2fa5)
#40 0x000000000457a7d1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x457a7d1)
#41 0x00000000044fa8bb clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44fa8bb)
#42 0x000000000465ed83 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x465ed83)
#43 0x0000000000cebbbc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xcebbbc)
#44 0x0000000000ce463d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#45 0x00000000042fadc9 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
#46 0x00000000038bb6d3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38bb6d3)
#47 0x00000000042fafe9 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
#48 0x00000000042c297d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42c297d)
#49 0x00000000042c397d 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+++0x42c397d)
#50 0x00000000042ccf6c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42ccf6c)
#51 0x0000000000ce8921 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xce8921)
#52 0x0000000000bba334 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xbba334)
#53 0x00007572c9629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#54 0x00007572c9629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#55 0x0000000000ce40de _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xce40de)
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/eJzsW11z26ga_jXKDWOPBPryRS4cJ96T3XbbaTJn9i6DELLZyqAFlDr99WcAORaKo6Q9yn53msQW8PK8D_DygAArxTac0vMguQiSyzPc6q2Q5w_sV8zjPE7OClE-nAdwGcDl7ZYpoKnSBCsKmAIbyqnEmpageAAYVO3Xr1TOXeYgvAzC7vdK7BpWUwmu9k0tJJUBWoIgudhq3agALQO4DuB6I8pC1Hou5CaA668BXMc__ZaRSMiPQXIZwPz12eGiX73Fzfg9rlkJiCgp-MLqGhCJ1RYIDlY15htwK1v-ed6VS0P3nzSNe0JqrBT4WfCVaB5wUVMQZBcuqf80gDkRXGn_WRrABQjQJShpTTUN0AXoioJ7wUpQCRHA3GZ6NAoAcJZwqwUIYPoeWhNBcqG3TAXJJejKzAJ0ZXPZilLfBgBc0D2hjTa5k4sALh-LZxdAUt1KDkILKbs0xKFeafPo-N18c_T0Hj9S1Wf8WgNF6U4BvcUamArBRlAFCkw-Ay0AMYzP0nm_zI02iWW7a0wTn7L98d3V8uYKqLbYMQ0wKNoNkLQRUhubg97B9LYt5kTsAriu6_vDn1kjxa-U6ACumVItVQFcA8xLwDip25ICvaVdzzBgtcSEBnAFGkkbKQhVipZAiVa6x6YkVkoQZoeBbDlQRLJGz591KpwH4eKjFBuJdwDLTbujXCs7IuBamHZak268zOhhvMC1o0ybThrAdcH44VkALwJ4AWab8guW1SwGsw2YmR6zxk1jTLa6afVcgdnOEABms32ezrDazdQD13gfoEvGNa3BrOJidk9lIRQ16WB2A2azDSEzLURNtpjxAF2OgjSZFceN2goNZhURtZCzkuENF0ozolwdll7vcYBWHafoyrEUGZa8x2iZBGiJcsMUaaWkXIM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