@@ -396,18 +396,18 @@ static void checkOptions(Ctx &ctx) {
396396 ErrAlways (ctx) << " -z pac-plt only supported on AArch64" ;
397397 if (ctx.arg .zForceBti )
398398 ErrAlways (ctx) << " -z force-bti only supported on AArch64" ;
399- if (ctx.arg .zBtiReport != " none " )
399+ if (ctx.arg .zBtiReport != ReportPolicy::None )
400400 ErrAlways (ctx) << " -z bti-report only supported on AArch64" ;
401- if (ctx.arg .zPauthReport != " none " )
401+ if (ctx.arg .zPauthReport != ReportPolicy::None )
402402 ErrAlways (ctx) << " -z pauth-report only supported on AArch64" ;
403- if (ctx.arg .zGcsReport != " none " )
403+ if (ctx.arg .zGcsReport != ReportPolicy::None )
404404 ErrAlways (ctx) << " -z gcs-report only supported on AArch64" ;
405405 if (ctx.arg .zGcs != GcsPolicy::Implicit)
406406 ErrAlways (ctx) << " -z gcs only supported on AArch64" ;
407407 }
408408
409409 if (ctx.arg .emachine != EM_AARCH64 && ctx.arg .emachine != EM_ARM &&
410- ctx.arg .zExecuteOnlyReport != " none " )
410+ ctx.arg .zExecuteOnlyReport != ReportPolicy::None )
411411 ErrAlways (ctx)
412412 << " -z execute-only-report only supported on AArch64 and ARM" ;
413413
@@ -423,7 +423,7 @@ static void checkOptions(Ctx &ctx) {
423423 ErrAlways (ctx) << " --relax-gp is only supported on RISC-V targets" ;
424424
425425 if (ctx.arg .emachine != EM_386 && ctx.arg .emachine != EM_X86_64 &&
426- ctx.arg .zCetReport != " none " )
426+ ctx.arg .zCetReport != ReportPolicy::None )
427427 ErrAlways (ctx) << " -z cet-report only supported on X86 and X86_64" ;
428428
429429 if (ctx.arg .pie && ctx.arg .shared )
@@ -1272,11 +1272,6 @@ static void parseClangOption(Ctx &ctx, StringRef opt, const Twine &msg) {
12721272 ErrAlways (ctx) << msg << " : " << StringRef (err).trim ();
12731273}
12741274
1275- // Checks the parameter of the bti-report and cet-report options.
1276- static bool isValidReportString (StringRef arg) {
1277- return arg == " none" || arg == " warning" || arg == " error" ;
1278- }
1279-
12801275// Process a remap pattern 'from-glob=to-file'.
12811276static bool remapInputs (Ctx &ctx, StringRef line, const Twine &location) {
12821277 SmallVector<StringRef, 0 > fields;
@@ -1638,12 +1633,17 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
16381633 if (option.first != reportArg.first )
16391634 continue ;
16401635 arg->claim ();
1641- if (!isValidReportString (option.second )) {
1636+ if (option.second == " none" )
1637+ *reportArg.second = ReportPolicy::None;
1638+ else if (option.second == " warning" )
1639+ *reportArg.second = ReportPolicy::Warning;
1640+ else if (option.second == " error" )
1641+ *reportArg.second = ReportPolicy::Error;
1642+ else {
16421643 ErrAlways (ctx) << " unknown -z " << reportArg.first
16431644 << " = value: " << option.second ;
16441645 continue ;
16451646 }
1646- *reportArg.second = option.second ;
16471647 }
16481648 }
16491649
@@ -2820,17 +2820,13 @@ static void readSecurityNotes(Ctx &ctx) {
28202820 bool hasValidPauthAbiCoreInfo = llvm::any_of (
28212821 ctx.aarch64PauthAbiCoreInfo , [](uint8_t c) { return c != 0 ; });
28222822
2823- auto report = [&](StringRef config) -> ELFSyncStream {
2824- if (config == " error" )
2825- return {ctx, DiagLevel::Err};
2826- else if (config == " warning" )
2827- return {ctx, DiagLevel::Warn};
2828- return {ctx, DiagLevel::None};
2823+ auto report = [&](ReportPolicy policy) -> ELFSyncStream {
2824+ return {ctx, toDiagLevel (policy)};
28292825 };
2830- auto reportUnless = [&](StringRef config , bool cond) -> ELFSyncStream {
2826+ auto reportUnless = [&](ReportPolicy policy , bool cond) -> ELFSyncStream {
28312827 if (cond)
28322828 return {ctx, DiagLevel::None};
2833- return report (config) ;
2829+ return {ctx, toDiagLevel (policy)} ;
28342830 };
28352831 for (ELFFileBase *f : ctx.objectFiles ) {
28362832 uint32_t features = f->andFeatures ;
@@ -2860,13 +2856,13 @@ static void readSecurityNotes(Ctx &ctx) {
28602856
28612857 if (ctx.arg .zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
28622858 features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
2863- if (ctx.arg .zBtiReport == " none " )
2859+ if (ctx.arg .zBtiReport == ReportPolicy::None )
28642860 Warn (ctx) << f
28652861 << " : -z force-bti: file does not have "
28662862 " GNU_PROPERTY_AARCH64_FEATURE_1_BTI property" ;
28672863 } else if (ctx.arg .zForceIbt &&
28682864 !(features & GNU_PROPERTY_X86_FEATURE_1_IBT)) {
2869- if (ctx.arg .zCetReport == " none " )
2865+ if (ctx.arg .zCetReport == ReportPolicy::None )
28702866 Warn (ctx) << f
28712867 << " : -z force-ibt: file does not have "
28722868 " GNU_PROPERTY_X86_FEATURE_1_IBT property" ;
0 commit comments