Move the fixit for -Wformat-security to a note.
r263299 added a fixit for the -Wformat-security warning, but that runs
into complications with our guideline that error recovery should be done
as-if the fixit had been applied. Putting the fixit on a note avoids that.
llvm-svn: 263584
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 966d349..cc261e0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3628,19 +3628,20 @@
// If there are no arguments specified, warn with -Wformat-security, otherwise
// warn only with -Wformat-nonliteral.
if (Args.size() == firstDataArg) {
- const SemaDiagnosticBuilder &D =
- Diag(FormatLoc, diag::warn_format_nonliteral_noargs);
+ Diag(FormatLoc, diag::warn_format_nonliteral_noargs)
+ << OrigFormatExpr->getSourceRange();
switch (Type) {
default:
- D << OrigFormatExpr->getSourceRange();
break;
case FST_Kprintf:
case FST_FreeBSDKPrintf:
case FST_Printf:
- D << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
+ Diag(FormatLoc, diag::note_format_security_fixit)
+ << FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
break;
case FST_NSString:
- D << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
+ Diag(FormatLoc, diag::note_format_security_fixit)
+ << FixItHint::CreateInsertion(FormatLoc, "@\"%@\", ");
break;
}
} else {