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

Ted Kremenek kremenek at apple.com
Mon Feb 1 11:38:10 PST 2010


Author: kremenek
Date: Mon Feb  1 13:38:10 2010
New Revision: 94994

URL: http://llvm.org/viewvc/llvm-project?rev=94994&view=rev
Log:
Use early return as suggested by Cristian Draghici.

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=94994&r1=94993&r2=94994&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Feb  1 13:38:10 2010
@@ -1286,19 +1286,16 @@
       // Check if we didn't match because of an implicit cast from a 'char'
       // or 'short' to an 'int'.  This is done because printf is a varargs
       // function.
-      bool hasError = true;      
       if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Ex))
-        if (ICE->getType() == S.Context.IntTy) {
-          Ex = ICE->getSubExpr();
-          hasError = !MatchType(*T, Ex->getType(), true);
-        }
-      
-      if (hasError)            
-        S.Diag(getLocationOfByte(CS.getStart()),
-               diag::warn_printf_conversion_argument_type_mismatch)
-          << *T << Ex->getType()
-          << getFormatSpecifierRange(startSpecifier, specifierLen)
-          << Ex->getSourceRange();
+        if (ICE->getType() == S.Context.IntTy)
+          if (MatchType(*T, ICE->getSubExpr()->getType(), true))
+            return true;
+
+      S.Diag(getLocationOfByte(CS.getStart()),
+             diag::warn_printf_conversion_argument_type_mismatch)
+        << *T << Ex->getType()
+        << getFormatSpecifierRange(startSpecifier, specifierLen)
+        << Ex->getSourceRange();
     }
     return true;
   }





More information about the cfe-commits mailing list