diff options
author | Arnaud A. de Grandmaison <arnaud.degrandmaison@arm.com> | 2017-05-15 08:43:27 +0000 |
---|---|---|
committer | Arnaud A. de Grandmaison <arnaud.degrandmaison@arm.com> | 2017-05-15 08:43:27 +0000 |
commit | 6d2417924c42e061d2812de90751d301a0a20740 (patch) | |
tree | c3edc9a34996bf41a17492f4de73e9979c927d85 /llvm/lib/MC/MCObjectStreamer.cpp | |
parent | 0fe7231a2ffd2df77ea056ac4a58ae48cff08b26 (diff) | |
download | bcm5719-llvm-6d2417924c42e061d2812de90751d301a0a20740.tar.gz bcm5719-llvm-6d2417924c42e061d2812de90751d301a0a20740.zip |
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.
llvm-svn: 303041
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index f7f2253256e..174397e2739 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -133,6 +133,11 @@ void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, // Avoid fixups when possible. int64_t AbsValue; if (Value->evaluateAsAbsolute(AbsValue, getAssembler())) { + if (!isUIntN(8 * Size, AbsValue) && !isIntN(8 * Size, AbsValue)) { + getContext().reportError( + Loc, "value evaluated as " + Twine(AbsValue) + " is out of range."); + return; + } EmitIntValue(AbsValue, Size); return; } |