diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-01-07 19:00:49 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-01-07 19:00:49 +0000 |
commit | e8f1eaea8ac513530fd7ce4c2f0d46cc77f9e540 (patch) | |
tree | b76e2384c32ecddf26166d3b0f3d80432143022f /llvm/lib/MC/MCParser/AsmParser.cpp | |
parent | 4fb504fec1a97be27e1130ab53aa169120339464 (diff) | |
download | bcm5719-llvm-e8f1eaea8ac513530fd7ce4c2f0d46cc77f9e540.tar.gz bcm5719-llvm-e8f1eaea8ac513530fd7ce4c2f0d46cc77f9e540.zip |
Change SMRange to be half-open (exclusive end) instead of closed (inclusive)
This is necessary not only for representing empty ranges, but for handling
multibyte characters in the input. (If the end pointer in a range refers to
a multibyte character, should it point to the beginning or the end of the
character in a char array?) Some of the code in the asm parsers was already
assuming this anyway.
llvm-svn: 171765
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index ab1210302dd..7eddd341f5a 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -732,7 +732,7 @@ bool AsmParser::ParseParenExpr(const MCExpr *&Res, SMLoc &EndLoc) { if (ParseExpression(Res)) return true; if (Lexer.isNot(AsmToken::RParen)) return TokError("expected ')' in parentheses expression"); - EndLoc = Lexer.getLoc(); + EndLoc = Lexer.getTok().getEndLoc(); Lex(); return false; } @@ -746,7 +746,7 @@ bool AsmParser::ParseBracketExpr(const MCExpr *&Res, SMLoc &EndLoc) { if (ParseExpression(Res)) return true; if (Lexer.isNot(AsmToken::RBrac)) return TokError("expected ']' in brackets expression"); - EndLoc = Lexer.getLoc(); + EndLoc = Lexer.getTok().getEndLoc(); Lex(); return false; } @@ -773,12 +773,12 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { case AsmToken::Dollar: case AsmToken::String: case AsmToken::Identifier: { - EndLoc = Lexer.getLoc(); - StringRef Identifier; if (ParseIdentifier(Identifier)) return true; + EndLoc = SMLoc::getFromPointer(Identifier.end()); + // This is a symbol reference. std::pair<StringRef, StringRef> Split = Identifier.split('@'); MCSymbol *Sym = getContext().GetOrCreateSymbol(Split.first); @@ -811,7 +811,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { SMLoc Loc = getTok().getLoc(); int64_t IntVal = getTok().getIntVal(); Res = MCConstantExpr::Create(IntVal, getContext()); - EndLoc = Lexer.getLoc(); + EndLoc = Lexer.getTok().getEndLoc(); Lex(); // Eat token. // Look for 'b' or 'f' following an Integer as a directional label if (Lexer.getKind() == AsmToken::Identifier) { @@ -823,7 +823,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { getContext()); if (IDVal == "b" && Sym->isUndefined()) return Error(Loc, "invalid reference to undefined symbol"); - EndLoc = Lexer.getLoc(); + EndLoc = Lexer.getTok().getEndLoc(); Lex(); // Eat identifier. } } @@ -833,6 +833,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { APFloat RealVal(APFloat::IEEEdouble, getTok().getString()); uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue(); Res = MCConstantExpr::Create(IntVal, getContext()); + EndLoc = Lexer.getTok().getEndLoc(); Lex(); // Eat token. return false; } @@ -842,7 +843,7 @@ bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) { MCSymbol *Sym = Ctx.CreateTempSymbol(); Out.EmitLabel(Sym); Res = MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_None, getContext()); - EndLoc = Lexer.getLoc(); + EndLoc = Lexer.getTok().getEndLoc(); Lex(); // Eat identifier. return false; } @@ -1753,7 +1754,7 @@ bool AsmParser::ParseMacroArgument(MacroArgument &MA, if (IsOperator(Lexer.getKind())) { // Check to see whether the token is used as an operator, // or part of an identifier - const char *NextChar = getTok().getEndLoc().getPointer() + 1; + const char *NextChar = getTok().getEndLoc().getPointer(); if (*NextChar == ' ') AddTokens = 2; } @@ -2982,7 +2983,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) { else if (Name == "epilogue_begin") Flags |= DWARF2_FLAG_EPILOGUE_BEGIN; else if (Name == "is_stmt") { - SMLoc Loc = getTok().getLoc(); + Loc = getTok().getLoc(); const MCExpr *Value; if (getParser().ParseExpression(Value)) return true; @@ -3001,7 +3002,7 @@ bool GenericAsmParser::ParseDirectiveLoc(StringRef, SMLoc DirectiveLoc) { } } else if (Name == "isa") { - SMLoc Loc = getTok().getLoc(); + Loc = getTok().getLoc(); const MCExpr *Value; if (getParser().ParseExpression(Value)) return true; |