@@ -528,6 +528,47 @@ enum class BuiltinCountedByRefKind {
528
528
BinaryExpr,
529
529
};
530
530
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
+
531
572
/// Sema - This implements semantic analysis and AST building for C.
532
573
/// \nosubgrouping
533
574
class Sema final : public SemaBase {
@@ -3290,47 +3331,6 @@ class Sema final : public SemaBase {
3290
3331
SourceLocation NameLoc,
3291
3332
bool IsTemplateTypeArg);
3292
3333
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
-
3334
3334
class NameClassification {
3335
3335
NameClassificationKind Kind;
3336
3336
union {
@@ -3343,101 +3343,107 @@ class Sema final : public SemaBase {
3343
3343
explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {}
3344
3344
3345
3345
public:
3346
- NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {}
3346
+ NameClassification(ParsedType Type)
3347
+ : Kind(NameClassificationKind::Type), Type(Type) {}
3347
3348
3348
- NameClassification(const IdentifierInfo *Keyword) : Kind(NC_Keyword) {}
3349
+ NameClassification(const IdentifierInfo *Keyword)
3350
+ : Kind(NameClassificationKind::Keyword) {}
3349
3351
3350
- static NameClassification Error() { return NameClassification(NC_Error); }
3352
+ static NameClassification Error() {
3353
+ return NameClassification(NameClassificationKind::Error);
3354
+ }
3351
3355
3352
3356
static NameClassification Unknown() {
3353
- return NameClassification(NC_Unknown );
3357
+ return NameClassification(NameClassificationKind::Unknown );
3354
3358
}
3355
3359
3356
3360
static NameClassification OverloadSet(ExprResult E) {
3357
- NameClassification Result(NC_OverloadSet );
3361
+ NameClassification Result(NameClassificationKind::OverloadSet );
3358
3362
Result.Expr = E;
3359
3363
return Result;
3360
3364
}
3361
3365
3362
3366
static NameClassification NonType(NamedDecl *D) {
3363
- NameClassification Result(NC_NonType );
3367
+ NameClassification Result(NameClassificationKind::NonType );
3364
3368
Result.NonTypeDecl = D;
3365
3369
return Result;
3366
3370
}
3367
3371
3368
3372
static NameClassification UndeclaredNonType() {
3369
- return NameClassification(NC_UndeclaredNonType );
3373
+ return NameClassification(NameClassificationKind::UndeclaredNonType );
3370
3374
}
3371
3375
3372
3376
static NameClassification DependentNonType() {
3373
- return NameClassification(NC_DependentNonType );
3377
+ return NameClassification(NameClassificationKind::DependentNonType );
3374
3378
}
3375
3379
3376
3380
static NameClassification TypeTemplate(TemplateName Name) {
3377
- NameClassification Result(NC_TypeTemplate );
3381
+ NameClassification Result(NameClassificationKind::TypeTemplate );
3378
3382
Result.Template = Name;
3379
3383
return Result;
3380
3384
}
3381
3385
3382
3386
static NameClassification VarTemplate(TemplateName Name) {
3383
- NameClassification Result(NC_VarTemplate );
3387
+ NameClassification Result(NameClassificationKind::VarTemplate );
3384
3388
Result.Template = Name;
3385
3389
return Result;
3386
3390
}
3387
3391
3388
3392
static NameClassification FunctionTemplate(TemplateName Name) {
3389
- NameClassification Result(NC_FunctionTemplate );
3393
+ NameClassification Result(NameClassificationKind::FunctionTemplate );
3390
3394
Result.Template = Name;
3391
3395
return Result;
3392
3396
}
3393
3397
3394
3398
static NameClassification Concept(TemplateName Name) {
3395
- NameClassification Result(NC_Concept );
3399
+ NameClassification Result(NameClassificationKind::Concept );
3396
3400
Result.Template = Name;
3397
3401
return Result;
3398
3402
}
3399
3403
3400
3404
static NameClassification UndeclaredTemplate(TemplateName Name) {
3401
- NameClassification Result(NC_UndeclaredTemplate );
3405
+ NameClassification Result(NameClassificationKind::UndeclaredTemplate );
3402
3406
Result.Template = Name;
3403
3407
return Result;
3404
3408
}
3405
3409
3406
3410
NameClassificationKind getKind() const { return Kind; }
3407
3411
3408
3412
ExprResult getExpression() const {
3409
- assert(Kind == NC_OverloadSet );
3413
+ assert(Kind == NameClassificationKind::OverloadSet );
3410
3414
return Expr;
3411
3415
}
3412
3416
3413
3417
ParsedType getType() const {
3414
- assert(Kind == NC_Type );
3418
+ assert(Kind == NameClassificationKind::Type );
3415
3419
return Type;
3416
3420
}
3417
3421
3418
3422
NamedDecl *getNonTypeDecl() const {
3419
- assert(Kind == NC_NonType );
3423
+ assert(Kind == NameClassificationKind::NonType );
3420
3424
return NonTypeDecl;
3421
3425
}
3422
3426
3423
3427
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);
3427
3433
return Template;
3428
3434
}
3429
3435
3430
3436
TemplateNameKind getTemplateNameKind() const {
3431
3437
switch (Kind) {
3432
- case NC_TypeTemplate :
3438
+ case NameClassificationKind::TypeTemplate :
3433
3439
return TNK_Type_template;
3434
- case NC_FunctionTemplate :
3440
+ case NameClassificationKind::FunctionTemplate :
3435
3441
return TNK_Function_template;
3436
- case NC_VarTemplate :
3442
+ case NameClassificationKind::VarTemplate :
3437
3443
return TNK_Var_template;
3438
- case NC_Concept :
3444
+ case NameClassificationKind::Concept :
3439
3445
return TNK_Concept_template;
3440
- case NC_UndeclaredTemplate :
3446
+ case NameClassificationKind::UndeclaredTemplate :
3441
3447
return TNK_Undeclared_template;
3442
3448
default:
3443
3449
llvm_unreachable("unsupported name classification.");
0 commit comments