Skip to content

Commit 597f56f

Browse files
committed
[clang][AST][NFC] Take const CXXRecordDecl* in ComparisonCategories
The class member is already const.
1 parent 1a219e9 commit 597f56f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang/include/clang/AST/ComparisonCategories.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ComparisonCategoryInfo {
7878
friend class Sema;
7979

8080
public:
81-
ComparisonCategoryInfo(const ASTContext &Ctx, CXXRecordDecl *RD,
81+
ComparisonCategoryInfo(const ASTContext &Ctx, const CXXRecordDecl *RD,
8282
ComparisonCategoryType Kind)
8383
: Ctx(Ctx), Record(RD), Kind(Kind) {}
8484

clang/lib/AST/ComparisonCategories.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ bool ComparisonCategoryInfo::ValueInfo::hasValidIntValue() const {
4848

4949
// Before we attempt to get the value of the first field, ensure that we
5050
// actually have one (and only one) field.
51-
auto *Record = VD->getType()->getAsCXXRecordDecl();
51+
const auto *Record = VD->getType()->getAsCXXRecordDecl();
5252
if (std::distance(Record->field_begin(), Record->field_end()) != 1 ||
5353
!Record->field_begin()->getType()->isIntegralOrEnumerationType())
5454
return false;
@@ -98,13 +98,13 @@ static const NamespaceDecl *lookupStdNamespace(const ASTContext &Ctx,
9898
return StdNS;
9999
}
100100

101-
static CXXRecordDecl *lookupCXXRecordDecl(const ASTContext &Ctx,
102-
const NamespaceDecl *StdNS,
103-
ComparisonCategoryType Kind) {
101+
static const CXXRecordDecl *lookupCXXRecordDecl(const ASTContext &Ctx,
102+
const NamespaceDecl *StdNS,
103+
ComparisonCategoryType Kind) {
104104
StringRef Name = ComparisonCategories::getCategoryString(Kind);
105105
DeclContextLookupResult Lookup = StdNS->lookup(&Ctx.Idents.get(Name));
106106
if (!Lookup.empty())
107-
if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Lookup.front()))
107+
if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Lookup.front()))
108108
return RD;
109109
return nullptr;
110110
}
@@ -116,7 +116,7 @@ ComparisonCategories::lookupInfo(ComparisonCategoryType Kind) const {
116116
return &It->second;
117117

118118
if (const NamespaceDecl *NS = lookupStdNamespace(Ctx, StdNS))
119-
if (CXXRecordDecl *RD = lookupCXXRecordDecl(Ctx, NS, Kind))
119+
if (const CXXRecordDecl *RD = lookupCXXRecordDecl(Ctx, NS, Kind))
120120
return &Data.try_emplace((char)Kind, Ctx, RD, Kind).first->second;
121121

122122
return nullptr;
@@ -126,13 +126,13 @@ const ComparisonCategoryInfo *
126126
ComparisonCategories::lookupInfoForType(QualType Ty) const {
127127
assert(!Ty.isNull() && "type must be non-null");
128128
using CCT = ComparisonCategoryType;
129-
auto *RD = Ty->getAsCXXRecordDecl();
129+
const auto *RD = Ty->getAsCXXRecordDecl();
130130
if (!RD)
131131
return nullptr;
132132

133133
// Check to see if we have information for the specified type cached.
134134
const auto *CanonRD = RD->getCanonicalDecl();
135-
for (auto &KV : Data) {
135+
for (const auto &KV : Data) {
136136
const ComparisonCategoryInfo &Info = KV.second;
137137
if (CanonRD == Info.Record->getCanonicalDecl())
138138
return &Info;

0 commit comments

Comments
 (0)