Skip to content

Commit 6e63b68

Browse files
committed
[clang][NFC] Convert Sema::OverloadKind to scoped enum
1 parent 083b4a3 commit 6e63b68

File tree

4 files changed

+41
-40
lines changed

4 files changed

+41
-40
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,20 @@ enum class CorrectTypoKind {
804804
ErrorRecovery // CorrectTypo used in normal error recovery.
805805
};
806806

807+
enum class OverloadKind {
808+
/// This is a legitimate overload: the existing declarations are
809+
/// functions or function templates with different signatures.
810+
Overload,
811+
812+
/// This is not an overload because the signature exactly matches
813+
/// an existing declaration.
814+
Match,
815+
816+
/// This is not an overload because the lookup results contain a
817+
/// non-function.
818+
NonFunction
819+
};
820+
807821
/// Sema - This implements semantic analysis and AST building for C.
808822
/// \nosubgrouping
809823
class Sema final : public SemaBase {
@@ -9987,28 +10001,14 @@ class Sema final : public SemaBase {
998710001
/// if Sema is already doing so, which would cause infinite recursions.
998810002
bool IsBuildingRecoveryCallExpr;
998910003

9990-
enum OverloadKind {
9991-
/// This is a legitimate overload: the existing declarations are
9992-
/// functions or function templates with different signatures.
9993-
Ovl_Overload,
9994-
9995-
/// This is not an overload because the signature exactly matches
9996-
/// an existing declaration.
9997-
Ovl_Match,
9998-
9999-
/// This is not an overload because the lookup results contain a
10000-
/// non-function.
10001-
Ovl_NonFunction
10002-
};
10003-
1000410004
/// Determine whether the given New declaration is an overload of the
10005-
/// declarations in Old. This routine returns Ovl_Match or Ovl_NonFunction if
10006-
/// New and Old cannot be overloaded, e.g., if New has the same signature as
10007-
/// some function in Old (C++ 1.3.10) or if the Old declarations aren't
10008-
/// functions (or function templates) at all. When it does return Ovl_Match or
10009-
/// Ovl_NonFunction, MatchedDecl will point to the decl that New cannot be
10010-
/// overloaded with. This decl may be a UsingShadowDecl on top of the
10011-
/// underlying declaration.
10005+
/// declarations in Old. This routine returns OverloadKind::Match or
10006+
/// OverloadKind::NonFunction if New and Old cannot be overloaded, e.g., if
10007+
/// New has the same signature as some function in Old (C++ 1.3.10) or if the
10008+
/// Old declarations aren't functions (or function templates) at all. When it
10009+
/// does return OverloadKind::Match or OverloadKind::NonFunction, MatchedDecl
10010+
/// will point to the decl that New cannot be overloaded with. This decl may
10011+
/// be a UsingShadowDecl on top of the underlying declaration.
1001210012
///
1001310013
/// Example: Given the following input:
1001410014
///
@@ -10021,14 +10021,15 @@ class Sema final : public SemaBase {
1002110021
///
1002210022
/// When we process #2, Old contains only the FunctionDecl for #1. By
1002310023
/// comparing the parameter types, we see that #1 and #2 are overloaded (since
10024-
/// they have different signatures), so this routine returns Ovl_Overload;
10025-
/// MatchedDecl is unchanged.
10024+
/// they have different signatures), so this routine returns
10025+
/// OverloadKind::Overload; MatchedDecl is unchanged.
1002610026
///
1002710027
/// When we process #3, Old is an overload set containing #1 and #2. We
1002810028
/// compare the signatures of #3 to #1 (they're overloaded, so we do nothing)
1002910029
/// and then #3 to #2. Since the signatures of #3 and #2 are identical (return
1003010030
/// types of functions are not part of the signature), IsOverload returns
10031-
/// Ovl_Match and MatchedDecl will be set to point to the FunctionDecl for #2.
10031+
/// OverloadKind::Match and MatchedDecl will be set to point to the
10032+
/// FunctionDecl for #2.
1003210033
///
1003310034
/// 'NewIsUsingShadowDecl' indicates that 'New' is being introduced into a
1003410035
/// class by a using declaration. The rules for whether to hide shadow

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12032,15 +12032,15 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
1203212032
MayNeedOverloadableChecks = true;
1203312033
switch (CheckOverload(S, NewFD, Previous, OldDecl,
1203412034
/*NewIsUsingDecl*/ false)) {
12035-
case Ovl_Match:
12035+
case OverloadKind::Match:
1203612036
Redeclaration = true;
1203712037
break;
1203812038

12039-
case Ovl_NonFunction:
12039+
case OverloadKind::NonFunction:
1204012040
Redeclaration = true;
1204112041
break;
1204212042

12043-
case Ovl_Overload:
12043+
case OverloadKind::Overload:
1204412044
Redeclaration = false;
1204512045
break;
1204612046
}

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12797,15 +12797,15 @@ bool Sema::CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Orig,
1279712797
NamedDecl *OldDecl = nullptr;
1279812798
switch (CheckOverload(nullptr, FD, Previous, OldDecl,
1279912799
/*IsForUsingDecl*/ true)) {
12800-
case Ovl_Overload:
12800+
case OverloadKind::Overload:
1280112801
return false;
1280212802

12803-
case Ovl_NonFunction:
12803+
case OverloadKind::NonFunction:
1280412804
Diag(BUD->getLocation(), diag::err_using_decl_conflict);
1280512805
break;
1280612806

1280712807
// We found a decl with the exact signature.
12808-
case Ovl_Match:
12808+
case OverloadKind::Match:
1280912809
// If we're in a record, we want to hide the target, so we
1281012810
// return true (without a diagnostic) to tell the caller not to
1281112811
// build a shadow decl.

clang/lib/Sema/SemaOverload.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,9 +1200,9 @@ static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args,
12001200
return false;
12011201
}
12021202

1203-
Sema::OverloadKind
1204-
Sema::CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &Old,
1205-
NamedDecl *&Match, bool NewIsUsingDecl) {
1203+
OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
1204+
const LookupResult &Old, NamedDecl *&Match,
1205+
bool NewIsUsingDecl) {
12061206
for (LookupResult::iterator I = Old.begin(), E = Old.end();
12071207
I != E; ++I) {
12081208
NamedDecl *OldD = *I;
@@ -1244,14 +1244,14 @@ Sema::CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &Old,
12441244
continue;
12451245

12461246
Match = *I;
1247-
return Ovl_Match;
1247+
return OverloadKind::Match;
12481248
}
12491249

12501250
// Builtins that have custom typechecking or have a reference should
12511251
// not be overloadable or redeclarable.
12521252
if (!getASTContext().canBuiltinBeRedeclared(OldF)) {
12531253
Match = *I;
1254-
return Ovl_NonFunction;
1254+
return OverloadKind::NonFunction;
12551255
}
12561256
} else if (isa<UsingDecl>(OldD) || isa<UsingPackDecl>(OldD)) {
12571257
// We can overload with these, which can show up when doing
@@ -1268,14 +1268,14 @@ Sema::CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &Old,
12681268
// member, the using declaration can only introduce an enumerator.
12691269
if (UUD->getQualifier()->isDependent() && !UUD->isCXXClassMember()) {
12701270
Match = *I;
1271-
return Ovl_NonFunction;
1271+
return OverloadKind::NonFunction;
12721272
}
12731273
} else {
12741274
// (C++ 13p1):
12751275
// Only function declarations can be overloaded; object and type
12761276
// declarations cannot be overloaded.
12771277
Match = *I;
1278-
return Ovl_NonFunction;
1278+
return OverloadKind::NonFunction;
12791279
}
12801280
}
12811281

@@ -1303,14 +1303,14 @@ Sema::CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &Old,
13031303
if (CheckFunctionTemplateSpecialization(New, nullptr, TemplateSpecResult,
13041304
/*QualifiedFriend*/true)) {
13051305
New->setInvalidDecl();
1306-
return Ovl_Overload;
1306+
return OverloadKind::Overload;
13071307
}
13081308

13091309
Match = TemplateSpecResult.getAsSingle<FunctionDecl>();
1310-
return Ovl_Match;
1310+
return OverloadKind::Match;
13111311
}
13121312

1313-
return Ovl_Overload;
1313+
return OverloadKind::Overload;
13141314
}
13151315

13161316
template <typename AttrT> static bool hasExplicitAttr(const FunctionDecl *D) {

0 commit comments

Comments
 (0)