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

Conrad Poelman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 22:29:33 PDT 2019


poelmanc marked 3 inline comments as done.
poelmanc 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(
----------------
MyDeveloperDay wrote:
> 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=";
> ```
> 
Great suggestion, done. See https://reviews.llvm.org/D69548. (I figured it should be a separate topic from this one, but holler if you prefer I add it to this patch.)


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