summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FileUtilities.cpp
diff options
context:
space:
mode:
authorLauro Ramos Venancio <lauro.venancio@gmail.com>2008-01-28 18:23:23 +0000
committerLauro Ramos Venancio <lauro.venancio@gmail.com>2008-01-28 18:23:23 +0000
commit99929d20e7bead8db91b74555b8f118f2b2dac07 (patch)
tree489fb01866312a66acc87dbaeea5a4a40fb56b6f /llvm/lib/Support/FileUtilities.cpp
parenta1160715478a2d6894a42afdb7290ea20b45108a (diff)
downloadbcm5719-llvm-99929d20e7bead8db91b74555b8f118f2b2dac07.tar.gz
bcm5719-llvm-99929d20e7bead8db91b74555b8f118f2b2dac07.zip
Fix fpcmp infinite loop when comparing "29-266" with "29-268".
llvm-svn: 46455
Diffstat (limited to 'llvm/lib/Support/FileUtilities.cpp')
-rw-r--r--llvm/lib/Support/FileUtilities.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index eff6fc911b2..30463e86792 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/lib/Support/FileUtilities.cpp
@@ -20,11 +20,15 @@
#include <cctype>
using namespace llvm;
-static bool isNumberChar(char C) {
+static bool isSignedChar(char C) {
+ if (C == '+' || C == '-')
+ return true;
+ else
+ return false;
+}
+
+static bool isExpoentChar(char C) {
switch (C) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case '.': case '+': case '-':
case 'D': // Strange exponential notation.
case 'd': // Strange exponential notation.
case 'e':
@@ -33,13 +37,25 @@ static bool isNumberChar(char C) {
}
}
+static bool isNumberChar(char C) {
+ switch (C) {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case '.': return true;
+ default: return isSignedChar(C) || isExpoentChar(C);
+ }
+}
+
static char *BackupNumber(char *Pos, char *FirstChar) {
// If we didn't stop in the middle of a number, don't backup.
if (!isNumberChar(*Pos)) return Pos;
// Otherwise, return to the start of the number.
- while (Pos > FirstChar && isNumberChar(Pos[-1]))
+ while (Pos > FirstChar && isNumberChar(Pos[-1])) {
--Pos;
+ if (Pos > FirstChar && isSignedChar(Pos[0]) && !isExpoentChar(Pos[-1]))
+ break;
+ }
return Pos;
}
OpenPOWER on IntegriCloud