summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-03 16:41:24 +0000
committerChris Lattner <sabre@nondot.org>2010-08-03 16:41:24 +0000
commit3db3bb0032d8ebb6337b9ccbe3da518b15a0b210 (patch)
tree530dc6a35c7ed25fc23eb43b6c6e8681314075b3 /llvm/lib/Support/raw_ostream.cpp
parentddaaf40d2480b62f26078062d9e8bb1f370ea24f (diff)
downloadbcm5719-llvm-3db3bb0032d8ebb6337b9ccbe3da518b15a0b210.tar.gz
bcm5719-llvm-3db3bb0032d8ebb6337b9ccbe3da518b15a0b210.zip
avoid undef behavior on minint, fixing PR7783.
llvm-svn: 110114
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 8054ae63688..ac118a91a3f 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -143,9 +143,10 @@ raw_ostream &raw_ostream::operator<<(unsigned long long N) {
}
raw_ostream &raw_ostream::operator<<(long long N) {
- if (N < 0) {
+ if (N < 0) {
*this << '-';
- N = -N;
+ // Avoid undefined behavior on INT64_MIN with a cast.
+ N = -(unsigned long long)N;
}
return this->operator<<(static_cast<unsigned long long>(N));
OpenPOWER on IntegriCloud