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

    <tr>
        <th>Summary</th>
        <td>
            Malformed attribute results in crash
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    Given the following malformed C++: https://godbolt.org/z/W58rexb7T

```cpp
[][[h]]l
```

This results in a crash with assertions enabled due to dereferences a null reference. There is no actual assertion but we get the following backtrace:


```console
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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1.      <eof> parser at end of file
 #0 0x00000000038d2b38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38d2b38)
 #1 0x00000000038d081c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38d081c)
 #2 0x0000000003818cf8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ff556442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000000006d7ca07 GetFullTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::QualType, clang::TypeSourceInfo*) SemaType.cpp:0:0
 #5 0x0000000006d817aa clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d817aa)
 #6 0x00000000064cc9db clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64cc9db)
 #7 0x00000000064cdb31 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64cdb31)
 #8 0x000000000616eb7f clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x616eb7f)
 #9 0x000000000617dfaa 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+++0x617dfaa)
#10 0x000000000613bdee clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x613bdee)
#11 0x000000000613c5c1 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x613c5c1)
#12 0x00000000061439f6 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61439f6)
#13 0x000000000614489d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x614489d)
#14 0x0000000006144d70 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6144d70)
#15 0x00000000061375ba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61375ba)
#16 0x00000000041669e8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41669e8)
#17 0x00000000043e1099 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43e1099)
#18 0x000000000435fc0e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x435fc0e)
#19 0x00000000044c327e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c327e)
#20 0x0000000000c1ea66 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc1ea66)
#21 0x0000000000c1677a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#22 0x00000000041a7ff9 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
#23 0x00000000038191a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38191a4)
#24 0x00000000041a85ef 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
#25 0x0000000004170275 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4170275)
#26 0x0000000004170cdd 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+++0x4170cdd)
#27 0x0000000004178c15 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4178c15)
#28 0x0000000000c1bf1d clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc1bf1d)
#29 0x0000000000b12824 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb12824)
#30 0x00007ff556429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#31 0x00007ff556429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#32 0x0000000000c1623e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc1623e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```

I picked this up from: https://github.com/llvm/llvm-project/pull/77703

We seem to generating a good `ParsedAttr` when we first see it but somewhere along the way we are losing it.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkmk1zozrWxz8N2ahwgcAGL7JwO3E_udW3Ok8nNXfpEuKANS0kRhKJM59-SgLHiDju7pm4FzO3chNa6OV_fjo6OgiI1qwWANfB_FMwv7kindlJda13pGLfrwpZvlx_Zk8gkNkBqiTn8pmJGjWEV1I1UKJ1gD_Zn2SFdsa0OkhWAd4EeFPLspDczKSqA7z5Z4A3f81zBfsiewyimyBaDb8XUf9D23YocUrc7087d3XDJ3XHHTzumEYKdMeNRkwggqgieoeemdkhojUow6TQCAQpOJSo7AAZiUpQUIECQUEjgkTHOXotmaHHHShATCMhEaGmI_zYFyo6g54B1WAmWApCvxtFKFgKYyMnpkqhJYe-9P7L7erhFumuaJhBBBVdjRS0Uhkrc8KUmV1XzKhsArzh_O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