diff options
| author | Mitchell Balan <mitchell@stellarscience.com> | 2019-11-19 07:43:12 -0500 |
|---|---|---|
| committer | Mitchell Balan <mitchell@stellarscience.com> | 2019-11-19 07:52:31 -0500 |
| commit | f8901aff4a8f1809d62e0d676a1035099c8f734a (patch) | |
| tree | 314f905551713c702c26f97ebfcde57ddb363d22 /clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp | |
| parent | 41ee54e5d18858c56725485ef637ad5a686368f4 (diff) | |
| download | bcm5719-llvm-f8901aff4a8f1809d62e0d676a1035099c8f734a.tar.gz bcm5719-llvm-f8901aff4a8f1809d62e0d676a1035099c8f734a.zip | |
Revert "[clang-tidy] modernize-use-override new option AllowOverrideAndFinal"
This reverts commit 50e99563fb0459f5160572eef3c4e6062b8ad3f2.
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp index 6bf0edb7231..42f802cd0af 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp @@ -73,7 +73,7 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) { namedDecl( varDecl( hasType(hasUnqualifiedDesugaredType(recordType( - hasDeclaration(cxxRecordDecl(hasStringTypeName))))), + hasDeclaration(cxxRecordDecl(hasName("basic_string")))))), hasInitializer(expr(ignoringImplicit(anyOf( EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries))))) .bind("vardecl"), @@ -82,12 +82,11 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) { } void RedundantStringInitCheck::check(const MatchFinder::MatchResult &Result) { - const auto *VDecl = Result.Nodes.getNodeAs<VarDecl>("vardecl"); - // VarDecl's getSourceRange() spans 'string foo = ""' or 'string bar("")'. - // So start at getLocation() to span just 'foo = ""' or 'bar("")'. - SourceRange ReplaceRange(VDecl->getLocation(), VDecl->getEndLoc()); - diag(VDecl->getLocation(), "redundant string initialization") - << FixItHint::CreateReplacement(ReplaceRange, VDecl->getName()); + const auto *CtorExpr = Result.Nodes.getNodeAs<Expr>("expr"); + const auto *Decl = Result.Nodes.getNodeAs<NamedDecl>("decl"); + diag(CtorExpr->getExprLoc(), "redundant string initialization") + << FixItHint::CreateReplacement(CtorExpr->getSourceRange(), + Decl->getName()); } } // namespace readability |

