[PATCH] D20196: [clang-tidy] Inefficient string operation

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Sun May 15 17:32:57 PDT 2016


etienneb added inline comments.

================
Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:35
@@ +34,3 @@
+      cxxOperatorCallExpr(hasAnyArgument(ignoringImpCasts(declRefExpr(BasicStringType))),
+                          hasOverloadedOperatorName("+"));
+
----------------
you should swap the  two parameters

```
hasOverloadedOperatorName("+"),
hasAnyArgument(...)
```

matching 'hasOverloadedOperatorName' is less expensive

================
Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:41
@@ +40,3 @@
+              cxxOperatorCallExpr(hasDescendant(BasicStringPlusOperator),
+                                  hasAnyArgument(ignoringImpCasts(declRefExpr(BasicStringType))),
+                                  hasOverloadedOperatorName("+"))
----------------
this is not indented correctly.
could you run 
```
  % clang-format -style=file <your-file> -i
```

================
Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:47
@@ +46,3 @@
+  const auto AssingOperator = cxxOperatorCallExpr(
+      hasOverloadedOperatorName("="),hasDescendant(BasicStringPlusOperator),
+      allOf(hasArgument(
----------------
space after ","

================
Comment at: clang-tidy/performance/InefficientStringAdditionCheck.cpp:54
@@ +53,3 @@
+                1, stmt(hasDescendant(declRefExpr(hasDeclaration(decl(
+                       equalsBoundNode("lhsStrT")))) /*.bind("rhs-self")*/)))));
+
----------------
You forgot a comment here?


http://reviews.llvm.org/D20196





More information about the cfe-commits mailing list