aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support
diff options
context:
space:
mode:
authorEdwin Török <edwintorok@gmail.com>2009-07-11 20:10:48 +0000
committerEdwin Török <edwintorok@gmail.com>2009-07-11 20:10:48 +0000
commit675d56222b6b98d2c22a17aaf69a036e57d5426a (patch)
treee4bb95c96a33fda5d5204f2c9d1b906084760415 /lib/Support
parent3f6e3ffc36c9dd4c10056c7262de77f6c4a115c7 (diff)
downloadexternal_llvm-675d56222b6b98d2c22a17aaf69a036e57d5426a.zip
external_llvm-675d56222b6b98d2c22a17aaf69a036e57d5426a.tar.gz
external_llvm-675d56222b6b98d2c22a17aaf69a036e57d5426a.tar.bz2
assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/APFloat.cpp15
-rw-r--r--lib/Support/APInt.cpp9
-rw-r--r--lib/Support/CommandLine.cpp2
-rw-r--r--lib/Support/Dwarf.cpp43
-rw-r--r--lib/Support/ErrorHandling.cpp4
-rw-r--r--lib/Support/FoldingSet.cpp3
6 files changed, 41 insertions, 35 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index 3b03c54..29bf0b4 100644
--- a/lib/Support/APFloat.cpp
+++ b/lib/Support/APFloat.cpp
@@ -14,6 +14,7 @@
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <cstring>
@@ -1068,7 +1069,7 @@ APFloat::roundAwayFromZero(roundingMode rounding_mode,
switch (rounding_mode) {
default:
- assert(0);
+ llvm_unreachable();
case rmNearestTiesToAway:
return lost_fraction == lfExactlyHalf || lost_fraction == lfMoreThanHalf;
@@ -1207,7 +1208,7 @@ APFloat::addOrSubtractSpecials(const APFloat &rhs, bool subtract)
{
switch (convolve(category, rhs.category)) {
default:
- assert(0);
+ llvm_unreachable();
case convolve(fcNaN, fcZero):
case convolve(fcNaN, fcNormal):
@@ -1331,7 +1332,7 @@ APFloat::multiplySpecials(const APFloat &rhs)
{
switch (convolve(category, rhs.category)) {
default:
- assert(0);
+ llvm_unreachable();
case convolve(fcNaN, fcZero):
case convolve(fcNaN, fcNormal):
@@ -1373,7 +1374,7 @@ APFloat::divideSpecials(const APFloat &rhs)
{
switch (convolve(category, rhs.category)) {
default:
- assert(0);
+ llvm_unreachable();
case convolve(fcNaN, fcZero):
case convolve(fcNaN, fcNormal):
@@ -1415,7 +1416,7 @@ APFloat::modSpecials(const APFloat &rhs)
{
switch (convolve(category, rhs.category)) {
default:
- assert(0);
+ llvm_unreachable();
case convolve(fcNaN, fcZero):
case convolve(fcNaN, fcNormal):
@@ -1692,7 +1693,7 @@ APFloat::compare(const APFloat &rhs) const
switch (convolve(category, rhs.category)) {
default:
- assert(0);
+ llvm_unreachable();
case convolve(fcNaN, fcZero):
case convolve(fcNaN, fcNormal):
@@ -2929,7 +2930,7 @@ APFloat::initFromAPInt(const APInt& api, bool isIEEE)
else if (api.getBitWidth()==128 && !isIEEE)
return initFromPPCDoubleDoubleAPInt(api);
else
- assert(0);
+ llvm_unreachable();
}
APFloat::APFloat(const APInt& api, bool isIEEE)
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 30dc352..bd5abec 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -17,6 +17,7 @@
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cmath>
@@ -1386,7 +1387,7 @@ APInt APInt::sqrt() const {
else
return x_old + 1;
} else
- assert(0 && "Error in APInt::sqrt computation");
+ LLVM_UNREACHABLE("Error in APInt::sqrt computation");
return x_old + 1;
}
@@ -2032,7 +2033,7 @@ void APInt::fromString(unsigned numbits, const char *str, unsigned slen,
char cdigit = str[i];
if (radix == 16) {
if (!isxdigit(cdigit))
- assert(0 && "Invalid hex digit in string");
+ LLVM_UNREACHABLE("Invalid hex digit in string");
if (isdigit(cdigit))
digit = cdigit - '0';
else if (cdigit >= 'a')
@@ -2040,7 +2041,7 @@ void APInt::fromString(unsigned numbits, const char *str, unsigned slen,
else if (cdigit >= 'A')
digit = cdigit - 'A' + 10;
else
- assert(0 && "huh? we shouldn't get here");
+ LLVM_UNREACHABLE("huh? we shouldn't get here");
} else if (isdigit(cdigit)) {
digit = cdigit - '0';
assert((radix == 10 ||
@@ -2048,7 +2049,7 @@ void APInt::fromString(unsigned numbits, const char *str, unsigned slen,
(radix == 2 && (digit == 0 || digit == 1))) &&
"Invalid digit in string for given radix");
} else {
- assert(0 && "Invalid character in digit string");
+ LLVM_UNREACHABLE("Invalid character in digit string");
}
// Shift or multiply the value by the radix
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 0fe949c..400241f 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -693,7 +693,7 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
ValNo++;
break;
default:
- assert(0 && "Internal error, unexpected NumOccurrences flag in "
+ LLVM_UNREACHABLE("Internal error, unexpected NumOccurrences flag in "
"positional argument processing!");
}
}
diff --git a/lib/Support/Dwarf.cpp b/lib/Support/Dwarf.cpp
index fa99035..c2ce680 100644
--- a/lib/Support/Dwarf.cpp
+++ b/lib/Support/Dwarf.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Support/Dwarf.h"
+#include "llvm/Support/ErrorHandling.h"
#include <cassert>
@@ -83,7 +84,7 @@ const char *TagString(unsigned Tag) {
case DW_TAG_lo_user: return "DW_TAG_lo_user";
case DW_TAG_hi_user: return "DW_TAG_hi_user";
}
- assert(0 && "Unknown Dwarf Tag");
+ LLVM_UNREACHABLE("Unknown Dwarf Tag");
return "";
}
@@ -94,7 +95,7 @@ const char *ChildrenString(unsigned Children) {
case DW_CHILDREN_no: return "CHILDREN_no";
case DW_CHILDREN_yes: return "CHILDREN_yes";
}
- assert(0 && "Unknown Dwarf ChildrenFlag");
+ LLVM_UNREACHABLE("Unknown Dwarf ChildrenFlag");
return "";
}
@@ -205,7 +206,7 @@ const char *AttributeString(unsigned Attribute) {
case DW_AT_APPLE_major_runtime_vers: return "DW_AT_APPLE_major_runtime_vers";
case DW_AT_APPLE_runtime_class: return "DW_AT_APPLE_runtime_class";
}
- assert(0 && "Unknown Dwarf Attribute");
+ LLVM_UNREACHABLE("Unknown Dwarf Attribute");
return "";
}
@@ -235,7 +236,7 @@ const char *FormEncodingString(unsigned Encoding) {
case DW_FORM_ref_udata: return "FORM_ref_udata";
case DW_FORM_indirect: return "FORM_indirect";
}
- assert(0 && "Unknown Dwarf Form Encoding");
+ LLVM_UNREACHABLE("Unknown Dwarf Form Encoding");
return "";
}
@@ -310,7 +311,7 @@ const char *OperationEncodingString(unsigned Encoding) {
case DW_OP_lo_user: return "OP_lo_user";
case DW_OP_hi_user: return "OP_hi_user";
}
- assert(0 && "Unknown Dwarf Operation Encoding");
+ LLVM_UNREACHABLE("Unknown Dwarf Operation Encoding");
return "";
}
@@ -336,7 +337,7 @@ const char *AttributeEncodingString(unsigned Encoding) {
case DW_ATE_lo_user: return "ATE_lo_user";
case DW_ATE_hi_user: return "ATE_hi_user";
}
- assert(0 && "Unknown Dwarf Attribute Encoding");
+ LLVM_UNREACHABLE("Unknown Dwarf Attribute Encoding");
return "";
}
@@ -350,7 +351,7 @@ const char *DecimalSignString(unsigned Sign) {
case DW_DS_leading_separate: return "DS_leading_separate";
case DW_DS_trailing_separate: return "DS_trailing_separate";
}
- assert(0 && "Unknown Dwarf Decimal Sign Attribute");
+ LLVM_UNREACHABLE("Unknown Dwarf Decimal Sign Attribute");
return "";
}
@@ -364,7 +365,7 @@ const char *EndianityString(unsigned Endian) {
case DW_END_lo_user: return "END_lo_user";
case DW_END_hi_user: return "END_hi_user";
}
- assert(0 && "Unknown Dwarf Endianity");
+ LLVM_UNREACHABLE("Unknown Dwarf Endianity");
return "";
}
@@ -377,7 +378,7 @@ const char *AccessibilityString(unsigned Access) {
case DW_ACCESS_protected: return "ACCESS_protected";
case DW_ACCESS_private: return "ACCESS_private";
}
- assert(0 && "Unknown Dwarf Accessibility");
+ LLVM_UNREACHABLE("Unknown Dwarf Accessibility");
return "";
}
@@ -389,7 +390,7 @@ const char *VisibilityString(unsigned Visibility) {
case DW_VIS_exported: return "VIS_exported";
case DW_VIS_qualified: return "VIS_qualified";
}
- assert(0 && "Unknown Dwarf Visibility");
+ LLVM_UNREACHABLE("Unknown Dwarf Visibility");
return "";
}
@@ -401,7 +402,7 @@ const char *VirtualityString(unsigned Virtuality) {
case DW_VIRTUALITY_virtual: return "VIRTUALITY_virtual";
case DW_VIRTUALITY_pure_virtual: return "VIRTUALITY_pure_virtual";
}
- assert(0 && "Unknown Dwarf Virtuality");
+ LLVM_UNREACHABLE("Unknown Dwarf Virtuality");
return "";
}
@@ -431,7 +432,7 @@ const char *LanguageString(unsigned Language) {
case DW_LANG_lo_user: return "LANG_lo_user";
case DW_LANG_hi_user: return "LANG_hi_user";
}
- assert(0 && "Unknown Dwarf Language");
+ LLVM_UNREACHABLE("Unknown Dwarf Language");
return "";
}
@@ -444,7 +445,7 @@ const char *CaseString(unsigned Case) {
case DW_ID_down_case: return "ID_down_case";
case DW_ID_case_insensitive: return "ID_case_insensitive";
}
- assert(0 && "Unknown Dwarf Identifier Case");
+ LLVM_UNREACHABLE("Unknown Dwarf Identifier Case");
return "";
}
@@ -458,7 +459,7 @@ const char *ConventionString(unsigned Convention) {
case DW_CC_lo_user: return "CC_lo_user";
case DW_CC_hi_user: return "CC_hi_user";
}
- assert(0 && "Unknown Dwarf Calling Convention");
+ LLVM_UNREACHABLE("Unknown Dwarf Calling Convention");
return "";
}
@@ -471,7 +472,7 @@ const char *InlineCodeString(unsigned Code) {
case DW_INL_declared_not_inlined: return "INL_declared_not_inlined";
case DW_INL_declared_inlined: return "INL_declared_inlined";
}
- assert(0 && "Unknown Dwarf Inline Code");
+ LLVM_UNREACHABLE("Unknown Dwarf Inline Code");
return "";
}
@@ -482,7 +483,7 @@ const char *ArrayOrderString(unsigned Order) {
case DW_ORD_row_major: return "ORD_row_major";
case DW_ORD_col_major: return "ORD_col_major";
}
- assert(0 && "Unknown Dwarf Array Order");
+ LLVM_UNREACHABLE("Unknown Dwarf Array Order");
return "";
}
@@ -493,7 +494,7 @@ const char *DiscriminantString(unsigned Discriminant) {
case DW_DSC_label: return "DSC_label";
case DW_DSC_range: return "DSC_range";
}
- assert(0 && "Unknown Dwarf Discriminant Descriptor");
+ LLVM_UNREACHABLE("Unknown Dwarf Discriminant Descriptor");
return "";
}
@@ -514,7 +515,7 @@ const char *LNStandardString(unsigned Standard) {
case DW_LNS_set_epilogue_begin: return "LNS_set_epilogue_begin";
case DW_LNS_set_isa: return "LNS_set_isa";
}
- assert(0 && "Unknown Dwarf Line Number Standard");
+ LLVM_UNREACHABLE("Unknown Dwarf Line Number Standard");
return "";
}
@@ -529,7 +530,7 @@ const char *LNExtendedString(unsigned Encoding) {
case DW_LNE_lo_user: return "LNE_lo_user";
case DW_LNE_hi_user: return "LNE_hi_user";
}
- assert(0 && "Unknown Dwarf Line Number Extended Opcode Encoding");
+ LLVM_UNREACHABLE("Unknown Dwarf Line Number Extended Opcode Encoding");
return "";
}
@@ -544,7 +545,7 @@ const char *MacinfoString(unsigned Encoding) {
case DW_MACINFO_end_file: return "MACINFO_end_file";
case DW_MACINFO_vendor_ext: return "MACINFO_vendor_ext";
}
- assert(0 && "Unknown Dwarf Macinfo Type Encodings");
+ LLVM_UNREACHABLE("Unknown Dwarf Macinfo Type Encodings");
return "";
}
@@ -580,7 +581,7 @@ const char *CallFrameString(unsigned Encoding) {
case DW_CFA_lo_user: return "CFA_lo_user";
case DW_CFA_hi_user: return "CFA_hi_user";
}
- assert(0 && "Unknown Dwarf Call Frame Instruction Encodings");
+ LLVM_UNREACHABLE("Unknown Dwarf Call Frame Instruction Encodings");
return "";
}
diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp
index 2a5d906..f2e247c 100644
--- a/lib/Support/ErrorHandling.cpp
+++ b/lib/Support/ErrorHandling.cpp
@@ -44,7 +44,9 @@ void llvm_report_error(const std::string &reason) {
exit(1);
}
-void llvm_unreachable(void) {
+void llvm_unreachable(const char *msg) {
+ if (msg)
+ errs() << msg << "\n";
abort();
}
}
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp
index 41c730e..0f61067 100644
--- a/lib/Support/FoldingSet.cpp
+++ b/lib/Support/FoldingSet.cpp
@@ -15,6 +15,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/FoldingSet.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <cstring>
@@ -50,7 +51,7 @@ void FoldingSetNodeID::AddInteger(unsigned long I) {
else if (sizeof(long) == sizeof(long long)) {
AddInteger((unsigned long long)I);
} else {
- assert(0 && "unexpected sizeof(long)");
+ LLVM_UNREACHABLE("unexpected sizeof(long)");
}
}
void FoldingSetNodeID::AddInteger(long long I) {