Skip to content

Commit 7e3080f

Browse files
authored
[clang] Mark OverloadCandidateSet::OperatorRewriteInfo methods as const (#162271)
They don't mutate the object and this makes them easier to use and allows better const correctness when using Clang as a library.
1 parent 95144b1 commit 7e3080f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clang/include/clang/Sema/Overload.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,12 +1202,12 @@ class Sema;
12021202

12031203
/// Would use of this function result in a rewrite using a different
12041204
/// operator?
1205-
bool isRewrittenOperator(const FunctionDecl *FD) {
1205+
bool isRewrittenOperator(const FunctionDecl *FD) const {
12061206
return OriginalOperator &&
12071207
FD->getDeclName().getCXXOverloadedOperator() != OriginalOperator;
12081208
}
12091209

1210-
bool isAcceptableCandidate(const FunctionDecl *FD) {
1210+
bool isAcceptableCandidate(const FunctionDecl *FD) const {
12111211
if (!OriginalOperator)
12121212
return true;
12131213

@@ -1234,21 +1234,21 @@ class Sema;
12341234
}
12351235
/// Determines whether this operator could be implemented by a function
12361236
/// with reversed parameter order.
1237-
bool isReversible() {
1237+
bool isReversible() const {
12381238
return AllowRewrittenCandidates && OriginalOperator &&
12391239
(getRewrittenOverloadedOperator(OriginalOperator) != OO_None ||
12401240
allowsReversed(OriginalOperator));
12411241
}
12421242

12431243
/// Determine whether reversing parameter order is allowed for operator
12441244
/// Op.
1245-
bool allowsReversed(OverloadedOperatorKind Op);
1245+
bool allowsReversed(OverloadedOperatorKind Op) const;
12461246

12471247
/// Determine whether we should add a rewritten candidate for \p FD with
12481248
/// reversed parameter order.
12491249
/// \param OriginalArgs are the original non reversed arguments.
12501250
bool shouldAddReversed(Sema &S, ArrayRef<Expr *> OriginalArgs,
1251-
FunctionDecl *FD);
1251+
FunctionDecl *FD) const;
12521252
};
12531253

12541254
private:

clang/lib/Sema/SemaOverload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,14 +1087,14 @@ static bool shouldAddReversedEqEq(Sema &S, SourceLocation OpLoc,
10871087
}
10881088

10891089
bool OverloadCandidateSet::OperatorRewriteInfo::allowsReversed(
1090-
OverloadedOperatorKind Op) {
1090+
OverloadedOperatorKind Op) const {
10911091
if (!AllowRewrittenCandidates)
10921092
return false;
10931093
return Op == OO_EqualEqual || Op == OO_Spaceship;
10941094
}
10951095

10961096
bool OverloadCandidateSet::OperatorRewriteInfo::shouldAddReversed(
1097-
Sema &S, ArrayRef<Expr *> OriginalArgs, FunctionDecl *FD) {
1097+
Sema &S, ArrayRef<Expr *> OriginalArgs, FunctionDecl *FD) const {
10981098
auto Op = FD->getOverloadedOperator();
10991099
if (!allowsReversed(Op))
11001100
return false;

0 commit comments

Comments
 (0)