mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
DataLayout: Provide nicer diagnostics for malformed strings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223911 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
09df76443e
commit
fda17198fd
@ -199,6 +199,8 @@ static std::pair<StringRef, StringRef> split(StringRef Str, char Separator) {
|
||||
std::pair<StringRef, StringRef> Split = Str.split(Separator);
|
||||
if (Split.second.empty() && Split.first != Str)
|
||||
report_fatal_error("Trailing separator in datalayout string");
|
||||
if (!Split.second.empty() && Split.first.empty())
|
||||
report_fatal_error("Expected token before separator in datalayout string");
|
||||
return Split;
|
||||
}
|
||||
|
||||
@ -297,6 +299,9 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
"Sized aggregate specification in datalayout string");
|
||||
|
||||
// ABI alignment.
|
||||
if (Rest.empty())
|
||||
report_fatal_error(
|
||||
"Missing alignment specification in datalayout string");
|
||||
Split = split(Rest, ':');
|
||||
unsigned ABIAlign = inBytes(getInt(Tok));
|
||||
|
||||
@ -328,8 +333,12 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
assert(Tok.empty());
|
||||
assert(Rest.size() == 1);
|
||||
if (!Tok.empty())
|
||||
report_fatal_error("Unexpected trailing characters after mangling specifier in datalayout string");
|
||||
if (Rest.empty())
|
||||
report_fatal_error("Expected mangling specifier in datalayout string");
|
||||
if (Rest.size() > 1)
|
||||
report_fatal_error("Unknown mangling specifier in datalayout string");
|
||||
switch(Rest[0]) {
|
||||
default:
|
||||
report_fatal_error("Unknown mangling in datalayout string");
|
||||
|
3
test/Assembler/invalid-datalayout10.ll
Normal file
3
test/Assembler/invalid-datalayout10.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "m"
|
||||
; CHECK: Expected mangling specifier in datalayout string
|
3
test/Assembler/invalid-datalayout11.ll
Normal file
3
test/Assembler/invalid-datalayout11.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "m."
|
||||
; CHECK: Unexpected trailing characters after mangling specifier in datalayout string
|
3
test/Assembler/invalid-datalayout12.ll
Normal file
3
test/Assembler/invalid-datalayout12.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "f"
|
||||
; CHECK: Missing alignment specification in datalayout string
|
3
test/Assembler/invalid-datalayout13.ll
Normal file
3
test/Assembler/invalid-datalayout13.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = ":32"
|
||||
; CHECK: Expected token before separator in datalayout string
|
Loading…
Reference in New Issue
Block a user