Skip to content

Commit d337e82

Browse files
author
Tom James
committed
West const everywhere
1 parent 19465b6 commit d337e82

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

clang-tools-extra/clang-tidy/bugprone/MethodHidingCheck.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace clang::tidy::bugprone {
1616

1717
namespace {
1818

19-
bool sameBasicType(ParmVarDecl const *Lhs, ParmVarDecl const *Rhs) {
19+
bool sameBasicType(const ParmVarDecl *Lhs, const ParmVarDecl *Rhs) {
2020
if (Lhs && Rhs) {
2121
return Lhs->getType()
2222
.getCanonicalType()
@@ -29,7 +29,7 @@ bool sameBasicType(ParmVarDecl const *Lhs, ParmVarDecl const *Rhs) {
2929
return false;
3030
}
3131

32-
bool namesCollide(CXXMethodDecl const &Lhs, CXXMethodDecl const &Rhs) {
32+
bool namesCollide(const CXXMethodDecl &Lhs, const CXXMethodDecl &Rhs) {
3333
if (Lhs.getNameAsString() != Rhs.getNameAsString())
3434
return false;
3535
if (Lhs.isConst() != Rhs.isConst())
@@ -51,12 +51,12 @@ bool namesCollide(CXXMethodDecl const &Lhs, CXXMethodDecl const &Rhs) {
5151
}
5252

5353
AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) {
54-
CXXRecordDecl const *DerivedClass = Node.getParent();
55-
for (auto const &Base : DerivedClass->bases()) {
56-
std::stack<CXXBaseSpecifier const *> Stack;
54+
const CXXRecordDecl *DerivedClass = Node.getParent();
55+
for (const auto &Base : DerivedClass->bases()) {
56+
std::stack<const CXXBaseSpecifier *> Stack;
5757
Stack.push(&Base);
5858
while (!Stack.empty()) {
59-
CXXBaseSpecifier const *CurrentBaseSpec = Stack.top();
59+
const CXXBaseSpecifier *CurrentBaseSpec = Stack.top();
6060
Stack.pop();
6161

6262
if (CurrentBaseSpec->getAccessSpecifier() ==
@@ -68,7 +68,7 @@ AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) {
6868
if (!CurrentRecord)
6969
continue;
7070

71-
for (auto const &BaseMethod : CurrentRecord->methods()) {
71+
for (const auto &BaseMethod : CurrentRecord->methods()) {
7272
if (namesCollide(*BaseMethod, Node)) {
7373
ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
7474
Builder->setBinding("base_method",
@@ -77,9 +77,8 @@ AST_MATCHER(CXXMethodDecl, nameCollidesWithMethodInBase) {
7777
}
7878
}
7979

80-
for (auto const &SubBase : CurrentRecord->bases())
80+
for (const auto &SubBase : CurrentRecord->bases())
8181
Stack.push(&SubBase);
82-
8382
}
8483
}
8584
return false;
@@ -110,11 +109,11 @@ void MethodHidingCheck::registerMatchers(MatchFinder *Finder) {
110109
}
111110

112111
void MethodHidingCheck::check(const MatchFinder::MatchResult &Result) {
113-
auto const *ShadowingMethod =
112+
const auto *ShadowingMethod =
114113
Result.Nodes.getNodeAs<CXXMethodDecl>("shadowing_method");
115-
auto const *DerivedClass =
114+
const auto *DerivedClass =
116115
Result.Nodes.getNodeAs<CXXRecordDecl>("derived_class");
117-
auto const *BaseMethod = Result.Nodes.getNodeAs<CXXMethodDecl>("base_method");
116+
const auto *BaseMethod = Result.Nodes.getNodeAs<CXXMethodDecl>("base_method");
118117

119118
if (!ShadowingMethod || !DerivedClass || !BaseMethod)
120119
llvm_unreachable("Required binding not found");

0 commit comments

Comments
 (0)