Skip to content

Commit ed673aa

Browse files
committed
[clang][NFC] Convert Sema::OffsetOfKind to scoped enum
1 parent 8089c3d commit ed673aa

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class Parser : public CodeCompletionHandler {
374374
/// function call.
375375
bool CalledSignatureHelp = false;
376376

377-
Sema::OffsetOfKind OffsetOfState = Sema::OffsetOfKind::OOK_Outside;
377+
OffsetOfKind OffsetOfState = OffsetOfKind::Outside;
378378

379379
/// The "depth" of the template parameters currently being parsed.
380380
unsigned TemplateParameterDepth;

clang/include/clang/Parse/RAIIObjectsForParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ namespace clang {
361361
};
362362

363363
class OffsetOfStateRAIIObject {
364-
Sema::OffsetOfKind &OffsetOfState;
365-
Sema::OffsetOfKind OldValue;
364+
OffsetOfKind &OffsetOfState;
365+
OffsetOfKind OldValue;
366366

367367
public:
368-
OffsetOfStateRAIIObject(Parser &P, Sema::OffsetOfKind Value)
368+
OffsetOfStateRAIIObject(Parser &P, OffsetOfKind Value)
369369
: OffsetOfState(P.OffsetOfState), OldValue(P.OffsetOfState) {
370370
OffsetOfState = Value;
371371
}

clang/include/clang/Sema/Sema.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,16 @@ enum class NonTagKind {
609609
TemplateTemplateArgument,
610610
};
611611

612+
enum class OffsetOfKind {
613+
// Not parsing a type within __builtin_offsetof.
614+
Outside,
615+
// Parsing a type within __builtin_offsetof.
616+
Builtin,
617+
// Parsing a type within macro "offsetof", defined in __buitin_offsetof
618+
// To improve our diagnostic message.
619+
Macro,
620+
};
621+
612622
/// Sema - This implements semantic analysis and AST building for C.
613623
/// \nosubgrouping
614624
class Sema final : public SemaBase {
@@ -4001,16 +4011,6 @@ class Sema final : public SemaBase {
40014011
bool isDefinition, SourceLocation NewTagLoc,
40024012
const IdentifierInfo *Name);
40034013

4004-
enum OffsetOfKind {
4005-
// Not parsing a type within __builtin_offsetof.
4006-
OOK_Outside,
4007-
// Parsing a type within __builtin_offsetof.
4008-
OOK_Builtin,
4009-
// Parsing a type within macro "offsetof", defined in __buitin_offsetof
4010-
// To improve our diagnostic message.
4011-
OOK_Macro,
4012-
};
4013-
40144014
/// This is invoked when we see 'struct foo' or 'struct {'. In the
40154015
/// former case, Name will be non-null. In the later case, Name will be null.
40164016
/// TagSpec indicates what kind of tag this is. TUK indicates whether this is

clang/lib/Parse/ParseExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,12 +2796,12 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
27962796
}
27972797
case tok::kw___builtin_offsetof: {
27982798
SourceLocation TypeLoc = Tok.getLocation();
2799-
auto OOK = Sema::OffsetOfKind::OOK_Builtin;
2799+
auto OOK = OffsetOfKind::Builtin;
28002800
if (Tok.getLocation().isMacroID()) {
28012801
StringRef MacroName = Lexer::getImmediateMacroNameForDiagnostics(
28022802
Tok.getLocation(), PP.getSourceManager(), getLangOpts());
28032803
if (MacroName == "offsetof")
2804-
OOK = Sema::OffsetOfKind::OOK_Macro;
2804+
OOK = OffsetOfKind::Macro;
28052805
}
28062806
TypeResult Ty;
28072807
{

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18240,10 +18240,10 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1824018240
}
1824118241

1824218242
// Only C23 and later allow defining new types in 'offsetof()'.
18243-
if (OOK != OOK_Outside && TUK == TagUseKind::Definition &&
18243+
if (OOK != OffsetOfKind::Outside && TUK == TagUseKind::Definition &&
1824418244
!getLangOpts().CPlusPlus && !getLangOpts().C23)
1824518245
Diag(New->getLocation(), diag::ext_type_defined_in_offsetof)
18246-
<< (OOK == OOK_Macro) << New->getSourceRange();
18246+
<< (OOK == OffsetOfKind::Macro) << New->getSourceRange();
1824718247

1824818248
// C++11 [dcl.type]p3:
1824918249
// A type-specifier-seq shall not define a class or enumeration [...].

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18000,7 +18000,8 @@ DeclResult Sema::ActOnTemplatedFriendTag(
1800018000
/*ScopedEnumUsesClassTag=*/false,
1800118001
/*UnderlyingType=*/TypeResult(),
1800218002
/*IsTypeSpecifier=*/false,
18003-
/*IsTemplateParamOrArg=*/false, /*OOK=*/OOK_Outside);
18003+
/*IsTemplateParamOrArg=*/false,
18004+
/*OOK=*/OffsetOfKind::Outside);
1800418005
}
1800518006

1800618007
ElaboratedTypeKeyword Keyword

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10070,7 +10070,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
1007010070
Attr, AS_none, /*ModulePrivateLoc=*/SourceLocation(),
1007110071
MultiTemplateParamsArg(), Owned, IsDependent, SourceLocation(),
1007210072
false, TypeResult(), /*IsTypeSpecifier*/ false,
10073-
/*IsTemplateParamOrArg*/ false, /*OOK=*/OOK_Outside)
10073+
/*IsTemplateParamOrArg*/ false, /*OOK=*/OffsetOfKind::Outside)
1007410074
.get();
1007510075
assert(!IsDependent && "explicit instantiation of dependent name not yet handled");
1007610076

0 commit comments

Comments
 (0)