aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorVlad Serebrennikov <serebrennikov.vladislav@gmail.com>2025-04-30 02:23:12 +0300
committerVlad Serebrennikov <serebrennikov.vladislav@gmail.com>2025-04-30 02:23:39 +0300
commit4595e8092ed5ce69b3ce33e989d7bea3a25fc289 (patch)
treec10663abb68789137e32583167e3dfa703935464 /clang/lib
parent951292be2c21bc903e63729338d872a878d2d49c (diff)
downloadllvm-4595e8092ed5ce69b3ce33e989d7bea3a25fc289.zip
llvm-4595e8092ed5ce69b3ce33e989d7bea3a25fc289.tar.gz
llvm-4595e8092ed5ce69b3ce33e989d7bea3a25fc289.tar.bz2
[clang][NFC] Convert `Parser::AnnotatedNameKind` to scoped enum
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp2
-rw-r--r--clang/lib/Parse/ParseTentative.cpp20
-rw-r--r--clang/lib/Parse/Parser.cpp35
3 files changed, 29 insertions, 28 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 4e801f4..f50a245 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -216,7 +216,7 @@ Retry:
// Try to limit which sets of keywords should be included in typo
// correction based on what the next token is.
StatementFilterCCC CCC(Next);
- if (TryAnnotateName(&CCC) == ANK_Error) {
+ if (TryAnnotateName(&CCC) == AnnotatedNameKind::Error) {
// Handle errors here by skipping up to the next semicolon or '}', and
// eat the semicolon if that's what stopped us.
SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index ff27ef7..0994ff1 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1401,11 +1401,11 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
// to types and identifiers, in order to try to recover from errors.
TentativeParseCCC CCC(Next);
switch (TryAnnotateName(&CCC)) {
- case ANK_Error:
+ case AnnotatedNameKind::Error:
return TPResult::Error;
- case ANK_TentativeDecl:
+ case AnnotatedNameKind::TentativeDecl:
return TPResult::False;
- case ANK_TemplateName:
+ case AnnotatedNameKind::TemplateName:
// In C++17, this could be a type template for class template argument
// deduction. Try to form a type annotation for it. If we're in a
// template template argument, we'll undo this when checking the
@@ -1420,9 +1420,9 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
// A bare type template-name which can't be a template template
// argument is an error, and was probably intended to be a type.
return GreaterThanIsOperator ? TPResult::True : TPResult::False;
- case ANK_Unresolved:
+ case AnnotatedNameKind::Unresolved:
return InvalidAsDeclSpec ? TPResult::Ambiguous : TPResult::False;
- case ANK_Success:
+ case AnnotatedNameKind::Success:
break;
}
assert(Tok.isNot(tok::identifier) &&
@@ -1694,11 +1694,11 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
// Try to resolve the name. If it doesn't exist, assume it was
// intended to name a type and keep disambiguating.
switch (TryAnnotateName(/*CCC=*/nullptr, AllowImplicitTypename)) {
- case ANK_Error:
+ case AnnotatedNameKind::Error:
return TPResult::Error;
- case ANK_TentativeDecl:
+ case AnnotatedNameKind::TentativeDecl:
return TPResult::False;
- case ANK_TemplateName:
+ case AnnotatedNameKind::TemplateName:
// In C++17, this could be a type template for class template
// argument deduction.
if (getLangOpts().CPlusPlus17) {
@@ -1717,9 +1717,9 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
return (getLangOpts().CPlusPlus17 || GreaterThanIsOperator)
? TPResult::True
: TPResult::False;
- case ANK_Unresolved:
+ case AnnotatedNameKind::Unresolved:
return InvalidAsDeclSpec ? TPResult::Ambiguous : TPResult::False;
- case ANK_Success:
+ case AnnotatedNameKind::Success:
break;
}
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index a82aea1..0954c31 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -1802,7 +1802,7 @@ void Parser::AnnotateScopeToken(CXXScopeSpec &SS, bool IsNewAnnotation) {
/// \param AllowImplicitTypename Whether we are in a context where a dependent
/// nested-name-specifier without typename is treated as a type (e.g.
/// T::type).
-Parser::AnnotatedNameKind
+AnnotatedNameKind
Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
ImplicitTypenameContext AllowImplicitTypename) {
assert(Tok.is(tok::identifier) || Tok.is(tok::annot_cxxscope));
@@ -1815,13 +1815,13 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,
/*ObjectHasErrors=*/false,
EnteringContext))
- return ANK_Error;
+ return AnnotatedNameKind::Error;
if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
if (TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation,
AllowImplicitTypename))
- return ANK_Error;
- return ANK_Unresolved;
+ return AnnotatedNameKind::Error;
+ return AnnotatedNameKind::Unresolved;
}
IdentifierInfo *Name = Tok.getIdentifierInfo();
@@ -1834,8 +1834,9 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
// an expression. Fall back to annotating it as a type.
if (TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation,
AllowImplicitTypename))
- return ANK_Error;
- return Tok.is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl;
+ return AnnotatedNameKind::Error;
+ return Tok.is(tok::annot_typename) ? AnnotatedNameKind::Success
+ : AnnotatedNameKind::TentativeDecl;
}
Token Next = NextToken();
@@ -1863,7 +1864,7 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
switch (Classification.getKind()) {
case Sema::NC_Error:
- return ANK_Error;
+ return AnnotatedNameKind::Error;
case Sema::NC_Keyword:
// The identifier was typo-corrected to a keyword.
@@ -1873,7 +1874,7 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
if (SS.isNotEmpty())
AnnotateScopeToken(SS, !WasScopeAnnotation);
// We've "annotated" this as a keyword.
- return ANK_Success;
+ return AnnotatedNameKind::Success;
case Sema::NC_Unknown:
// It's not something we know about. Leave it unannotated.
@@ -1905,7 +1906,7 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
if (NewType.isUsable())
Ty = NewType.get();
else if (Tok.is(tok::eof)) // Nothing to do here, bail out...
- return ANK_Error;
+ return AnnotatedNameKind::Error;
}
Tok.setKind(tok::annot_typename);
@@ -1913,7 +1914,7 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
Tok.setAnnotationEndLoc(Tok.getLocation());
Tok.setLocation(BeginLoc);
PP.AnnotateCachedTokens(Tok);
- return ANK_Success;
+ return AnnotatedNameKind::Success;
}
case Sema::NC_OverloadSet:
@@ -1923,7 +1924,7 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
if (SS.isNotEmpty())
Tok.setLocation(SS.getBeginLoc());
PP.AnnotateCachedTokens(Tok);
- return ANK_Success;
+ return AnnotatedNameKind::Success;
case Sema::NC_NonType:
if (TryAltiVecVectorToken())
@@ -1938,7 +1939,7 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
PP.AnnotateCachedTokens(Tok);
if (SS.isNotEmpty())
AnnotateScopeToken(SS, !WasScopeAnnotation);
- return ANK_Success;
+ return AnnotatedNameKind::Success;
case Sema::NC_UndeclaredNonType:
case Sema::NC_DependentNonType:
@@ -1951,14 +1952,14 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
PP.AnnotateCachedTokens(Tok);
if (SS.isNotEmpty())
AnnotateScopeToken(SS, !WasScopeAnnotation);
- return ANK_Success;
+ return AnnotatedNameKind::Success;
case Sema::NC_TypeTemplate:
if (Next.isNot(tok::less)) {
// This may be a type template being used as a template template argument.
if (SS.isNotEmpty())
AnnotateScopeToken(SS, !WasScopeAnnotation);
- return ANK_TemplateName;
+ return AnnotatedNameKind::TemplateName;
}
[[fallthrough]];
case Sema::NC_Concept:
@@ -1977,17 +1978,17 @@ Parser::TryAnnotateName(CorrectionCandidateCallback *CCC,
Classification.getTemplateNameKind(), SS, SourceLocation(), Id,
/*AllowTypeAnnotation=*/!IsConceptName,
/*TypeConstraint=*/IsConceptName))
- return ANK_Error;
+ return AnnotatedNameKind::Error;
if (SS.isNotEmpty())
AnnotateScopeToken(SS, !WasScopeAnnotation);
- return ANK_Success;
+ return AnnotatedNameKind::Success;
}
}
// Unable to classify the name, but maybe we can annotate a scope specifier.
if (SS.isNotEmpty())
AnnotateScopeToken(SS, !WasScopeAnnotation);
- return ANK_Unresolved;
+ return AnnotatedNameKind::Unresolved;
}
bool Parser::TryKeywordIdentFallback(bool DisableKeyword) {