[cfe-commits] r94721 - in /cfe/trunk/lib/Sema: Sema.h SemaChecking.cpp

Ted Kremenek kremenek at apple.com
Wed Jan 27 17:18:22 PST 2010


Author: kremenek
Date: Wed Jan 27 19:18:22 2010
New Revision: 94721

URL: http://llvm.org/viewvc/llvm-project?rev=94721&view=rev
Log:
Add placeholder function in Sema for new format string checking logic.
This function will use the format string parsing logic in libAnalysis,
and once it is shown to be better than the current implementation it
will replace AlternateCheckPrintfString() entirely.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=94721&r1=94720&r2=94721&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Jan 27 19:18:22 2010
@@ -4047,6 +4047,13 @@
   bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
                               bool HasVAListArg, unsigned format_idx,
                               unsigned firstDataArg);
+  // FIXME: This function is placeholder for transitioning the printf
+  //  format string checking to a new codepath.  It will eventually
+  //  replace CheckPrintfString().
+  void AlternateCheckPrintfString(const StringLiteral *FExpr,
+                                  const Expr *OrigFormatExpr,
+                                  const CallExpr *TheCall, bool HasVAListArg,
+                                  unsigned format_idx, unsigned firstDataArg);  
   void CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
                          const CallExpr *TheCall, bool HasVAListArg,
                          unsigned format_idx, unsigned firstDataArg);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=94721&r1=94720&r2=94721&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Jan 27 19:18:22 2010
@@ -1036,6 +1036,14 @@
                              const Expr *OrigFormatExpr,
                              const CallExpr *TheCall, bool HasVAListArg,
                              unsigned format_idx, unsigned firstDataArg) {
+    
+  static bool UseAlternatePrintfChecking = false;
+  if (UseAlternatePrintfChecking) {
+    AlternateCheckPrintfString(FExpr, OrigFormatExpr, TheCall,
+                               HasVAListArg, format_idx, firstDataArg);
+    return;
+  }    
+  
 
   const ObjCStringLiteral *ObjCFExpr =
     dyn_cast<ObjCStringLiteral>(OrigFormatExpr);
@@ -1059,7 +1067,7 @@
       << OrigFormatExpr->getSourceRange();
     return;
   }
-
+  
   // We process the format string using a binary state machine.  The
   // current state is stored in CurrentState.
   enum {
@@ -1271,6 +1279,15 @@
   }
 }
 
+void
+Sema::AlternateCheckPrintfString(const StringLiteral *FExpr,
+                                 const Expr *OrigFormatExpr,
+                                 const CallExpr *TheCall, bool HasVAListArg,
+                                 unsigned format_idx, unsigned firstDataArg) {
+  
+  
+}
+
 //===--- CHECK: Return Address of Stack Variable --------------------------===//
 
 static DeclRefExpr* EvalVal(Expr *E);





More information about the cfe-commits mailing list