From de5dac1c46226b61ce9921449dd9322b5ffcc41e Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Tue, 9 Feb 2010 01:00:18 +0000 Subject: [PATCH] Fixed a problem where the enhanced disassembly library was reporting inaccurate token IDs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95639 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/edis/EDToken.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/edis/EDToken.cpp b/tools/edis/EDToken.cpp index 6b67e624e8c..9408305d4bb 100644 --- a/tools/edis/EDToken.cpp +++ b/tools/edis/EDToken.cpp @@ -94,7 +94,8 @@ int EDToken::tokenize(std::vector &tokens, SmallVector parsedOperands; SmallVector asmTokens; - disassembler.parseInst(parsedOperands, asmTokens, str); + if(disassembler.parseInst(parsedOperands, asmTokens, str)) + return -1; SmallVectorImpl::iterator operandIterator; unsigned int operandIndex; @@ -167,7 +168,12 @@ int EDToken::tokenize(std::vector &tokens, if(operandIterator != parsedOperands.end() && tokenLoc.getPointer() >= (*operandIterator)->getStartLoc().getPointer()) { - token->setOperandID(operandOrder[operandIndex]); + /// operandIndex == 0 means the operand is the instruction (which the + /// AsmParser treats as an operand but edis does not). We therefore skip + /// operandIndex == 0 and subtract 1 from all other operand indices. + + if(operandIndex > 0) + token->setOperandID(operandOrder[operandIndex - 1]); } tokens.push_back(token); -- 2.34.1