Skip to content

Commit 17fa04e

Browse files
committed
[clang][AST][NFC] Make declarationReplaces()'s first parameter const
And const qualify some local variables
1 parent 41096d1 commit 17fa04e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ class NamedDecl : public Decl {
358358
///
359359
/// \param IsKnownNewer \c true if this declaration is known to be newer
360360
/// than \p OldD (for instance, if this declaration is newly-created).
361-
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer = true) const;
361+
bool declarationReplaces(const NamedDecl *OldD,
362+
bool IsKnownNewer = true) const;
362363

363364
/// Determine whether this declaration has linkage.
364365
bool hasLinkage() const;

clang/lib/AST/Decl.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,8 @@ static bool isRedeclarable(Decl::Kind K) {
18431843
llvm_unreachable("unknown decl kind");
18441844
}
18451845

1846-
bool NamedDecl::declarationReplaces(NamedDecl *OldD, bool IsKnownNewer) const {
1846+
bool NamedDecl::declarationReplaces(const NamedDecl *OldD,
1847+
bool IsKnownNewer) const {
18471848
assert(getDeclName() == OldD->getDeclName() && "Declaration name mismatch");
18481849

18491850
// Never replace one imported declaration with another; we need both results
@@ -1873,13 +1874,13 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD, bool IsKnownNewer) const {
18731874

18741875
// Using declarations can be replaced if they import the same name from the
18751876
// same context.
1876-
if (auto *UD = dyn_cast<UsingDecl>(this)) {
1877+
if (const auto *UD = dyn_cast<UsingDecl>(this)) {
18771878
ASTContext &Context = getASTContext();
18781879
return Context.getCanonicalNestedNameSpecifier(UD->getQualifier()) ==
18791880
Context.getCanonicalNestedNameSpecifier(
18801881
cast<UsingDecl>(OldD)->getQualifier());
18811882
}
1882-
if (auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(this)) {
1883+
if (const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(this)) {
18831884
ASTContext &Context = getASTContext();
18841885
return Context.getCanonicalNestedNameSpecifier(UUVD->getQualifier()) ==
18851886
Context.getCanonicalNestedNameSpecifier(
@@ -1896,7 +1897,7 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD, bool IsKnownNewer) const {
18961897
// Check whether this is actually newer than OldD. We want to keep the
18971898
// newer declaration. This loop will usually only iterate once, because
18981899
// OldD is usually the previous declaration.
1899-
for (auto *D : redecls()) {
1900+
for (const auto *D : redecls()) {
19001901
if (D == OldD)
19011902
break;
19021903

0 commit comments

Comments
 (0)