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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Assertion `Eval.Val.hasValue()' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            crash-on-valid,
            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/zhK3Eddqs](https://godbolt.org/z/zhK3Eddqs)

This valid code will crash on clang assertion trunk:
```cpp
template<typename T>
struct B {
  [[clang::annotate("test", (9, (void)T{}))]] void t() {}
};
B<int> b;

```

This goes back to clang-12.

Stack dump:
```
clang++: /root/llvm-project/clang/lib/Sema/SemaAttr.cpp:540: bool clang::Sema::ConstantFoldAttrArgs(const clang::AttributeCommonInfo&, llvm::MutableArrayRef<clang::Expr*>): Assertion `Eval.Val.hasValue()' failed.
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-assertions-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:9: current parser token ';'
2.      <source>:2:8: instantiating class definition 'B<int>'
 #0 0x0000000003c04df8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c04df8)
 #1 0x0000000003c02b04 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c02b04)
 #2 0x0000000003b50068 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007536fea42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007536fea969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007536fea42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007536fea287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007536fea2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007536fea39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000000000673c949 clang::Sema::ConstantFoldAttrArgs(clang::AttributeCommonInfo const&, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x673c949)
#10 0x00000000066bfad7 clang::Sema::CreateAnnotationAttr(clang::AttributeCommonInfo const&, llvm::StringRef, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66bfad7)
#11 0x00000000070db171 clang::Sema::InstantiateAttrs(clang::MultiLevelTemplateArgumentList const&, clang::Decl const*, clang::Decl*, llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*, clang::LocalInstantiationScope*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70db171)
#12 0x00000000070dc60c clang::TemplateDeclInstantiator::InitFunctionInstantiation(clang::FunctionDecl*, clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70dc60c)
#13 0x00000000070dcba8 clang::TemplateDeclInstantiator::InitMethodInstantiation(clang::CXXMethodDecl*, clang::CXXMethodDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70dcba8)
#14 0x00000000070e2905 clang::TemplateDeclInstantiator::VisitCXXMethodDecl(clang::CXXMethodDecl*, clang::TemplateParameterList*, clang::TemplateDeclInstantiator::RewriteKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70e2905)
#15 0x0000000007052e0b clang::Sema::InstantiateClass(clang::SourceLocation, clang::CXXRecordDecl*, clang::CXXRecordDecl*, clang::MultiLevelTemplateArgumentList const&, clang::TemplateSpecializationKind, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7052e0b)
#16 0x000000000707fd58 clang::Sema::InstantiateClassTemplateSpecialization(clang::SourceLocation, clang::ClassTemplateSpecializationDecl*, clang::TemplateSpecializationKind, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x707fd58)
#17 0x00000000070f3f3f void llvm::function_ref<void ()>::callback_fn<clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*)::'lambda'()>(long) SemaType.cpp:0:0
#18 0x0000000007c830f1 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7c830f1)
#19 0x00000000070fd367 clang::Sema::RequireCompleteTypeImpl(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70fd367)
#20 0x00000000070fd6b5 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, clang::Sema::TypeDiagnoser&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70fd6b5)
#21 0x00000000070fd835 clang::Sema::RequireCompleteType(clang::SourceLocation, clang::QualType, clang::Sema::CompleteTypeKind, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x70fd835)
#22 0x00000000068d4a11 clang::Sema::ActOnUninitializedDecl(clang::Decl*) (.part.0) SemaDecl.cpp:0:0
#23 0x0000000006576928 clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6576928)
#24 0x0000000006586409 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6586409)
#25 0x00000000065463be clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65463be)
#26 0x0000000006546b79 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6546b79)
#27 0x000000000654e2f3 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x654e2f3)
#28 0x000000000654f1bd clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x654f1bd)
#29 0x00000000065416fa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65416fa)
#30 0x0000000004587678 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4587678)
#31 0x0000000004842f09 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4842f09)
#32 0x00000000047c2b9e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47c2b9e)
#33 0x000000000492df6e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x492df6e)
#34 0x0000000000cb235f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb235f)
#35 0x0000000000ca9dfa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x00000000045cb0d9 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
#37 0x0000000003b50514 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b50514)
#38 0x00000000045cb6cf 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
#39 0x000000000459115d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459115d)
#40 0x000000000459224d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459224d)
#41 0x0000000004599605 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4599605)
#42 0x0000000000caf1a3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaf1a3)
#43 0x0000000000b82fe4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb82fe4)
#44 0x00007536fea29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#45 0x00007536fea29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#46 0x0000000000ca98a5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca98a5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkml1v27jSgH-NckPYkKjvi1woTrJvd1u0b5PTs3cGJVE2tzKpJanU6a8_GFK2Pmyn9Z44KHCKpLFFcjjzcEjOUCRKsRWn9NoJb5zw9oq0ei3k9TP7i_AgCcKrXJTP1w7OHJw9rplCmipdEEURU2hFOZVE0xLlz4igqv3-ncq5rey48LMQm4bVVKK7bVMLSaXjZ8gJb9ZaN8rxMwffO_h-Jcpc1Hou5MrB99_hd_2Hf1eWfysnvHVw8vPVcWo7Nro-kZqVqBAlRd9YXaNCErVGgqOiJnyFiFJUaiY40rLlX0G-mzmRa3-KpnHcTNNNUxNNHX-hnxvKyYaiR8e_c9xMadkWGt0gJ75x3Awhg_DGyAZZfkY4Fxoa48TBGMg5GDt4gRycpN3fJ8FKB6ePICS-Bf1xCkaHtwiKkDaNU9SVuxn870OHN46_YFw7_h3K7ZOh-gMMK0EVyknxFWlhTZ95eG4rPGh4XrabZmK-42bWEnwDPzBs-F4KoR18X9dPm1kjxV-0gK9dvfua5Q6-f6Ab0v3JtJZz4OhnYeCCjFyIGg0Imcrm00JwpQnX96IuoV0mV8rBSQGPhy2gjOWtpgux2Qj-jlfCwRHABK1snQ-tJnlNMynJ82daOf5iIOBu20jwT_8OSPsZyvZu4ETu3ROp519IPV8T9YXUrR271MExqgiraQncPr2_yx7ukGrzDdOIoLxdIUkbITUQnjgr0-s2nxdi04E75MeUaqly8D0ivESMF3VbUqTXtHNYGDotSUHBykbSRoqCKkVLpEQr7WNoSZQSBTPzUbYcqUKyRs-PDLI7d9z0kxQrSTaIyFW7oVyrboxFY8a0m7gzupu43TjP9r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