aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/PrintfFormatString.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-29 20:29:53 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-29 20:29:53 +0000
commit4dcb18ff9d92c66c78077ac5cae4b83af37292e4 (patch)
tree275719f1f02e628fb435178e5db13cac200146f6 /lib/Analysis/PrintfFormatString.cpp
parente14654b3b749421e21a4d917cdbcaf5589c0c6c3 (diff)
Enhancements to the alternate (WIP) format string checking:
- Add ConversionSpecifier::consumesDataArgument() as a helper method to determine if a conversion specifier requires a matching argument. - Add support for glibc-specific '%m' conversion - Add an extra callback to HandleNull() for locations within the format specifier that have a null character git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/PrintfFormatString.cpp')
-rw-r--r--lib/Analysis/PrintfFormatString.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index bf1e894115..bb9ac8480a 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -191,6 +191,12 @@ static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H,
H.HandleIncompleteFormatSpecifier(Start, E - Start);
return true;
}
+
+ if (*I == '\0') {
+ // Detect spurious null characters, which are likely errors.
+ H.HandleNullChar(I);
+ return true;
+ }
// Finally, look for the conversion specifier.
const char *conversionPosition = I++;
@@ -219,7 +225,9 @@ static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H,
case 'n': k = ConversionSpecifier::OutIntPtrArg; break;
case '%': k = ConversionSpecifier::PercentArg; break;
// Objective-C.
- case '@': k = ConversionSpecifier::ObjCObjArg; break;
+ case '@': k = ConversionSpecifier::ObjCObjArg; break;
+ // Glibc specific.
+ case 'm': k = ConversionSpecifier::PrintErrno; break;
}
FS.setConversionSpecifier(ConversionSpecifier(conversionPosition, k));
@@ -246,7 +254,7 @@ bool clang::ParseFormatString(FormatStringHandler &H,
// We have a format specifier. Pass it to the callback.
if (!H.HandleFormatSpecifier(FSR.getValue(), FSR.getStart(),
I - FSR.getStart()))
- return false;
+ return true;
}
assert(I == E && "Format string not exhausted");
return false;