Skip to content

Commit 7ecd81e

Browse files
committed
[clang][NFC] Convert Parser::ExtraSemiKind to scoped enum
1 parent 4595e80 commit 7ecd81e

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ enum class AnnotatedNameKind {
6464
Success
6565
};
6666

67+
/// The kind of extra semi diagnostic to emit.
68+
enum class ExtraSemiKind {
69+
OutsideFunction = 0,
70+
InsideStruct = 1,
71+
InstanceVariableList = 2,
72+
AfterMemberFunctionDefinition = 3
73+
};
74+
6775
/// Parser - This implements a parser for the C family of languages. After
6876
/// parsing units of the grammar, productions are invoked to handle whatever has
6977
/// been read.
@@ -1120,14 +1128,6 @@ class Parser : public CodeCompletionHandler {
11201128
/// to the semicolon, consumes that extra token.
11211129
bool ExpectAndConsumeSemi(unsigned DiagID , StringRef TokenUsed = "");
11221130

1123-
/// The kind of extra semi diagnostic to emit.
1124-
enum ExtraSemiKind {
1125-
OutsideFunction = 0,
1126-
InsideStruct = 1,
1127-
InstanceVariableList = 2,
1128-
AfterMemberFunctionDefinition = 3
1129-
};
1130-
11311131
/// Consume any extra semi-colons until the end of the line.
11321132
void ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST T = TST_unspecified);
11331133

clang/lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5187,7 +5187,7 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
51875187

51885188
// Check for extraneous top-level semicolon.
51895189
if (Tok.is(tok::semi)) {
5190-
ConsumeExtraSemi(InsideStruct, TagType);
5190+
ConsumeExtraSemi(ExtraSemiKind::InsideStruct, TagType);
51915191
continue;
51925192
}
51935193

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,7 +3295,7 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclaration(
32953295

32963296
// Consume the ';' - it's optional unless we have a delete or default
32973297
if (Tok.is(tok::semi))
3298-
ConsumeExtraSemi(AfterMemberFunctionDefinition);
3298+
ConsumeExtraSemi(ExtraSemiKind::AfterMemberFunctionDefinition);
32993299

33003300
return DeclGroupPtrTy::make(DeclGroupRef(FunDecl));
33013301
}
@@ -3649,7 +3649,7 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas(
36493649

36503650
case tok::semi:
36513651
// Check for extraneous top-level semicolon.
3652-
ConsumeExtraSemi(InsideStruct, TagType);
3652+
ConsumeExtraSemi(ExtraSemiKind::InsideStruct, TagType);
36533653
return nullptr;
36543654

36553655
// Handle pragmas that can appear as member declarations.
@@ -5313,7 +5313,7 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration(
53135313

53145314
// Check for extraneous top-level semicolon.
53155315
if (Tok.is(tok::semi)) {
5316-
ConsumeExtraSemi(InsideStruct, TagType);
5316+
ConsumeExtraSemi(ExtraSemiKind::InsideStruct, TagType);
53175317
continue;
53185318
}
53195319

clang/lib/Parse/ParseObjc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ void Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
19721972

19731973
// Check for extraneous top-level semicolon.
19741974
if (Tok.is(tok::semi)) {
1975-
ConsumeExtraSemi(InstanceVariableList);
1975+
ConsumeExtraSemi(ExtraSemiKind::InstanceVariableList);
19761976
continue;
19771977
}
19781978

clang/lib/Parse/Parser.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/Sema/ParsedTemplate.h"
2525
#include "clang/Sema/Scope.h"
2626
#include "clang/Sema/SemaCodeCompletion.h"
27+
#include "llvm/ADT/STLForwardCompat.h"
2728
#include "llvm/Support/Path.h"
2829
#include "llvm/Support/TimeProfiler.h"
2930
using namespace clang;
@@ -213,7 +214,7 @@ void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST TST) {
213214

214215
// C++11 allows extra semicolons at namespace scope, but not in any of the
215216
// other contexts.
216-
if (Kind == OutsideFunction && getLangOpts().CPlusPlus) {
217+
if (Kind == ExtraSemiKind::OutsideFunction && getLangOpts().CPlusPlus) {
217218
if (getLangOpts().CPlusPlus11)
218219
Diag(StartLoc, diag::warn_cxx98_compat_top_level_semi)
219220
<< FixItHint::CreateRemoval(SourceRange(StartLoc, EndLoc));
@@ -223,10 +224,11 @@ void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST TST) {
223224
return;
224225
}
225226

226-
if (Kind != AfterMemberFunctionDefinition || HadMultipleSemis)
227+
if (Kind != ExtraSemiKind::AfterMemberFunctionDefinition || HadMultipleSemis)
227228
Diag(StartLoc, diag::ext_extra_semi)
228-
<< Kind << DeclSpec::getSpecifierName(TST,
229-
Actions.getASTContext().getPrintingPolicy())
229+
<< llvm::to_underlying(Kind)
230+
<< DeclSpec::getSpecifierName(
231+
TST, Actions.getASTContext().getPrintingPolicy())
230232
<< FixItHint::CreateRemoval(SourceRange(StartLoc, EndLoc));
231233
else
232234
// A single semicolon is valid after a member function definition.
@@ -902,7 +904,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
902904
// Either a C++11 empty-declaration or attribute-declaration.
903905
SingleDecl =
904906
Actions.ActOnEmptyDeclaration(getCurScope(), Attrs, Tok.getLocation());
905-
ConsumeExtraSemi(OutsideFunction);
907+
ConsumeExtraSemi(ExtraSemiKind::OutsideFunction);
906908
break;
907909
case tok::r_brace:
908910
Diag(Tok, diag::err_extraneous_closing_brace);

0 commit comments

Comments
 (0)