Skip to content

Commit f8901af

Browse files
author
Mitchell Balan
committed
Revert "[clang-tidy] modernize-use-override new option AllowOverrideAndFinal"
This reverts commit 50e9956.
1 parent 41ee54e commit f8901af

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
7373
namedDecl(
7474
varDecl(
7575
hasType(hasUnqualifiedDesugaredType(recordType(
76-
hasDeclaration(cxxRecordDecl(hasStringTypeName))))),
76+
hasDeclaration(cxxRecordDecl(hasName("basic_string")))))),
7777
hasInitializer(expr(ignoringImplicit(anyOf(
7878
EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries)))))
7979
.bind("vardecl"),
@@ -82,12 +82,11 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
8282
}
8383

8484
void RedundantStringInitCheck::check(const MatchFinder::MatchResult &Result) {
85-
const auto *VDecl = Result.Nodes.getNodeAs<VarDecl>("vardecl");
86-
// VarDecl's getSourceRange() spans 'string foo = ""' or 'string bar("")'.
87-
// So start at getLocation() to span just 'foo = ""' or 'bar("")'.
88-
SourceRange ReplaceRange(VDecl->getLocation(), VDecl->getEndLoc());
89-
diag(VDecl->getLocation(), "redundant string initialization")
90-
<< FixItHint::CreateReplacement(ReplaceRange, VDecl->getName());
85+
const auto *CtorExpr = Result.Nodes.getNodeAs<Expr>("expr");
86+
const auto *Decl = Result.Nodes.getNodeAs<NamedDecl>("decl");
87+
diag(CtorExpr->getExprLoc(), "redundant string initialization")
88+
<< FixItHint::CreateReplacement(CtorExpr->getSourceRange(),
89+
Decl->getName());
9190
}
9291

9392
} // namespace readability

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %check_clang_tidy %s readability-redundant-string-init %t
1+
// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t
2+
// FIXME: Fix the checker to work in C++17 mode.
23

34
namespace std {
45
template <typename T>

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t \
2-
// RUN: -config="{CheckOptions: \
3-
// RUN: [{key: readability-redundant-string-init.StringNames, \
4-
// RUN: value: '::std::basic_string;our::TestString'}] \
5-
// RUN: }"
1+
// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t
62
// FIXME: Fix the checker to work in C++17 mode.
73

84
namespace std {
@@ -135,11 +131,6 @@ void k() {
135131
// CHECK-FIXES: std::string a, b, c;
136132

137133
std::string d = "u", e = "u", f = "u";
138-
139-
std::string g = "u", h = "", i = "uuu", j = "", k;
140-
// CHECK-MESSAGES: [[@LINE-1]]:24: warning: redundant string initialization
141-
// CHECK-MESSAGES: [[@LINE-2]]:43: warning: redundant string initialization
142-
// CHECK-FIXES: std::string g = "u", h, i = "uuu", j, k;
143134
}
144135

145136
// These cases should not generate warnings.

0 commit comments

Comments
 (0)