@@ -396,18 +396,18 @@ static void checkOptions(Ctx &ctx) {
396
396
ErrAlways (ctx) << " -z pac-plt only supported on AArch64" ;
397
397
if (ctx.arg .zForceBti )
398
398
ErrAlways (ctx) << " -z force-bti only supported on AArch64" ;
399
- if (ctx.arg .zBtiReport != " none " )
399
+ if (ctx.arg .zBtiReport != ReportPolicy::None )
400
400
ErrAlways (ctx) << " -z bti-report only supported on AArch64" ;
401
- if (ctx.arg .zPauthReport != " none " )
401
+ if (ctx.arg .zPauthReport != ReportPolicy::None )
402
402
ErrAlways (ctx) << " -z pauth-report only supported on AArch64" ;
403
- if (ctx.arg .zGcsReport != " none " )
403
+ if (ctx.arg .zGcsReport != ReportPolicy::None )
404
404
ErrAlways (ctx) << " -z gcs-report only supported on AArch64" ;
405
405
if (ctx.arg .zGcs != GcsPolicy::Implicit)
406
406
ErrAlways (ctx) << " -z gcs only supported on AArch64" ;
407
407
}
408
408
409
409
if (ctx.arg .emachine != EM_AARCH64 && ctx.arg .emachine != EM_ARM &&
410
- ctx.arg .zExecuteOnlyReport != " none " )
410
+ ctx.arg .zExecuteOnlyReport != ReportPolicy::None )
411
411
ErrAlways (ctx)
412
412
<< " -z execute-only-report only supported on AArch64 and ARM" ;
413
413
@@ -423,7 +423,7 @@ static void checkOptions(Ctx &ctx) {
423
423
ErrAlways (ctx) << " --relax-gp is only supported on RISC-V targets" ;
424
424
425
425
if (ctx.arg .emachine != EM_386 && ctx.arg .emachine != EM_X86_64 &&
426
- ctx.arg .zCetReport != " none " )
426
+ ctx.arg .zCetReport != ReportPolicy::None )
427
427
ErrAlways (ctx) << " -z cet-report only supported on X86 and X86_64" ;
428
428
429
429
if (ctx.arg .pie && ctx.arg .shared )
@@ -1272,11 +1272,6 @@ static void parseClangOption(Ctx &ctx, StringRef opt, const Twine &msg) {
1272
1272
ErrAlways (ctx) << msg << " : " << StringRef (err).trim ();
1273
1273
}
1274
1274
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
-
1280
1275
// Process a remap pattern 'from-glob=to-file'.
1281
1276
static bool remapInputs (Ctx &ctx, StringRef line, const Twine &location) {
1282
1277
SmallVector<StringRef, 0 > fields;
@@ -1638,12 +1633,17 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
1638
1633
if (option.first != reportArg.first )
1639
1634
continue ;
1640
1635
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 {
1642
1643
ErrAlways (ctx) << " unknown -z " << reportArg.first
1643
1644
<< " = value: " << option.second ;
1644
1645
continue ;
1645
1646
}
1646
- *reportArg.second = option.second ;
1647
1647
}
1648
1648
}
1649
1649
@@ -2820,17 +2820,13 @@ static void readSecurityNotes(Ctx &ctx) {
2820
2820
bool hasValidPauthAbiCoreInfo = llvm::any_of (
2821
2821
ctx.aarch64PauthAbiCoreInfo , [](uint8_t c) { return c != 0 ; });
2822
2822
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)};
2829
2825
};
2830
- auto reportUnless = [&](StringRef config , bool cond) -> ELFSyncStream {
2826
+ auto reportUnless = [&](ReportPolicy policy , bool cond) -> ELFSyncStream {
2831
2827
if (cond)
2832
2828
return {ctx, DiagLevel::None};
2833
- return report (config) ;
2829
+ return {ctx, toDiagLevel (policy)} ;
2834
2830
};
2835
2831
for (ELFFileBase *f : ctx.objectFiles ) {
2836
2832
uint32_t features = f->andFeatures ;
@@ -2860,13 +2856,13 @@ static void readSecurityNotes(Ctx &ctx) {
2860
2856
2861
2857
if (ctx.arg .zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
2862
2858
features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
2863
- if (ctx.arg .zBtiReport == " none " )
2859
+ if (ctx.arg .zBtiReport == ReportPolicy::None )
2864
2860
Warn (ctx) << f
2865
2861
<< " : -z force-bti: file does not have "
2866
2862
" GNU_PROPERTY_AARCH64_FEATURE_1_BTI property" ;
2867
2863
} else if (ctx.arg .zForceIbt &&
2868
2864
!(features & GNU_PROPERTY_X86_FEATURE_1_IBT)) {
2869
- if (ctx.arg .zCetReport == " none " )
2865
+ if (ctx.arg .zCetReport == ReportPolicy::None )
2870
2866
Warn (ctx) << f
2871
2867
<< " : -z force-ibt: file does not have "
2872
2868
" GNU_PROPERTY_X86_FEATURE_1_IBT property" ;
0 commit comments