def note_drv_command_failed_diag_msg : Note<
"diagnostic msg: %0">;
+def note_drv_t_option_is_global :
+ Note<"The last /TC or /TP option takes precedence over earlier instances">;
def err_analyzer_config_no_value : Error<
"analyzer-config option '%0' has a key but no value">;
types::ID InputType = types::TY_Nothing;
Arg *InputTypeArg = 0;
- // The /TC and /TP options set the input type to C or C++ globally.
+ // The last /TC or /TP option sets the input type to C or C++ globally.
if (Arg *TCTP = Args.getLastArg(options::OPT__SLASH_TC,
options::OPT__SLASH_TP)) {
InputTypeArg = TCTP;
- unsigned opposite;
-
- if (TCTP->getOption().matches(options::OPT__SLASH_TC)) {
- InputType = types::TY_C;
- opposite = options::OPT__SLASH_TP;
- } else {
- InputType = types::TY_CXX;
- opposite = options::OPT__SLASH_TC;
- }
-
- if (Arg *OppositeArg = Args.getLastArg(opposite)) {
- Diag(clang::diag::warn_drv_overriding_t_option)
- << OppositeArg->getSpelling() << InputTypeArg->getSpelling();
+ InputType = TCTP->getOption().matches(options::OPT__SLASH_TC)
+ ? types::TY_C : types::TY_CXX;
+
+ arg_iterator it = Args.filtered_begin(options::OPT__SLASH_TC,
+ options::OPT__SLASH_TP);
+ const arg_iterator ie = Args.filtered_end();
+ Arg *Previous = *it++;
+ bool ShowNote = false;
+ while (it != ie) {
+ Diag(clang::diag::warn_drv_overriding_t_option) << Previous->getSpelling()
+ << (*it)->getSpelling();
+ Previous = *it++;
+ ShowNote = true;
}
+ if (ShowNote)
+ Diag(clang::diag::note_drv_t_option_is_global);
// No driver mode exposes -x and /TC or /TP; we don't support mixing them.
assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
\r
// RUN: %clang_cl /TC -### -- %s 2>&1 | FileCheck -check-prefix=TC %s\r
// TC: "-x" "c"\r
+// TC-NOT: warning\r
+// TC-NOT: note\r
\r
// RUN: %clang_cl /TP -### -- %s 2>&1 | FileCheck -check-prefix=TP %s\r
// TP: "-x" "c++"\r
+// TP-NOT: warning\r
+// TP-NOT: note\r
\r
-// RUN: %clang_cl -### /Tc%s 2>&1 | FileCheck -check-prefix=Tc %s\r
-// RUN: %clang_cl -### /TP /Tc%s 2>&1 | FileCheck -check-prefix=Tc %s\r
+// RUN: %clang_cl -### /Tc%s /TP -- %s 2>&1 | FileCheck -check-prefix=Tc %s\r
+// RUN: %clang_cl -### /TP /Tc%s -- %s 2>&1 | FileCheck -check-prefix=Tc %s\r
// Tc: "-x" "c"\r
+// Tc: "-x" "c++"\r
+// Tc-NOT: warning\r
+// Tc-NOT: note\r
\r
-// RUN: %clang_cl -### /Tp%s 2>&1 | FileCheck -check-prefix=Tp %s\r
-// RUN: %clang_cl -### /TC /Tp%s 2>&1 | FileCheck -check-prefix=Tp %s\r
+// RUN: %clang_cl -### /Tp%s /TC -- %s 2>&1 | FileCheck -check-prefix=Tp %s\r
+// RUN: %clang_cl -### /TC /Tp%s -- %s 2>&1 | FileCheck -check-prefix=Tp %s\r
// Tp: "-x" "c++"\r
+// Tp: "-x" "c"\r
+// Tp-NOT: warning\r
+// Tp-NOT: note\r
\r
-// RUN: %clang_cl /TP /TC -### -- %s 2>&1 | FileCheck -check-prefix=WARN %s\r
-// WARN: overriding '/TP' option with '/TC'\r
+// RUN: %clang_cl /TP /TC /TP -### -- %s 2>&1 | FileCheck -check-prefix=WARN %s\r
+// WARN: warning: overriding '/TP' option with '/TC'\r
+// WARN: warning: overriding '/TC' option with '/TP'\r
+// WARN: note: The last /TC or /TP option takes precedence over earlier instances\r
+// WARN-NOT: note\r