[cfe-commits] r140068 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/Specifiers.h lib/AST/Decl.cpp lib/AST/DeclPrinter.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGe

John McCall rjmccall at apple.com
Mon Sep 19 15:03:21 PDT 2011


On Sep 19, 2011, at 2:37 PM, David Blaikie wrote:
> We generally prefer llvm_unreachable to assert(0)
> 
> we do (specifically just clang, or llvm as a whole)? I've seen some variation in this & when someone was fixing up the assert("foo")s in the code to assert(0 && "foo")s a week or two ago I thought about suggesting they be llvm_unreachables instead, but when I searched I think I found an email by Chris Lattner saying that assert(0 && "foo") was preferred (I can see if I can find it again).

This is what I and several others recommend for Clang.  There are several theoretical advantages to llvm_unreachable, plus it's just clearer.  Really, the only disadvantage is that the name's a bit long and unwieldy.

I think Chris has gone back and forward about it.  It *used* to actually be a performance issue because it didn't completely compile away in non-assertions builds, but that's no longer true, at least when built by Clang.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110919/fc5ef006/attachment.html>


More information about the cfe-commits mailing list