[PATCH] D18412: [clang-tidy] Add support for different char-types for the readability-redundant-string-cstr checker.

Etienne Bergeron via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 13:21:29 PDT 2016

etienneb added a comment.

In http://reviews.llvm.org/D18412#381843, @dblaikie wrote:

> can you just match on the name of the template instead?

I'm not sure to get your point?

Are you proposing to match "basic_string" instead of the whole regexp?
I'm in favor of that change as I don't see any counter example or any false positive.

In fact, many checkers are using hasName("basic_string").
I just kept the change as minimal as possible to keep the same semantic and allow matching more cases.

Example from RedundantStringInitCheck.cpp:

  // Match string constructor.
  const auto StringConstructorExpr = expr(anyOf(

Comment at: test/clang-tidy/readability-redundant-string-cstr.cpp:54
@@ +53,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
mamai wrote:
> Isn't this a copy-paste error to reference f1 ? Same question for line 62 and 70...
Good catch.


More information about the cfe-commits mailing list