On 05.04.2013 4:41, Jordan Rose wrote:
:-) A fully-covered switch in LLVM does not include a "default" case. We do put 
an llvm_unreachable after the switch to appease older GCCs' -Wreturn-type, but the point 
of the covered switch is so that we get a warning when a new enum value is added.
Got it. Fixed at r178831.



On Apr 4, 2013, at 17:31 , Anton Yartsev <[email protected]> wrote:

Author: ayartsev
Date: Thu Apr  4 19:31:02 2013
New Revision: 178820

URL: http://llvm.org/viewvc/llvm-project?rev=178820&view=rev
Log:
[analyzer] Fully-covered switch for families in isTrackedFamily()

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=178820&r1=178819&r2=178820&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Thu Apr  4 19:31:02 
2013
@@ -1068,13 +1068,24 @@ ProgramStateRef MallocChecker::FreeMemAu
}

bool MallocChecker::isTrackedFamily(AllocationFamily Family) const {
-  if (Family == AF_Malloc &&
-    (!Filter.CMallocOptimistic && !Filter.CMallocPessimistic))
-    return false;
-
-  if ((Family == AF_CXXNew || Family == AF_CXXNewArray) &&
-    !Filter.CNewDeleteChecker)
-    return false;
+  switch (Family) {
+  case AF_Malloc: {
+    if (!Filter.CMallocOptimistic && !Filter.CMallocPessimistic)
+      return false;
+    break;
+  }
+  case AF_CXXNew:
+  case AF_CXXNewArray: {
+    if (!Filter.CNewDeleteChecker)
+      return false;
+    break;
+  }
+  case AF_None: {
+    return true;
+  }
+  default:
+    llvm_unreachable("unhandled family");
+  }

   return true;
}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


--
Anton

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to