summaryrefslogtreecommitdiffstats
path: root/clang/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
commit23a71a1cdf7ad3a81386578621a41e27c4ad06d4 (patch)
treec1de8335d140a2e66534ebfe2ecb6d658eb7d8cd /clang/lib/Analysis/PrintfFormatString.cpp
parent6bd1dee261b564103cee01d871446e81a4c5ff21 (diff)
downloadbcm5719-llvm-23a71a1cdf7ad3a81386578621a41e27c4ad06d4.tar.gz
bcm5719-llvm-23a71a1cdf7ad3a81386578621a41e27c4ad06d4.zip
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 llvm-svn: 94834
Diffstat (limited to 'clang/lib/Analysis/PrintfFormatString.cpp')
-rw-r--r--clang/lib/Analysis/PrintfFormatString.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp
index bf1e8941152..bb9ac8480a0 100644
--- a/clang/lib/Analysis/PrintfFormatString.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud