[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
Fri Nov 15 20:45:36 PST 2019


poelmanc marked 6 inline comments as done.
poelmanc added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:30
+  // They appear in the AST just *prior* to the typedefs.
+  Finder->addMatcher(cxxRecordDecl().bind("struct"), this);
 }
----------------
aaron.ballman wrote:
> It's unfortunate that we can't restrict this matcher more -- there tend to be a lot of struct declarations, so I am a bit worried about the performance of this matching on so many of them. At a minimum, I think you can restrict it to non-implicit structs here and simplify the code in `check()` a bit.
Done, thanks!

If there's a way to match only `CXXRecordDecl`s that are //immediately followed// by a `TypedefDecl`, that would cut down the matches just to the ones we need. That said, at least the amount of work done on each `check()` call for the non-implicit `CXXRecordDecl`s is minimal: it just stores its `SourceRange` and returns.


================
Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:85
+    ReplaceRange.setBegin(LastReplacementEnd);
+    Using = "; using ";
+
----------------
aaron.ballman wrote:
> Should there be a newline here, to avoid putting all the using declarations on the same line?
Done. Updated test cases and documentation to reflect this.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70270/new/

https://reviews.llvm.org/D70270





More information about the cfe-commits mailing list