]> granicus.if.org Git - clang/commitdiff
Move ParseFormatString() and FormatStringHandler back into the analyze_printf namespace.
authorTed Kremenek <kremenek@apple.com>
Thu, 4 Feb 2010 20:46:58 +0000 (20:46 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 4 Feb 2010 20:46:58 +0000 (20:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95324 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Analyses/PrintfFormatString.h
lib/Analysis/PrintfFormatString.cpp
lib/Sema/SemaChecking.cpp

index 46f23ce3e24f4d6fe17a22218e7f2208d4ad9b30..a5c0b23c2d0f34b1a757d88aef6512ba89b16560 100644 (file)
@@ -234,8 +234,6 @@ public:
   bool hasLeadingZeros() const { return (bool) HasLeadingZeroes; }  
 };
 
-} // end printf namespace
-
 class FormatStringHandler {
 public:
   FormatStringHandler() {}
@@ -261,6 +259,6 @@ public:
 bool ParseFormatString(FormatStringHandler &H,
                        const char *beg, const char *end);
 
-
+} // end printf namespace
 } // end clang namespace
 #endif
index 35c620adedc1aeff5274c92f6c1b067aa53036c7..6e603faf7290fb4f102b3e84497fc867ec113cb3 100644 (file)
@@ -18,6 +18,7 @@
 using clang::analyze_printf::FormatSpecifier;
 using clang::analyze_printf::OptionalAmount;
 using clang::analyze_printf::ArgTypeResult;
+using clang::analyze_printf::FormatStringHandler;
 using namespace clang;
 
 namespace {
@@ -87,7 +88,8 @@ static OptionalAmount ParseAmount(const char *&Beg, const char *E) {
 }
 
 static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H,
-                                                  const char *&Beg, const char *E) {
+                                                  const char *&Beg,
+                                                  const char *E) {
   
   using namespace clang::analyze_printf;
   
@@ -241,7 +243,7 @@ static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H,
   return FormatSpecifierResult(Start, FS);
 }
 
-bool clang::ParseFormatString(FormatStringHandler &H,
+bool clang::analyze_printf::ParseFormatString(FormatStringHandler &H,
                        const char *I, const char *E) {
   // Keep looking for a format specifier until we have exhausted the string.
   while (I != E) {
index cb0e5fb218169f8c9529a9ca69820341cf2da954..cba3c60661891e8a4bc921cf8226435edfe6c3da 100644 (file)
@@ -1033,7 +1033,7 @@ Sema::CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg,
 }
 
 namespace {
-class CheckPrintfHandler : public FormatStringHandler {
+class CheckPrintfHandler : public analyze_printf::FormatStringHandler {
   Sema &S;
   const StringLiteral *FExpr;
   const Expr *OrigFormatExpr;
@@ -1061,9 +1061,10 @@ public:
   void HandleIncompleteFormatSpecifier(const char *startSpecifier,
                                        unsigned specifierLen);
   
-  void HandleInvalidConversionSpecifier(const analyze_printf::FormatSpecifier &FS,
-                                        const char *startSpecifier,
-                                        unsigned specifierLen);
+  void
+  HandleInvalidConversionSpecifier(const analyze_printf::FormatSpecifier &FS,
+                                   const char *startSpecifier,
+                                   unsigned specifierLen);
   
   void HandleNullChar(const char *nullCharacter);
   
@@ -1292,9 +1293,9 @@ CheckPrintfHandler::HandleFormatSpecifier(const analyze_printf::FormatSpecifier
 
       S.Diag(getLocationOfByte(CS.getStart()),
              diag::warn_printf_conversion_argument_type_mismatch)
-        << *T << Ex->getType()
-        << getFormatSpecifierRange(startSpecifier, specifierLen)
-        << Ex->getSourceRange();
+      << *T << Ex->getType();
+//        << getFormatSpecifierRange(startSpecifier, specifierLen)
+//        << Ex->getSourceRange();
     }
     return true;
   }
@@ -1341,7 +1342,7 @@ void Sema::CheckPrintfString(const StringLiteral *FExpr,
                        isa<ObjCStringLiteral>(OrigFormatExpr), Str,
                        HasVAListArg, TheCall, format_idx);
 
-  if (!ParseFormatString(H, Str, Str + StrLen))
+  if (!analyze_printf::ParseFormatString(H, Str, Str + StrLen))
     H.DoneProcessing();
 }