@@ -528,6 +528,47 @@ enum class BuiltinCountedByRefKind {
528528 BinaryExpr,
529529};
530530
531+ /// Describes the result of the name lookup and resolution performed
532+ /// by \c Sema::ClassifyName().
533+ enum class NameClassificationKind {
534+ /// This name is not a type or template in this context, but might be
535+ /// something else.
536+ Unknown,
537+ /// Classification failed; an error has been produced.
538+ Error,
539+ /// The name has been typo-corrected to a keyword.
540+ Keyword,
541+ /// The name was classified as a type.
542+ Type,
543+ /// The name was classified as a specific non-type, non-template
544+ /// declaration. ActOnNameClassifiedAsNonType should be called to
545+ /// convert the declaration to an expression.
546+ NonType,
547+ /// The name was classified as an ADL-only function name.
548+ /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
549+ /// result to an expression.
550+ UndeclaredNonType,
551+ /// The name denotes a member of a dependent type that could not be
552+ /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
553+ /// convert the result to an expression.
554+ DependentNonType,
555+ /// The name was classified as an overload set, and an expression
556+ /// representing that overload set has been formed.
557+ /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
558+ /// expression referencing the overload set.
559+ OverloadSet,
560+ /// The name was classified as a template whose specializations are types.
561+ TypeTemplate,
562+ /// The name was classified as a variable template name.
563+ VarTemplate,
564+ /// The name was classified as a function template name.
565+ FunctionTemplate,
566+ /// The name was classified as an ADL-only function template name.
567+ UndeclaredTemplate,
568+ /// The name was classified as a concept name.
569+ Concept,
570+ };
571+
531572/// Sema - This implements semantic analysis and AST building for C.
532573/// \nosubgrouping
533574class Sema final : public SemaBase {
@@ -3290,47 +3331,6 @@ class Sema final : public SemaBase {
32903331 SourceLocation NameLoc,
32913332 bool IsTemplateTypeArg);
32923333
3293- /// Describes the result of the name lookup and resolution performed
3294- /// by \c ClassifyName().
3295- enum NameClassificationKind {
3296- /// This name is not a type or template in this context, but might be
3297- /// something else.
3298- NC_Unknown,
3299- /// Classification failed; an error has been produced.
3300- NC_Error,
3301- /// The name has been typo-corrected to a keyword.
3302- NC_Keyword,
3303- /// The name was classified as a type.
3304- NC_Type,
3305- /// The name was classified as a specific non-type, non-template
3306- /// declaration. ActOnNameClassifiedAsNonType should be called to
3307- /// convert the declaration to an expression.
3308- NC_NonType,
3309- /// The name was classified as an ADL-only function name.
3310- /// ActOnNameClassifiedAsUndeclaredNonType should be called to convert the
3311- /// result to an expression.
3312- NC_UndeclaredNonType,
3313- /// The name denotes a member of a dependent type that could not be
3314- /// resolved. ActOnNameClassifiedAsDependentNonType should be called to
3315- /// convert the result to an expression.
3316- NC_DependentNonType,
3317- /// The name was classified as an overload set, and an expression
3318- /// representing that overload set has been formed.
3319- /// ActOnNameClassifiedAsOverloadSet should be called to form a suitable
3320- /// expression referencing the overload set.
3321- NC_OverloadSet,
3322- /// The name was classified as a template whose specializations are types.
3323- NC_TypeTemplate,
3324- /// The name was classified as a variable template name.
3325- NC_VarTemplate,
3326- /// The name was classified as a function template name.
3327- NC_FunctionTemplate,
3328- /// The name was classified as an ADL-only function template name.
3329- NC_UndeclaredTemplate,
3330- /// The name was classified as a concept name.
3331- NC_Concept,
3332- };
3333-
33343334 class NameClassification {
33353335 NameClassificationKind Kind;
33363336 union {
@@ -3343,101 +3343,107 @@ class Sema final : public SemaBase {
33433343 explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
33443344
33453345 public:
3346- NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
3346+ NameClassification(ParsedType Type)
3347+ : Kind(NameClassificationKind::Type), Type(Type) {}
33473348
3348- NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3349+ NameClassification(const IdentifierInfo *Keyword)
3350+ : Kind(NameClassificationKind::Keyword) {}
33493351
3350- static NameClassification Error() { return NameClassification(NC_Error); }
3352+ static NameClassification Error() {
3353+ return NameClassification(NameClassificationKind::Error);
3354+ }
33513355
33523356 static NameClassification Unknown() {
3353- return NameClassification(NC_Unknown );
3357+ return NameClassification(NameClassificationKind::Unknown );
33543358 }
33553359
33563360 static NameClassification OverloadSet(ExprResult E) {
3357- NameClassification Result(NC_OverloadSet );
3361+ NameClassification Result(NameClassificationKind::OverloadSet );
33583362 Result.Expr = E;
33593363 return Result;
33603364 }
33613365
33623366 static NameClassification NonType(NamedDecl *D) {
3363- NameClassification Result(NC_NonType );
3367+ NameClassification Result(NameClassificationKind::NonType );
33643368 Result.NonTypeDecl = D;
33653369 return Result;
33663370 }
33673371
33683372 static NameClassification UndeclaredNonType() {
3369- return NameClassification(NC_UndeclaredNonType );
3373+ return NameClassification(NameClassificationKind::UndeclaredNonType );
33703374 }
33713375
33723376 static NameClassification DependentNonType() {
3373- return NameClassification(NC_DependentNonType );
3377+ return NameClassification(NameClassificationKind::DependentNonType );
33743378 }
33753379
33763380 static NameClassification TypeTemplate(TemplateName Name) {
3377- NameClassification Result(NC_TypeTemplate );
3381+ NameClassification Result(NameClassificationKind::TypeTemplate );
33783382 Result.Template = Name;
33793383 return Result;
33803384 }
33813385
33823386 static NameClassification VarTemplate(TemplateName Name) {
3383- NameClassification Result(NC_VarTemplate );
3387+ NameClassification Result(NameClassificationKind::VarTemplate );
33843388 Result.Template = Name;
33853389 return Result;
33863390 }
33873391
33883392 static NameClassification FunctionTemplate(TemplateName Name) {
3389- NameClassification Result(NC_FunctionTemplate );
3393+ NameClassification Result(NameClassificationKind::FunctionTemplate );
33903394 Result.Template = Name;
33913395 return Result;
33923396 }
33933397
33943398 static NameClassification Concept(TemplateName Name) {
3395- NameClassification Result(NC_Concept );
3399+ NameClassification Result(NameClassificationKind::Concept );
33963400 Result.Template = Name;
33973401 return Result;
33983402 }
33993403
34003404 static NameClassification UndeclaredTemplate(TemplateName Name) {
3401- NameClassification Result(NC_UndeclaredTemplate );
3405+ NameClassification Result(NameClassificationKind::UndeclaredTemplate );
34023406 Result.Template = Name;
34033407 return Result;
34043408 }
34053409
34063410 NameClassificationKind getKind() const { return Kind; }
34073411
34083412 ExprResult getExpression() const {
3409- assert(Kind == NC_OverloadSet );
3413+ assert(Kind == NameClassificationKind::OverloadSet );
34103414 return Expr;
34113415 }
34123416
34133417 ParsedType getType() const {
3414- assert(Kind == NC_Type );
3418+ assert(Kind == NameClassificationKind::Type );
34153419 return Type;
34163420 }
34173421
34183422 NamedDecl *getNonTypeDecl() const {
3419- assert(Kind == NC_NonType );
3423+ assert(Kind == NameClassificationKind::NonType );
34203424 return NonTypeDecl;
34213425 }
34223426
34233427 TemplateName getTemplateName() const {
3424- assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate ||
3425- Kind == NC_VarTemplate || Kind == NC_Concept ||
3426- Kind == NC_UndeclaredTemplate);
3428+ assert(Kind == NameClassificationKind::TypeTemplate ||
3429+ Kind == NameClassificationKind::FunctionTemplate ||
3430+ Kind == NameClassificationKind::VarTemplate ||
3431+ Kind == NameClassificationKind::Concept ||
3432+ Kind == NameClassificationKind::UndeclaredTemplate);
34273433 return Template;
34283434 }
34293435
34303436 TemplateNameKind getTemplateNameKind() const {
34313437 switch (Kind) {
3432- case NC_TypeTemplate :
3438+ case NameClassificationKind::TypeTemplate :
34333439 return TNK_Type_template;
3434- case NC_FunctionTemplate :
3440+ case NameClassificationKind::FunctionTemplate :
34353441 return TNK_Function_template;
3436- case NC_VarTemplate :
3442+ case NameClassificationKind::VarTemplate :
34373443 return TNK_Var_template;
3438- case NC_Concept :
3444+ case NameClassificationKind::Concept :
34393445 return TNK_Concept_template;
3440- case NC_UndeclaredTemplate :
3446+ case NameClassificationKind::UndeclaredTemplate :
34413447 return TNK_Undeclared_template;
34423448 default:
34433449 llvm_unreachable("unsupported name classification.");
0 commit comments