https://github.com/zeyi2 commented:

For this case:

```cpp
#include <vector>

std::vector<int> make() {
  return {0};
}
```

Currently the check would rewrite it to:

```cpp
std::vector<int> make() {
  return {};
}
```

IMO there is a semantic change here.

By looking at the AST dump:

```
`-CXXConstructExpr 0x9e2d6d6d8 <col:10, col:12> 'std::vector<int>' 'void 
(initializer_list<value_type>)' list std::initializer_list
        `-CXXStdInitializerListExpr 0x9e2d6d260 <col:10, col:12> 
'initializer_list<value_type>':'std::initializer_list<int>'
          `-MaterializeTemporaryExpr 0x9e2d6d248 <col:10, col:12> 'const 
value_type[1]' xvalue
            `-InitListExpr 0x9e2d6d200 <col:10, col:12> 'const value_type[1]'
              `-IntegerLiteral 0x9e2d6c270 <col:11> 'int' 0
```

I think we should also filter `cxxStdInitializerListExpr()` in the matcher, 
something like: `unless(hasAncestor(cxxStdInitializerListExpr()))`

https://github.com/llvm/llvm-project/pull/209367
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to