[PATCH] D38986: [Analyzer] Better unreachable message in enumeration

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 16 18:29:59 PDT 2017


george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun.

@dcoughlin I'm curious whether you'd like such a change: in general, I think it is much better when the assert failure tells the developer _what_ value is failing, rather than saying "oops we are dead".
I would personally even go further with providing a templated function from dump-able object to a string, which could be used to avoid such a cumbersome construction [which I have seen in a few places in Clang]


https://reviews.llvm.org/D38986

Files:
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp


Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -64,8 +64,12 @@
   }
 
   switch (Cond.getSubKind()) {
-  default:
-    llvm_unreachable("'Assume' not implemented for this NonLoc");
+  default: {
+    SmallString<64> buf;
+    llvm::raw_svector_ostream out(buf);
+    out << "'Assume' not implemented for this NonLoc: " << Cond << "\n";
+    llvm_unreachable(out.str().data());
+  }
 
   case nonloc::SymbolValKind: {
     nonloc::SymbolVal SV = Cond.castAs<nonloc::SymbolVal>();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38986.119239.patch
Type: text/x-patch
Size: 674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171017/dcb52ea6/attachment.bin>


More information about the cfe-commits mailing list