[clang] 17fa04e - [clang][AST][NFC] Make declarationReplaces()'s first parameter const
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 01:20:13 PST 2023
Author: Timm Bäder
Date: 2023-12-19T10:19:52+01:00
New Revision: 17fa04e32f8f7e7b65363dad0bc64d058030ef7c
URL: https://github.com/llvm/llvm-project/commit/17fa04e32f8f7e7b65363dad0bc64d058030ef7c
DIFF: https://github.com/llvm/llvm-project/commit/17fa04e32f8f7e7b65363dad0bc64d058030ef7c.diff
LOG: [clang][AST][NFC] Make declarationReplaces()'s first parameter const
And const qualify some local variables
Added:
Modified:
clang/include/clang/AST/Decl.h
clang/lib/AST/Decl.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index f9bf9cc5de7cb4..a807bcdd76b30d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -358,7 +358,8 @@ class NamedDecl : public Decl {
///
/// \param IsKnownNewer \c true if this declaration is known to be newer
/// than \p OldD (for instance, if this declaration is newly-created).
- bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer = true) const;
+ bool declarationReplaces(const NamedDecl *OldD,
+ bool IsKnownNewer = true) const;
/// Determine whether this declaration has linkage.
bool hasLinkage() const;
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index fbd5ff9a2ecf22..f8e6f4efff4ebb 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1843,7 +1843,8 @@ static bool isRedeclarable(Decl::Kind K) {
llvm_unreachable("unknown decl kind");
}
-bool NamedDecl::declarationReplaces(NamedDecl *OldD, bool IsKnownNewer) const {
+bool NamedDecl::declarationReplaces(const NamedDecl *OldD,
+ bool IsKnownNewer) const {
assert(getDeclName() == OldD->getDeclName() && "Declaration name mismatch");
// Never replace one imported declaration with another; we need both results
@@ -1873,13 +1874,13 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD, bool IsKnownNewer) const {
// Using declarations can be replaced if they import the same name from the
// same context.
- if (auto *UD = dyn_cast<UsingDecl>(this)) {
+ if (const auto *UD = dyn_cast<UsingDecl>(this)) {
ASTContext &Context = getASTContext();
return Context.getCanonicalNestedNameSpecifier(UD->getQualifier()) ==
Context.getCanonicalNestedNameSpecifier(
cast<UsingDecl>(OldD)->getQualifier());
}
- if (auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(this)) {
+ if (const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(this)) {
ASTContext &Context = getASTContext();
return Context.getCanonicalNestedNameSpecifier(UUVD->getQualifier()) ==
Context.getCanonicalNestedNameSpecifier(
@@ -1896,7 +1897,7 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD, bool IsKnownNewer) const {
// Check whether this is actually newer than OldD. We want to keep the
// newer declaration. This loop will usually only iterate once, because
// OldD is usually the previous declaration.
- for (auto *D : redecls()) {
+ for (const auto *D : redecls()) {
if (D == OldD)
break;
More information about the cfe-commits
mailing list