@@ -1049,6 +1049,69 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
1049
1049
}
1050
1050
}
1051
1051
1052
+ [&]() {
1053
+ if (ContainsError)
1054
+ return ;
1055
+
1056
+ llvm::SmallVector<const char *, 16 > WarningsToDisable = {
1057
+ " -Wno-elaborated-enum-base" ,
1058
+ };
1059
+
1060
+ llvm::SmallVector<const char *, 32 > ExtraArgs = {
1061
+ // Add other command-line arguments here.
1062
+ };
1063
+
1064
+ // Append WarningsToDisable to ExtraArgs, although do not disable warnings
1065
+ // the command-line has explicitly turned on.
1066
+ //
1067
+ // TODO: Consider handling warning groups specially.
1068
+ if (!WarningsToDisable.empty ()) {
1069
+ // Map the warnings explicitly turned on by the command-line.
1070
+ llvm::StringSet<> WarningsToKeep;
1071
+ for (auto *Arg : Args) {
1072
+ if (!Arg->getOption ().matches (options::OPT_W_Joined))
1073
+ continue ;
1074
+ StringRef Value = Arg->getValue ();
1075
+ if (Value.empty ())
1076
+ continue ; // Skip past "-W"
1077
+
1078
+ // Handle "-Wflag", "-Werror=flag", and "-Wno-flag". Ignore
1079
+ // "-Wno-error=flag" since it doesn't turn the warning on or off.
1080
+ if (Value.consume_front (" no-" )) {
1081
+ WarningsToKeep.erase (Value);
1082
+ continue ;
1083
+ }
1084
+ (void )Value.consume_front (" error=" );
1085
+ WarningsToKeep.insert (Value);
1086
+ }
1087
+
1088
+ // Disable any warnings not explicitly turned on.
1089
+ for (const char *Warning : WarningsToDisable) {
1090
+ StringRef S (Warning);
1091
+ bool Consumed = S.consume_front (" -Wno-" );
1092
+ (void )Consumed;
1093
+ assert (Consumed && " Warning flag should be in '-Wno-' form" );
1094
+ if (!WarningsToKeep.count (S))
1095
+ ExtraArgs.push_back (Warning);
1096
+ }
1097
+ }
1098
+
1099
+ if (ExtraArgs.empty ())
1100
+ return ; // Nothing to do...
1101
+
1102
+ // Process the extra arguments, adding them to the main Args list.
1103
+ InputArgList ExtraOptions =
1104
+ ParseArgStrings (ExtraArgs, /* IsClCompatMode=*/ false , ContainsError);
1105
+ if (ContainsError)
1106
+ return ;
1107
+ for (auto *Opt : ExtraOptions) {
1108
+ // Always claim these implicit arguments to avoid strange warnings
1109
+ // in -v output.
1110
+ Opt->claim ();
1111
+ appendOneArg (Opt, nullptr );
1112
+ }
1113
+ }();
1114
+
1052
1115
// Check for working directory option before accessing any files
1053
1116
if (Arg *WD = Args.getLastArg (options::OPT_working_directory))
1054
1117
if (VFS->setCurrentWorkingDirectory (WD->getValue ()))
0 commit comments