[PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 25 07:27:37 PST 2016


alexfh added inline comments.

================
Comment at: clang-tidy/readability/RedundantStringInitCheck.cpp:26
@@ +25,3 @@
+void RedundantStringInitCheck::registerMatchers(
+    ast_matchers::MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
----------------
nit: `ast_matchers::` can be omitted.

================
Comment at: clang-tidy/readability/RedundantStringInitCheck.cpp:54
@@ +53,3 @@
+void RedundantStringInitCheck::check(
+    const ast_matchers::MatchFinder::MatchResult &Result) {
+  const auto *CtorExpr = Result.Nodes.getNodeAs<Expr>("expr");
----------------
ditto

================
Comment at: test/clang-tidy/readability-redundant-string-init.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
+
----------------
Please add test cases with:
  * a template with multiple instantiations
  * macros, something along the lines of:
```
       #define M(x) x
       M({ std::string a = ""; })
       #define M2 { std::string b = ""; }
       M2;
       M2;
```


http://reviews.llvm.org/D17586





More information about the cfe-commits mailing list