llvm-project
67284454 - [clang] Make `InitListExpr::isExplicit()` work (#195175)

Commit
7 days ago
[clang] Make `InitListExpr::isExplicit()` work (#195175) The main goal of this change is to be able to use `isExplicit()` check in the IWYU tool. Consider the following: ```cpp struct Inner {}; struct Outer { Inner inner; }; const Outer& refOuter = {}; ``` Here, Clang generates `InitListExpr` child node for the implicit `Inner` initialization under the `InitListExpr` node corresponding to the initializer of `refOuter`. IWYU should require the header containing `Outer` definition for the initializer, but not the header for `Inner` because it should be already provided by `Outer`. 'IsExplicit' flag is copied from a template instantiation pattern into its instantiations although they are implicit because it makes sense for IWYU at least. (After all, instantiated declarations refer to the pattern explicitly written in the source.) `isImplicit()` AST matcher has been extended to support `InitListExpr`s. This is an NFC from the point of view of users of the Clang standalone executable (except the change in AST dumping), but a functional change for those who use Clang as a library.
Author
Parents
Loading