summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DataLayout.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-12-10 01:17:08 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-12-10 01:17:08 +0000
commit5330c69bd15179904dfae54fff511033305679e1 (patch)
treef8bc96df964b46da2779c44531172ad4d8bd2d6e /llvm/lib/IR/DataLayout.cpp
parentd85548d423409e11204f60b5d76f61a779d41b09 (diff)
downloadbcm5719-llvm-5330c69bd15179904dfae54fff511033305679e1.tar.gz
bcm5719-llvm-5330c69bd15179904dfae54fff511033305679e1.zip
DataLayout: Move asserts over to report_fatal_error
As indicated by the tests, it is possible to feed the AsmParser an invalid datalayout string. We should verify the result of parsing this string regardless of whether or not we have assertions enabled. llvm-svn: 223898
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r--llvm/lib/IR/DataLayout.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 8a057f552a5..394986e092d 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -247,8 +247,8 @@ void DataLayout::parseSpecifier(StringRef Desc) {
case 'p': {
// Address space.
unsigned AddrSpace = Tok.empty() ? 0 : getInt(Tok);
- assert(AddrSpace < 1 << 24 &&
- "Invalid address space, must be a 24bit integer");
+ if (!isUInt<24>(AddrSpace))
+ report_fatal_error("Invalid address space, must be a 24bit integer");
// Size.
Split = split(Rest, ':');
@@ -285,8 +285,9 @@ void DataLayout::parseSpecifier(StringRef Desc) {
// Bit size.
unsigned Size = Tok.empty() ? 0 : getInt(Tok);
- assert((AlignType != AGGREGATE_ALIGN || Size == 0) &&
- "These specifications don't have a size");
+ if (AlignType == AGGREGATE_ALIGN && Size != 0)
+ report_fatal_error(
+ "Sized aggregate specification in datalayout string");
// ABI alignment.
Split = split(Rest, ':');
@@ -306,7 +307,9 @@ void DataLayout::parseSpecifier(StringRef Desc) {
case 'n': // Native integer types.
for (;;) {
unsigned Width = getInt(Tok);
- assert(Width != 0 && "width must be non-zero");
+ if (Width == 0)
+ report_fatal_error(
+ "Zero width native integer type in datalayout string");
LegalIntWidths.push_back(Width);
if (Rest.empty())
break;
@@ -322,7 +325,7 @@ void DataLayout::parseSpecifier(StringRef Desc) {
assert(Rest.size() == 1);
switch(Rest[0]) {
default:
- llvm_unreachable("Unknown mangling in datalayout string");
+ report_fatal_error("Unknown mangling in datalayout string");
case 'e':
ManglingMode = MM_ELF;
break;
@@ -338,7 +341,7 @@ void DataLayout::parseSpecifier(StringRef Desc) {
}
break;
default:
- llvm_unreachable("Unknown specifier in datalayout string");
+ report_fatal_error("Unknown specifier in datalayout string");
break;
}
}
OpenPOWER on IntegriCloud