diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-12-10 01:38:28 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-12-10 01:38:28 +0000 |
commit | 2dc1b0f51487e7f16c013074b618c2040f01f898 (patch) | |
tree | d5f980d96b3788420a896629bd73e78953da6b02 /llvm/lib/IR/DataLayout.cpp | |
parent | 7c5da41c70041cd3a388454f71a6faaeaf77adce (diff) | |
download | llvm-2dc1b0f51487e7f16c013074b618c2040f01f898.zip llvm-2dc1b0f51487e7f16c013074b618c2040f01f898.tar.gz llvm-2dc1b0f51487e7f16c013074b618c2040f01f898.tar.bz2 |
DataLayout: Be more verbose when diagnosing problems in pointer specs
llvm-svn: 223903
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r-- | llvm/lib/IR/DataLayout.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index 394986e..4e0c066 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -197,8 +197,8 @@ void DataLayout::reset(StringRef Desc) { static std::pair<StringRef, StringRef> split(StringRef Str, char Separator) { assert(!Str.empty() && "parse error, string can't be empty here"); std::pair<StringRef, StringRef> Split = Str.split(Separator); - assert((!Split.second.empty() || Split.first == Str) && - "a trailing separator is not allowed"); + if (Split.second.empty() && Split.first != Str) + report_fatal_error("Trailing separator in datalayout string"); return Split; } @@ -213,7 +213,8 @@ static unsigned getInt(StringRef R) { /// Convert bits into bytes. Assert if not a byte width multiple. static unsigned inBytes(unsigned Bits) { - assert(Bits % 8 == 0 && "number of bits must be a byte width multiple"); + if (Bits % 8) + report_fatal_error("number of bits must be a byte width multiple"); return Bits / 8; } @@ -251,10 +252,16 @@ void DataLayout::parseSpecifier(StringRef Desc) { report_fatal_error("Invalid address space, must be a 24bit integer"); // Size. + if (Rest.empty()) + report_fatal_error( + "Missing size specification for pointer in datalayout string"); Split = split(Rest, ':'); unsigned PointerMemSize = inBytes(getInt(Tok)); // ABI alignment. + if (Rest.empty()) + report_fatal_error( + "Missing alignment specification for pointer in datalayout string"); Split = split(Rest, ':'); unsigned PointerABIAlign = inBytes(getInt(Tok)); |