llvm / llvm/llvm-project

copy initialization of FieldDecl sometimes erroneously includes `= ` in source range

Open
#190,816 2 comments 0 reactions 0 assignees View on GitHub
clang:diagnostics confirmed
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Source ranges for the initialization expression in a FieldDecl is inconsistent with that from VarDecl when copy initialization is used in some circumstances, e.g.

https://gcc.godbolt.org/z/vPaY3dM13

```c++
struct D {};
struct S {
D d0;
D d1 = d0; // CXXConstructExpr("= d0")
D d2 = {d0}; // CXXConstructExpr("= {d0}")
D d3 = D{d0}; // CXXTemporaryObjectExpr("D{d0}")
D d4{d0}; // CXXConstructExpr("{d0}")
};

void fn() {
D d0;
D d1 = d0; // CXXConstructExpr("d0")
D d2 = {d0}; // CXXConstructExpr("{d0}")
D d3 = D{d0}; // CXXTemporaryObjectExpr("D{d0}")
D d4{d0}; // CXXConstructExpr("{d0}")
}
```

It seems to be limited to CXXConstructExpr, but I've not looked exhaustively.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.