X86 MC: Don't crash on empty memory operand parens
authorReid Kleckner <reid@kleckner.net>
Thu, 31 Jul 2014 23:26:35 +0000 (23:26 +0000)
committerReid Kleckner <reid@kleckner.net>
Thu, 31 Jul 2014 23:26:35 +0000 (23:26 +0000)
Instead, create an absolute memory operand.

Fixes PR20504.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214457 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmParser/X86AsmParser.cpp
test/MC/X86/x86_operands.s

index 78b56b744f889079e6f5fa6d0b8b5a63441d3aa7..85de47be091742a80158c4b9473392c6a0cfe560 100644 (file)
@@ -1880,8 +1880,10 @@ std::unique_ptr<X86Operand> X86AsmParser::ParseMemOperand(unsigned SegReg,
     return nullptr;
   }
 
-  return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
-                               MemStart, MemEnd);
+  if (SegReg || BaseReg || IndexReg)
+    return X86Operand::CreateMem(SegReg, Disp, BaseReg, IndexReg, Scale,
+                                 MemStart, MemEnd);
+  return X86Operand::CreateMem(Disp, MemStart, MemEnd);
 }
 
 bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
index b34713db86378757f2025c5dc297156b48293455..2258a952774617d9769cc4d07f3a3605f9756092 100644 (file)
         call *%eax
 # CHECK: calll *4(%eax)
         call *4(%eax)
+foo:
+       calll foo()
+# CHECK: calll foo{{$}}
+       calll foo(,)
+# CHECK: calll foo{{$}}
 
 # CHECK: movl  %gs:8, %eax
 movl %gs:8, %eax