llvm.org GIT mirror llvm / d49739e
MCObjectStreamer : fail with a diagnostic when emitting an out of range value. We were previously silently emitting bogus data in release mode, making it very hard to diagnose the error, or crashing with an assert in debug mode. A proper diagnostic is now always emitted when the value to be emitted is out of range. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303041 91177308-0d34-0410-b5e6-96231b3b80d8 Arnaud A. de Grandmaison 3 years ago
2 changed file(s) with 14 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
132132 // Avoid fixups when possible.
133133 int64_t AbsValue;
134134 if (Value->evaluateAsAbsolute(AbsValue, getAssembler())) {
135 if (!isUIntN(8 * Size, AbsValue) && !isIntN(8 * Size, AbsValue)) {
136 getContext().reportError(
137 Loc, "value evaluated as " + Twine(AbsValue) + " is out of range.");
138 return;
139 }
135140 EmitIntValue(AbsValue, Size);
136141 return;
137142 }
0 // RUN: not llvm-mc -triple aarch64-elf -filetype=obj %s -o /dev/null 2>&1 | FileCheck %s
1
2 .data
3 b:
4 .fill 300
5 e:
6 .byte e - b
7 // CHECK: error: value evaluated as 300 is out of range.
8 // CHECK-NEXT: .byte e - b
9 // CHECK-NEXT: ^
110
211 .section sec_x
312 start: