llvm.org GIT mirror llvm / ba69b36
Reapply r179115, but use parsePrimaryExpression a little more judiciously. Test cases that regressed due to r179115, plus a few more, were added in r179182. Original commit message below: [ms-inline asm] Use parsePrimaryExpr in lieu of parseExpression if we need to parse an identifier. Otherwise, parseExpression may parse multiple tokens, which makes it impossible to properly compute an immediate displacement. An example of such a case is the source operand (i.e., [Symbol + ImmDisp]) in the below example: __asm mov eax, [Symbol + ImmDisp] Part of rdar://13611297 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179187 91177308-0d34-0410-b5e6-96231b3b80d8 Chad Rosier 7 years ago
3 changed file(s) with 15 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
150150 virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
151151 bool parseExpression(const MCExpr *&Res);
152152
153 /// parsePrimaryExpr - Parse a primary expression.
154 ///
155 /// @param Res - The value of the expression. The result is undefined
156 /// on error.
157 /// @result - False on success.
158 virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) = 0;
159
153160 /// parseParenExpression - Parse an arbitrary expression, assuming that an
154161 /// initial '(' has already been consumed.
155162 ///
220220
221221 bool parseExpression(const MCExpr *&Res);
222222 virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc);
223 virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc);
223224 virtual bool parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
224225 virtual bool parseAbsoluteExpression(int64_t &Res);
225226
866867 bool AsmParser::parseExpression(const MCExpr *&Res) {
867868 SMLoc EndLoc;
868869 return parseExpression(Res, EndLoc);
870 }
871
872 bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
873 return ParsePrimaryExpr(Res, EndLoc);
869874 }
870875
871876 const MCExpr *
11811181 SM.onRegister(TmpReg);
11821182 UpdateLocLex = false;
11831183 break;
1184 } else if (!getParser().parseExpression(Disp, End)) {
1184 } else if (!getParser().parsePrimaryExpr(Disp, End)) {
11851185 SM.onDispExpr();
11861186 UpdateLocLex = false;
11871187 break;
14001400
14011401 const MCExpr *Val;
14021402 SMLoc Start = Tok.getLoc(), End;
1403 if (getParser().parseExpression(Val, End))
1403 if (getParser().parsePrimaryExpr(Val, End))
14041404 return ErrorOperand(Start, "Unable to parse expression!");
14051405
14061406 // Don't emit the offset operator.
14361436
14371437 const MCExpr *Val;
14381438 SMLoc Start = Tok.getLoc(), End;
1439 if (getParser().parseExpression(Val, End))
1439 if (getParser().parsePrimaryExpr(Val, End))
14401440 return 0;
14411441
14421442 unsigned Length = 0, Size = 0, Type = 0;