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

    <tr>
        <th>Summary</th>
        <td>
            clang AST crashes on invalid decl type.Assertion `getType(Base)->isPointerType() || getType(Base)->isArrayType()' failed
        </td>
    </tr>

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

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

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

<pre>
    
The provided test case contains compilation errors, and in `clang/lib/AST/APValue.cpp`, the method `QualType APValue::LValueBase::getType() const` is noted to handle `ValueDecl` in an inadequate way for similar situations.
>// FIXME: It's unclear where we're supposed to take the type from, and
    // this actually matters for arrays of unknown bound. Eg:
    //
    // extern int arr[]; void f() { extern int arr[3]; };
    // constexpr int *p = &arr[1]; // valid?
    //
    // For now, we take the most complete type we can find.

 The possible reason is that the obtained decl is an invalid decl, causing it to lose its `int[]` type attribute.

crash example like:
```cpp
extern int error_names_array[total_error_count + 2];
extern int error_names_array[];
static int *sqlstate_map = &error_names_array[1];
```

Is this a common way of handling the situation? When Clang detects a compilation error, certain unhandled cases can cause the Clang frontend to crash.However, in my opinion, it should at least not result in a crash.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE2P4zYM_TXKhdjAlidxcvDBmZ2gC7TAFjtoexvQNhOrI0tekU4m_76Q7J0P9AsIokR-pMn3HonM5uyIKrU5qM3nFU7S-1ANaBwTrhrf3SqV1Y89wRj8xXTUgRALtMgErXcSkdD6YTQWxXgHFIIPrPQ9oOvAOFDbrLXozkofrWmUPtbfHuP319_QTrRux1Fts4iXnmAg6X0XY36d0D7eRoIFqIpaFfXP6fcBefl_JokgpXdK72NBLGqbgWFwXmKxHnp0naWYMsV-ptYmiAN0YBx29H1CIbjiDU4-AJvBWIynTKklXqusVsWD0kelj3D88scvD6qo4YsoXTJM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