]> granicus.if.org Git - clang/commitdiff
[analyzer] Future-proof MallocChecker CFG dumping.
authorJordan Rose <jordan_rose@apple.com>
Thu, 23 Jan 2014 03:59:01 +0000 (03:59 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 23 Jan 2014 03:59:01 +0000 (03:59 +0000)
Now we'll get a warning if we miss a case. Refinement of r199800.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199868 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/MallocChecker.cpp

index 188974391ce7fe942baae988dee9e14ced3ebb7d..e7edc20ac3e3379992c6153d8a65402f2dc7fa3a 100644 (file)
@@ -100,13 +100,13 @@ public:
   }
 
   void dump(raw_ostream &OS) const {
-    static const char *const Table[] = {
-      "Allocated",
-      "Released",
-      "Relinquished",
-      "Escaped"
-    };
-    OS << Table[(unsigned) K];
+    switch (static_cast<Kind>(K)) {
+#define CASE(ID) case ID: OS << #ID; break;
+    CASE(Allocated)
+    CASE(Released)
+    CASE(Relinquished)
+    CASE(Escaped)
+    }
   }
 
   LLVM_DUMP_METHOD void dump() const { dump(llvm::errs()); }