[LLVMbugs] [Bug 8973] New: remove llvm_unreachable
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jan 13 13:49:28 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=8973
Summary: remove llvm_unreachable
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Support Libraries
AssignedTo: unassignedbugs at nondot.org
ReportedBy: clattner at apple.com
CC: llvmbugs at cs.uiuc.edu
llvm_reachable does two things: it prints an error message, and is marked
noreturn to silence compiler warnings. It was added as a replacement for
"assert(0 &&" for the second feature, but it has since pervaded the codebase.
It would be really nice to eradicate almost all (or all) uses of this function,
replacing them with proper assertions. We have lots of stuff like this:
int foo() {
switch (x) {
case 1: ..
case 2: ..
case 3: return 27;
default: llvm_unreachable("whatever");
}
}
This sort of thing should be turned into:
int foo() {
switch (x) {
default: assert(0 && "whatever");
case 1: ..
case 2: ..
case 3: return 27;
}
}
There are other similar patterns to remove uses of llvm_unreachable. One
benefit of this is to get rid of all the ErrorHandling.h includes.
In contrast to llvm_unreachable, report_fatal_error *is* useful. Those handle
possible, but erroneous cases in the backend, such as inline asm constraint
failures.
-Chris
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list