Skip to content

Commit b10296e

Browse files
committed
[clang][NFC] Convert Sema::PragmaClangSectionKind to scoped enum
1 parent 936e528 commit b10296e

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ enum class FunctionEffectMode : uint8_t {
463463
Dependent // effect(expr) where expr is dependent.
464464
};
465465

466+
/// pragma clang section kind
467+
enum class PragmaClangSectionKind {
468+
Invalid = 0,
469+
BSS = 1,
470+
Data = 2,
471+
Rodata = 3,
472+
Text = 4,
473+
Relro = 5
474+
};
475+
466476
/// Sema - This implements semantic analysis and AST building for C.
467477
/// \nosubgrouping
468478
class Sema final : public SemaBase {
@@ -1412,16 +1422,6 @@ class Sema final : public SemaBase {
14121422
/// Source location for newly created implicit MSInheritanceAttrs
14131423
SourceLocation ImplicitMSInheritanceAttrLoc;
14141424

1415-
/// pragma clang section kind
1416-
enum PragmaClangSectionKind {
1417-
PCSK_Invalid = 0,
1418-
PCSK_BSS = 1,
1419-
PCSK_Data = 2,
1420-
PCSK_Rodata = 3,
1421-
PCSK_Text = 4,
1422-
PCSK_Relro = 5
1423-
};
1424-
14251425
enum PragmaClangSectionAction { PCSA_Set = 0, PCSA_Clear = 1 };
14261426

14271427
struct PragmaClangSection {

clang/lib/Parse/ParsePragma.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ void PragmaClangSectionHandler::HandlePragma(Preprocessor &PP,
23142314
Token &FirstToken) {
23152315

23162316
Token Tok;
2317-
auto SecKind = Sema::PragmaClangSectionKind::PCSK_Invalid;
2317+
auto SecKind = PragmaClangSectionKind::Invalid;
23182318

23192319
PP.Lex(Tok); // eat 'section'
23202320
while (Tok.isNot(tok::eod)) {
@@ -2325,15 +2325,15 @@ void PragmaClangSectionHandler::HandlePragma(Preprocessor &PP,
23252325

23262326
const IdentifierInfo *SecType = Tok.getIdentifierInfo();
23272327
if (SecType->isStr("bss"))
2328-
SecKind = Sema::PragmaClangSectionKind::PCSK_BSS;
2328+
SecKind = PragmaClangSectionKind::BSS;
23292329
else if (SecType->isStr("data"))
2330-
SecKind = Sema::PragmaClangSectionKind::PCSK_Data;
2330+
SecKind = PragmaClangSectionKind::Data;
23312331
else if (SecType->isStr("rodata"))
2332-
SecKind = Sema::PragmaClangSectionKind::PCSK_Rodata;
2332+
SecKind = PragmaClangSectionKind::Rodata;
23332333
else if (SecType->isStr("relro"))
2334-
SecKind = Sema::PragmaClangSectionKind::PCSK_Relro;
2334+
SecKind = PragmaClangSectionKind::Relro;
23352335
else if (SecType->isStr("text"))
2336-
SecKind = Sema::PragmaClangSectionKind::PCSK_Text;
2336+
SecKind = PragmaClangSectionKind::Text;
23372337
else {
23382338
PP.Diag(Tok.getLocation(), diag::err_pragma_expected_clang_section_name) << "clang section";
23392339
return;
@@ -2342,7 +2342,7 @@ void PragmaClangSectionHandler::HandlePragma(Preprocessor &PP,
23422342
SourceLocation PragmaLocation = Tok.getLocation();
23432343
PP.Lex(Tok); // eat ['bss'|'data'|'rodata'|'text']
23442344
if (Tok.isNot(tok::equal)) {
2345-
PP.Diag(Tok.getLocation(), diag::err_pragma_clang_section_expected_equal) << SecKind;
2345+
PP.Diag(Tok.getLocation(), diag::err_pragma_clang_section_expected_equal) << llvm::to_underlying(SecKind);
23462346
return;
23472347
}
23482348

clang/lib/Sema/SemaAttr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,21 +393,21 @@ void Sema::ActOnPragmaClangSection(SourceLocation PragmaLoc,
393393
PragmaClangSection *CSec;
394394
int SectionFlags = ASTContext::PSF_Read;
395395
switch (SecKind) {
396-
case PragmaClangSectionKind::PCSK_BSS:
396+
case PragmaClangSectionKind::BSS:
397397
CSec = &PragmaClangBSSSection;
398398
SectionFlags |= ASTContext::PSF_Write | ASTContext::PSF_ZeroInit;
399399
break;
400-
case PragmaClangSectionKind::PCSK_Data:
400+
case PragmaClangSectionKind::Data:
401401
CSec = &PragmaClangDataSection;
402402
SectionFlags |= ASTContext::PSF_Write;
403403
break;
404-
case PragmaClangSectionKind::PCSK_Rodata:
404+
case PragmaClangSectionKind::Rodata:
405405
CSec = &PragmaClangRodataSection;
406406
break;
407-
case PragmaClangSectionKind::PCSK_Relro:
407+
case PragmaClangSectionKind::Relro:
408408
CSec = &PragmaClangRelroSection;
409409
break;
410-
case PragmaClangSectionKind::PCSK_Text:
410+
case PragmaClangSectionKind::Text:
411411
CSec = &PragmaClangTextSection;
412412
SectionFlags |= ASTContext::PSF_Execute;
413413
break;

0 commit comments

Comments
 (0)