[ms-inline asm] Avoid a false positive assertion
authorChad Rosier <mcrosier@apple.com>
Wed, 22 Aug 2012 19:14:29 +0000 (19:14 +0000)
committerChad Rosier <mcrosier@apple.com>
Wed, 22 Aug 2012 19:14:29 +0000 (19:14 +0000)
Assertion failed: (Start.isValid() == End.isValid() && "Start and end should
either both be valid or both be invalid!")

when parsing inline asm.  SMLoc assumes that the first char * in the source is
invalid.  However, when parsing an inline asm the mnemonic is at this location.
I don't want to change SMLoc, so use a trivial workaround.

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

lib/Target/X86/AsmParser/X86AsmParser.cpp

index 73a00950ac168be3abf15893994ccd7a8748214b..8c9a02ff22c6ad40615622aec5f73d9cf7c5c42e 100644 (file)
@@ -1677,8 +1677,10 @@ MatchInstruction(SMLoc IDLoc,
   if ((Match1 == Match_MnemonicFail) && (Match2 == Match_MnemonicFail) &&
       (Match3 == Match_MnemonicFail) && (Match4 == Match_MnemonicFail)) {
     if (!WasOriginallyInvalidOperand) {
+      ArrayRef<SMRange> Ranges = matchingInlineAsm ? EmptyRanges :
+        Op->getLocRange();
       return Error(IDLoc, "invalid instruction mnemonic '" + Base + "'",
-                   Op->getLocRange(), matchingInlineAsm);
+                   Ranges, matchingInlineAsm);
     }
 
     // Recover location info for the operand if we know which was the problem.