summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorSeth Cantrell <seth.cantrell@gmail.com>2015-03-04 05:58:08 +0000
committerSeth Cantrell <seth.cantrell@gmail.com>2015-03-04 05:58:08 +0000
commit7934007d617f19985d8acaa8f85b6c8080e23532 (patch)
tree6b8d7359c972a3cc444fd2c4e461cea7b268f39b /clang/lib/Sema/SemaChecking.cpp
parent394d10e34d01415897b6af28f7fceaeb5a9088f2 (diff)
downloadbcm5719-llvm-7934007d617f19985d8acaa8f85b6c8080e23532.tar.gz
bcm5719-llvm-7934007d617f19985d8acaa8f85b6c8080e23532.zip
AT.isValid() should come before AT.matchesType()
llvm-svn: 231213
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp66
1 files changed, 36 insertions, 30 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 72cb6003f5a..6b569b63756 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4036,41 +4036,47 @@ bool CheckScanfHandler::HandleScanfSpecifier(
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);
+ if (match == analyze_format_string::ArgType::Match) {
+ return true;
+ }
- 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;
- }
+ ScanfSpecifier fixedFS = FS;
+ bool success = fixedFS.fixType(Ex->getType(), Ex->IgnoreImpCasts()->getType(),
+ S.getLangOpts(), S.Context);
- if (success) {
- // Get the fix string from the fixed format specifier.
- SmallString<128> buf;
- llvm::raw_svector_ostream os(buf);
- fixedFS.toString(os);
+ 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;
+ }
- 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 (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;
OpenPOWER on IntegriCloud