[llvm] r223811 - AsmParser: Don't crash on short hex constants for fp128 types
David Majnemer
david.majnemer at gmail.com
Tue Dec 9 11:10:03 PST 2014
Author: majnemer
Date: Tue Dec 9 13:10:03 2014
New Revision: 223811
URL: http://llvm.org/viewvc/llvm-project?rev=223811&view=rev
Log:
AsmParser: Don't crash on short hex constants for fp128 types
If we see 0xL01, treat it like 0xL00000000000000000000000000000001
instead of crashing.
Added:
llvm/trunk/test/Assembler/short-hexpair.ll
Modified:
llvm/trunk/lib/AsmParser/LLLexer.cpp
Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=223811&r1=223810&r2=223811&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp Tue Dec 9 13:10:03 2014
@@ -78,13 +78,15 @@ uint64_t LLLexer::HexIntToVal(const char
void LLLexer::HexToIntPair(const char *Buffer, const char *End,
uint64_t Pair[2]) {
Pair[0] = 0;
- for (int i=0; i<16; i++, Buffer++) {
- assert(Buffer != End);
- Pair[0] *= 16;
- Pair[0] += hexDigitValue(*Buffer);
+ if (End - Buffer >= 16) {
+ for (int i = 0; i < 16; i++, Buffer++) {
+ assert(Buffer != End);
+ Pair[0] *= 16;
+ Pair[0] += hexDigitValue(*Buffer);
+ }
}
Pair[1] = 0;
- for (int i=0; i<16 && Buffer != End; i++, Buffer++) {
+ for (int i = 0; i < 16 && Buffer != End; i++, Buffer++) {
Pair[1] *= 16;
Pair[1] += hexDigitValue(*Buffer);
}
Added: llvm/trunk/test/Assembler/short-hexpair.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/short-hexpair.ll?rev=223811&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/short-hexpair.ll (added)
+++ llvm/trunk/test/Assembler/short-hexpair.ll Tue Dec 9 13:10:03 2014
@@ -0,0 +1,4 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+ at x = global fp128 0xL01
+; CHECK: @x = global fp128 0xL00000000000000000000000000000001
More information about the llvm-commits
mailing list