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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 19 06:53:03 PDT 2016


alexfh added a comment.

A few more nits.


================
Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:50
@@ +49,3 @@
+      hasOverloadedOperatorName("="),
+      hasArgument(0, allOf(declRefExpr(BasicStringType),
+                           declRefExpr(hasDeclaration(decl().bind("lhsStrT")))
----------------
The `allOf(declRefExpr(x), declRefExpr(y))` construct can be replaced with `declRefExpr(x, y)`.

================
Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:54
@@ +53,3 @@
+      hasArgument(1, stmt(hasDescendant(declRefExpr(
+                         hasDeclaration(decl(equalsBoundNode("lhsStrT"))))))),
+      hasDescendant(BasicStringPlusOperator));
----------------
Indentation is confusing - as though `hasDeclaration` is an argument of `stmt`. Is it a result of clang-format?

================
Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:63
@@ +62,3 @@
+        cxxOperatorCallExpr(
+            hasAncestor(stmt(anyOf(cxxForRangeStmt(), whileStmt(), forStmt()))),
+            anyOf(AssignOperator, PlusOperator)),
----------------
`hasAncestor` is potentially more expensive, so it should go last.


https://reviews.llvm.org/D20196





More information about the cfe-commits mailing list