[PATCH] Refactor: Move remove-cstr-calls from a standalone executable to a clang-tidy check readability-redundant-string-cstr

Richard legalize at xmission.com
Sun Mar 15 13:03:14 PDT 2015


================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:38
@@ +37,3 @@
+  }
+  if (const auto op = dyn_cast<CXXOperatorCallExpr>(&ExprNode)) {
+    return op->getNumArgs() == 2 && op->getOperator() != OO_PlusPlus &&
----------------
alexfh wrote:
> alexfh wrote:
> > s/const auto/const auto*/
> Use LLVM naming style: `Op`
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:51
@@ +50,3 @@
+                  const Expr &ExprNode) {
+  if (const auto Op = dyn_cast<clang::UnaryOperator>(&ExprNode)) {
+    if (Op->getOpcode() == UO_AddrOf) {
----------------
alexfh wrote:
> s/const auto/const auto*/
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:67
@@ +66,3 @@
+
+const char *const StringConstructor =
+    "::std::basic_string<char, std::char_traits<char>, std::allocator<char> >"
----------------
alexfh wrote:
> const char StringConstructor[] = ...
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:71
@@ +70,3 @@
+
+const char *const StringCStrMethod =
+    "::std::basic_string<char, std::char_traits<char>, std::allocator<char> >"
----------------
alexfh wrote:
> ditto
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:92
@@ +91,3 @@
+          hasArgument(
+              0, id("call", memberCallExpr(
+                                callee(id("member", memberExpr())),
----------------
alexfh wrote:
> `id` is an old-style construct, now we prefer using `.bind()`:
> 
>   id("...", X) -> X.bind("...")
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:95
@@ +94,3 @@
+                                callee(methodDecl(hasName(StringCStrMethod))),
+                                on(id("arg", expr()))))),
+          // The second argument is the alloc object which must not be
----------------
alexfh wrote:
> ditto
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:116
@@ +115,3 @@
+          hasArgument(
+              0, id("call", memberCallExpr(
+                                callee(id("member", memberExpr())),
----------------
alexfh wrote:
> ditto
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:119
@@ +118,3 @@
+                                callee(methodDecl(hasName(StringCStrMethod))),
+                                on(id("arg", expr())))))),
+      this);
----------------
alexfh wrote:
> ditto
Fixed

================
Comment at: clang-tidy/readability/RedundantStringCStrCheck.cpp:124
@@ +123,3 @@
+void RedundantStringCStrCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto Call = Result.Nodes.getStmtAs<CallExpr>("call");
+  const auto Arg = Result.Nodes.getStmtAs<Expr>("arg");
----------------
alexfh wrote:
> const auto*
Fixed

http://reviews.llvm.org/D7318

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list