Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mlir
diff options
context:
space:
mode:
authorRiver Riddle <riddleriver@gmail.com>2022-05-18 03:49:28 +0300
committerRiver Riddle <riddleriver@gmail.com>2022-05-18 10:23:47 +0300
commit6d4471efb0b94c066e5e93c99278397691869dbc (patch)
tree536cb1dcfc4bad1b0a46d5f7759fab9763d3621b /mlir
parente213e5a999dbaa3c1aa97a6f81b77a3358b00b2a (diff)
[mlir:PDLL] Improve the location ranges of several expressions during parsing
This allows for the range to encompass more of the source associated with the full expression, making diagnostics easier to see/tooling easier/etc.
Diffstat (limited to 'mlir')
-rw-r--r--mlir/lib/Tools/PDLL/Parser/Parser.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
index f2406bae5d48..8efc3d0fce7b 100644
--- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp
+++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp
@@ -1766,6 +1766,7 @@ FailureOr<ast::Expr *> Parser::parseAttributeExpr() {
std::string attrExpr = curToken.getStringValue();
consumeToken();
+ loc.End = curToken.getEndLoc();
if (failed(
parseToken(Token::greater, "expected `>` after attribute literal")))
return failure();
@@ -1773,7 +1774,6 @@ FailureOr<ast::Expr *> Parser::parseAttributeExpr() {
}
FailureOr<ast::Expr *> Parser::parseCallExpr(ast::Expr *parentExpr) {
- SMRange loc = curToken.getLoc();
consumeToken(Token::l_paren);
// Parse the arguments of the call.
@@ -1792,7 +1792,8 @@ FailureOr<ast::Expr *> Parser::parseCallExpr(ast::Expr *parentExpr) {
arguments.push_back(*argument);
} while (consumeIf(Token::comma));
}
- loc.End = curToken.getEndLoc();
+
+ SMRange loc(parentExpr->getLoc().Start, curToken.getEndLoc());
if (failed(parseToken(Token::r_paren, "expected `)` after argument list")))
return failure();
@@ -1846,7 +1847,7 @@ FailureOr<ast::Expr *> Parser::parseInlineRewriteLambdaExpr() {
}
FailureOr<ast::Expr *> Parser::parseMemberAccessExpr(ast::Expr *parentExpr) {
- SMRange loc = curToken.getLoc();
+ SMRange dotLoc = curToken.getLoc();
consumeToken(Token::dot);
// Check for code completion of the member name.
@@ -1857,8 +1858,9 @@ FailureOr<ast::Expr *> Parser::parseMemberAccessExpr(ast::Expr *parentExpr) {
Token memberNameTok = curToken;
if (memberNameTok.isNot(Token::identifier, Token::integer) &&
!memberNameTok.isKeyword())
- return emitError(loc, "expected identifier or numeric member name");
+ return emitError(dotLoc, "expected identifier or numeric member name");
StringRef memberName = memberNameTok.getSpelling();
+ SMRange loc(parentExpr->getLoc().Start, curToken.getEndLoc());
consumeToken();
return createMemberAccessExpr(parentExpr, memberName, loc);
@@ -2099,6 +2101,7 @@ FailureOr<ast::Expr *> Parser::parseTypeExpr() {
std::string attrExpr = curToken.getStringValue();
consumeToken();
+ loc.End = curToken.getEndLoc();
if (failed(parseToken(Token::greater, "expected `>` after type literal")))
return failure();
return ast::TypeExpr::create(ctx, loc, attrExpr);