[cfe-commits] r95287 - in /cfe/trunk: lib/Checker/AdjustedReturnValueChecker.cpp test/Analysis/misc-ps.m

Ted Kremenek kremenek at apple.com
Wed Feb 3 20:18:55 PST 2010


Author: kremenek
Date: Wed Feb  3 22:18:55 2010
New Revision: 95287

URL: http://llvm.org/viewvc/llvm-project?rev=95287&view=rev
Log:
Specially handle casts to 'void' in AdjustedReturnValueChecker.

Modified:
    cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp
    cfe/trunk/test/Analysis/misc-ps.m

Modified: cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp?rev=95287&r1=95286&r2=95287&view=diff

==============================================================================
--- cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp (original)
+++ cfe/trunk/lib/Checker/AdjustedReturnValueChecker.cpp Wed Feb  3 22:18:55 2010
@@ -43,12 +43,21 @@
 void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C,
                                                    const CallExpr *CE) {
   
+  // Get the result type of the call.
+  QualType expectedResultTy = CE->getType();
+
   // Fetch the signature of the called function.
   const GRState *state = C.getState();
 
   SVal V = state->getSVal(CE);
   if (V.isUnknown())
     return;
+  
+  // Casting to void?  Discard the value.
+  if (expectedResultTy->isVoidType()) {
+    C.GenerateNode(state->BindExpr(CE, UnknownVal()));
+    return;
+  }                   
 
   const MemRegion *callee = state->getSVal(CE->getCallee()).getAsRegion();
   if (!callee)
@@ -76,8 +85,6 @@
   if (actualResultTy->getAs<ReferenceType>())
     return;
   
-  // Get the result type of the call.
-  QualType expectedResultTy = CE->getType();
 
   // Are they the same?
   if (expectedResultTy != actualResultTy) {

Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=95287&r1=95286&r2=95287&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Feb  3 22:18:55 2010
@@ -893,3 +893,11 @@
     return 1;
   return 0;
 }
+
+// Same as previous case, but handle casts to 'void'.
+int bar_rev95274() {
+  void (*Callback_rev95274)(void) = (void (*)(void)) foo_rev95267;
+  (*Callback_rev95274)();
+  return 0;
+}
+





More information about the cfe-commits mailing list