[PATCH] D18919: [Clang-tidy] Add check "modernize use using"
Piotr Padlewski via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 9 12:41:23 PDT 2016
Prazek added inline comments.
================
Comment at: clang-tidy/modernize/UseUsingCheck.cpp:26
@@ +25,3 @@
+/// AST representation of type.
+std::string removeExtraASTWords(std::string subject) {
+ std::pair<std::string, std::string> subs[] = {
----------------
add static
================
Comment at: clang-tidy/modernize/UseUsingCheck.cpp:27
@@ +26,3 @@
+std::string removeExtraASTWords(std::string subject) {
+ std::pair<std::string, std::string> subs[] = {
+ {"class ", ""}, {"struct ", ""}, {"union ", ""}, {"(void)", "()"}};
----------------
Stick to the LLVM coding style - local variables starts with capital letter.
Also add const here
================
Comment at: clang-tidy/modernize/UseUsingCheck.cpp:32-35
@@ +31,6 @@
+ std::string replace = p.second;
+ size_t pos = 0;
+ while ((pos = subject.find(search, pos)) != std::string::npos) {
+ subject.replace(pos, search.length(), replace);
+ pos += replace.length();
+ }
----------------
you can extract this to another static function
static void replaceAll(std::string &s, const std::string &search, const std::string replace);
================
Comment at: clang-tidy/modernize/UseUsingCheck.cpp:48
@@ +47,3 @@
+ << FixItHint::CreateReplacement(
+ MatchedDecl->getSourceRange(),
+ "using " + MatchedDecl->getNameAsString() + " = " +
----------------
check if it is clang-formatted
Repository:
rL LLVM
http://reviews.llvm.org/D18919
More information about the cfe-commits
mailing list