[PATCH] D69238: Fix clang-tidy readability-redundant-string-init for c++17/c++2a

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 11:53:35 PDT 2019


MyDeveloperDay added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp:50
           varDecl(hasType(hasUnqualifiedDesugaredType(recordType(
                       hasDeclaration(cxxRecordDecl(hasName("basic_string")))))),
                   hasInitializer(expr(ignoringImplicit(anyOf(
----------------
driveby aside comment (feel free to ignore): wouldn't it be good if "basic_string" here was configurable, this would allow anyone who defines a string class (say like StringRef) which could have this kind of redundant string initialization be able to catch them.

Couldn't this be then used to find code like `StringRef EnabledPrefixOut = "";`

```
static void ParseMRecip(const Driver &D, const ArgList &Args,
                        ArgStringList &OutStrings) {
  StringRef DisabledPrefixIn = "!";
  StringRef DisabledPrefixOut = "!";
  StringRef EnabledPrefixOut = "";
  StringRef Out = "-mrecip=";
```



Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69238/new/

https://reviews.llvm.org/D69238





More information about the cfe-commits mailing list