[PATCH] D70270: clang-tidy: modernize-use-using uses AST and now supports struct defintions and multiple types in a typedef
Conrad Poelman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 13:20:29 PST 2019
poelmanc created this revision.
poelmanc added reviewers: alexfh, aaron.ballman.
poelmanc added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, mgehre.
Herald added a project: clang.
In D67460#1737529 <https://reviews.llvm.org/D67460#1737529>, @aaron.ballman wrote:
> I'm a bit worried that this manual parsing technique will need fixing again in the future
That concern plus prior comments and help from `clang -ast-dump` led me to develop this new approach based entirely on the AST that completely eliminates manual parsing. It now handles `typedef`s that include comma-separated multiple types, and handles embedded `struct` definitions, which previously could not be automatically converted.
For example, with this patch `modernize-use-using` now can convert:
typedef struct { int a; } R_t, *R_p;
to:
using R_t = struct { int a; }; using R_p = R_t*;
`-ast-dump` showed that the `CXXRecordDecl` definitions and multiple `TypedefDecl`s come consecutively in the tree, so `check()` stores information between calls to determine when it is receiving a second or additional `TypedefDecl` within a single `typedef`, or when the current `TypedefDecl` refers to an embedded `CXXRecordDecl` like a `struct`.
This patch is independent of D67460 <https://reviews.llvm.org/D67460> except for borrowing its extended set of tests. All those tests pass, plus several that previously remained as `typedef` are now modernized to use `using`.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D70270
Files:
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-use-using.rst
clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
clang/include/clang/Basic/SourceLocation.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70270.229385.patch
Type: text/x-patch
Size: 14366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191114/0936cae7/attachment-0001.bin>
More information about the cfe-commits
mailing list