aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/PrintfFormatString.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-29 03:16:21 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-29 03:16:21 +0000
commit808015a18bd97781ce437831a95a92fdfc8d5136 (patch)
tree687528b674b59b6cbaf49ada87d769b7ce745280 /lib/Analysis/PrintfFormatString.cpp
parenta6fe0bf89db4372c9e8e8a5c2a50593c2977df29 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94794 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/PrintfFormatString.cpp')
-rw-r--r--lib/Analysis/PrintfFormatString.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index 3f03420657..bf1e894115 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/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