[cfe-commits] r70367 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Chris Lattner sabre at nondot.org
Tue Apr 28 21:49:34 PDT 2009


Author: lattner
Date: Tue Apr 28 23:49:34 2009
New Revision: 70367

URL: http://llvm.org/viewvc/llvm-project?rev=70367&view=rev
Log:
code simplification, no functionality change.

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

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Apr 28 23:49:34 2009
@@ -577,39 +577,36 @@
   // C string (e.g. "%d")
   // ObjC string uses the same format specifiers as C string, so we can use 
   // the same format string checking logic for both ObjC and C strings.
-  bool isFExpr = SemaCheckStringLiteral(OrigFormatExpr, TheCall, 
-                                        HasVAListArg, format_idx,
-                                        firstDataArg);
-
-  if (!isFExpr) {
-    // For vprintf* functions (i.e., HasVAListArg==true), we add a
-    // special check to see if the format string is a function parameter
-    // of the function calling the printf function.  If the function
-    // has an attribute indicating it is a printf-like function, then we
-    // should suppress warnings concerning non-literals being used in a call
-    // to a vprintf function.  For example:
-    //
-    // void
-    // logmessage(char const *fmt __attribute__ (format (printf, 1, 2)), ...) {
-    //      va_list ap;
-    //      va_start(ap, fmt);
-    //      vprintf(fmt, ap);  // Do NOT emit a warning about "fmt".
-    //      ...
-    //
-    //
-    //  FIXME: We don't have full attribute support yet, so just check to see
-    //    if the argument is a DeclRefExpr that references a parameter.  We'll
-    //    add proper support for checking the attribute later.
-    if (HasVAListArg)
-      if (const DeclRefExpr* DR = dyn_cast<DeclRefExpr>(OrigFormatExpr))
-        if (isa<ParmVarDecl>(DR->getDecl()))
-          return;
-
-    Diag(TheCall->getArg(format_idx)->getLocStart(), 
-         diag::warn_printf_not_string_constant)
-         << OrigFormatExpr->getSourceRange();
-    return;
-  }
+  if (SemaCheckStringLiteral(OrigFormatExpr, TheCall, HasVAListArg, format_idx,
+                             firstDataArg))
+    return;  // Literal format string found, check done!
+
+  // For vprintf* functions (i.e., HasVAListArg==true), we add a
+  // special check to see if the format string is a function parameter
+  // of the function calling the printf function.  If the function
+  // has an attribute indicating it is a printf-like function, then we
+  // should suppress warnings concerning non-literals being used in a call
+  // to a vprintf function.  For example:
+  //
+  // void
+  // logmessage(char const *fmt __attribute__ (format (printf, 1, 2)), ...) {
+  //      va_list ap;
+  //      va_start(ap, fmt);
+  //      vprintf(fmt, ap);  // Do NOT emit a warning about "fmt".
+  //      ...
+  //
+  //
+  //  FIXME: We don't have full attribute support yet, so just check to see
+  //    if the argument is a DeclRefExpr that references a parameter.  We'll
+  //    add proper support for checking the attribute later.
+  if (HasVAListArg)
+    if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(OrigFormatExpr))
+      if (isa<ParmVarDecl>(DR->getDecl()))
+        return;
+
+  Diag(TheCall->getArg(format_idx)->getLocStart(), 
+       diag::warn_printf_not_string_constant)
+       << OrigFormatExpr->getSourceRange();
 }
 
 void Sema::CheckPrintfString(const StringLiteral *FExpr,





More information about the cfe-commits mailing list