r199868 - [analyzer] Future-proof MallocChecker CFG dumping.

Jordan Rose jordan_rose at apple.com
Wed Jan 22 19:59:01 PST 2014


Author: jrose
Date: Wed Jan 22 21:59:01 2014
New Revision: 199868

URL: http://llvm.org/viewvc/llvm-project?rev=199868&view=rev
Log:
[analyzer] Future-proof MallocChecker CFG dumping.

Now we'll get a warning if we miss a case. Refinement of r199800.

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=199868&r1=199867&r2=199868&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Wed Jan 22 21:59:01 2014
@@ -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()); }





More information about the cfe-commits mailing list