diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-01-29 03:16:21 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-01-29 03:16:21 +0000 |
| commit | c22f78ddfdde18b8e7aca259371b6b514a29bd11 (patch) | |
| tree | 3c4a8b9807018850dc4c9e21e23aad31ef600fce /clang/lib/Analysis | |
| parent | a91be641a7268f84f5b096fa84f3d33282295630 (diff) | |
| download | bcm5719-llvm-c22f78ddfdde18b8e7aca259371b6b514a29bd11.tar.gz bcm5719-llvm-c22f78ddfdde18b8e7aca259371b6b514a29bd11.zip | |
Alternate format string checking: issue warnings for incomplete format specifiers.
In addition, move ParseFormatString() and FormatStringHandler() from
the clang::analyze_printf to the clang namespace. Hopefully this will
resolve some link errors on Linux.
llvm-svn: 94794
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/PrintfFormatString.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp index 3f034206576..bf1e8941152 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/lib/Analysis/PrintfFormatString.cpp @@ -16,6 +16,7 @@ using clang::analyze_printf::FormatSpecifier; using clang::analyze_printf::OptionalAmount; +using namespace clang; namespace { class FormatSpecifierResult { @@ -83,9 +84,8 @@ static OptionalAmount ParseAmount(const char *&Beg, const char *E) { return OptionalAmount(); } -static FormatSpecifierResult -ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, - const char *&Beg, const char *E) { +static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H, + const char *&Beg, const char *E) { using namespace clang::analyze_printf; @@ -113,7 +113,7 @@ ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, if (I == E) { // No more characters left? - H.HandleIncompleteFormatSpecifier(Start, E); + H.HandleIncompleteFormatSpecifier(Start, E - Start); return true; } @@ -136,7 +136,7 @@ ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, if (I == E) { // No more characters left? - H.HandleIncompleteFormatSpecifier(Start, E); + H.HandleIncompleteFormatSpecifier(Start, E - Start); return true; } @@ -145,15 +145,15 @@ ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, if (I == E) { // No more characters left? - H.HandleIncompleteFormatSpecifier(Start, E); + H.HandleIncompleteFormatSpecifier(Start, E - Start); return true; } // Look for the precision (if any). if (*I == '.') { - const char *startPrecision = I++; + ++I; if (I == E) { - H.HandleIncompletePrecision(I - 1); + H.HandleIncompleteFormatSpecifier(Start, E - Start); return true; } @@ -161,7 +161,7 @@ ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, if (I == E) { // No more characters left? - H.HandleIncompletePrecision(startPrecision); + H.HandleIncompleteFormatSpecifier(Start, E - Start); return true; } } @@ -188,7 +188,7 @@ ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, if (I == E) { // No more characters left? - H.HandleIncompleteFormatSpecifier(Start, E); + H.HandleIncompleteFormatSpecifier(Start, E - Start); return true; } @@ -230,8 +230,7 @@ ParseFormatSpecifier(clang::analyze_printf::FormatStringHandler &H, return FormatSpecifierResult(Start, FS); } -namespace clang { namespace analyze_printf { -bool ParseFormatString(FormatStringHandler &H, +bool clang::ParseFormatString(FormatStringHandler &H, const char *I, const char *E) { // Keep looking for a format specifier until we have exhausted the string. while (I != E) { @@ -254,4 +253,3 @@ bool ParseFormatString(FormatStringHandler &H, } FormatStringHandler::~FormatStringHandler() {} -}} // end namespace clang::analyze_printf |

