[clang] [clang-tools-extra] [CLANGD] Do not crash on designator initialization of union (PR #83369)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 12 23:24:17 PDT 2024
================
@@ -4601,8 +4601,15 @@ SourceRange DesignatedInitExpr::getDesignatorsSourceRange() const {
SourceLocation DesignatedInitExpr::getBeginLoc() const {
auto *DIE = const_cast<DesignatedInitExpr *>(this);
Designator &First = *DIE->getDesignator(0);
- if (First.isFieldDesignator())
- return GNUSyntax ? First.getFieldLoc() : First.getDotLoc();
+ if (First.isFieldDesignator()) {
+ for (unsigned int i = 0; i < DIE->size(); i++) {
----------------
HighCommander4 wrote:
Please add a comment explaining what this code is doing. Something like:
```c++
// Skip past implicit designators for anonymous structs/unions, since
// these do not have valid source locations.
```
https://github.com/llvm/llvm-project/pull/83369
More information about the cfe-commits
mailing list