r231213 - AT.isValid() should come before AT.matchesType()
Seth Cantrell
seth.cantrell at gmail.com
Tue Mar 3 21:58:08 PST 2015
Author: socantre
Date: Tue Mar 3 23:58:08 2015
New Revision: 231213
URL: http://llvm.org/viewvc/llvm-project?rev=231213&view=rev
Log:
AT.isValid() should come before AT.matchesType()
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=231213&r1=231212&r2=231213&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 3 23:58:08 2015
@@ -4036,41 +4036,47 @@ bool CheckScanfHandler::HandleScanfSpeci
return true;
const analyze_format_string::ArgType &AT = FS.getArgType(S.Context);
+
+ if (!AT.isValid()) {
+ return true;
+ }
+
analyze_format_string::ArgType::MatchKind match =
AT.matchesType(S.Context, Ex->getType());
- if (AT.isValid() && match != analyze_format_string::ArgType::Match) {
- ScanfSpecifier fixedFS = FS;
- bool success =
- fixedFS.fixType(Ex->getType(), Ex->IgnoreImpCasts()->getType(),
- S.getLangOpts(), S.Context);
-
- unsigned diag = diag::warn_format_conversion_argument_type_mismatch;
- if (match == analyze_format_string::ArgType::NoMatchPedantic) {
- diag = diag::warn_format_conversion_argument_type_mismatch_pedantic;
- }
-
- if (success) {
- // Get the fix string from the fixed format specifier.
- SmallString<128> buf;
- llvm::raw_svector_ostream os(buf);
- fixedFS.toString(os);
-
- EmitFormatDiagnostic(
- S.PDiag(diag) << AT.getRepresentativeTypeName(S.Context)
- << Ex->getType() << false << Ex->getSourceRange(),
- Ex->getLocStart(),
- /*IsStringLocation*/ false,
- getSpecifierRange(startSpecifier, specifierLen),
- FixItHint::CreateReplacement(
- getSpecifierRange(startSpecifier, specifierLen), os.str()));
- } else {
- EmitFormatDiagnostic(
- S.PDiag(diag) << AT.getRepresentativeTypeName(S.Context)
- << Ex->getType() << false << Ex->getSourceRange(),
- Ex->getLocStart(),
- /*IsStringLocation*/ false,
- getSpecifierRange(startSpecifier, specifierLen));
- }
+ if (match == analyze_format_string::ArgType::Match) {
+ return true;
+ }
+
+ ScanfSpecifier fixedFS = FS;
+ bool success = fixedFS.fixType(Ex->getType(), Ex->IgnoreImpCasts()->getType(),
+ S.getLangOpts(), S.Context);
+
+ unsigned diag = diag::warn_format_conversion_argument_type_mismatch;
+ if (match == analyze_format_string::ArgType::NoMatchPedantic) {
+ diag = diag::warn_format_conversion_argument_type_mismatch_pedantic;
+ }
+
+ if (success) {
+ // Get the fix string from the fixed format specifier.
+ SmallString<128> buf;
+ llvm::raw_svector_ostream os(buf);
+ fixedFS.toString(os);
+
+ EmitFormatDiagnostic(
+ S.PDiag(diag) << AT.getRepresentativeTypeName(S.Context)
+ << Ex->getType() << false << Ex->getSourceRange(),
+ Ex->getLocStart(),
+ /*IsStringLocation*/ false,
+ getSpecifierRange(startSpecifier, specifierLen),
+ FixItHint::CreateReplacement(
+ getSpecifierRange(startSpecifier, specifierLen), os.str()));
+ } else {
+ EmitFormatDiagnostic(S.PDiag(diag)
+ << AT.getRepresentativeTypeName(S.Context)
+ << Ex->getType() << false << Ex->getSourceRange(),
+ Ex->getLocStart(),
+ /*IsStringLocation*/ false,
+ getSpecifierRange(startSpecifier, specifierLen));
}
return true;
More information about the cfe-commits
mailing list