diff --git a/frontend/include/chpl/uast/all-location-maps.h b/frontend/include/chpl/uast/all-location-maps.h index a5144f3e19be..0537c6a08c1a 100644 --- a/frontend/include/chpl/uast/all-location-maps.h +++ b/frontend/include/chpl/uast/all-location-maps.h @@ -28,7 +28,7 @@ LOCATION_MAP(NamedDecl, DeclName) LOCATION_MAP(Loop, LoopHeader) LOCATION_MAP(AstNode, BlockHeader) LOCATION_MAP(NamedDecl, DeclHeader) -LOCATION_MAP(AstNode, ExprParenth) +LOCATION_MAP(AstNode, ExprParen) LOCATION_MAP(AstNode, CurlyBraces) // LOCATION_MAP(AstNode, NamedActual) // LOCATION_MAP(AstNode, AttributeNamedActual) diff --git a/frontend/lib/parsing/ParserContextImpl.h b/frontend/lib/parsing/ParserContextImpl.h index b89d7cb459e5..384b5360c4aa 100644 --- a/frontend/lib/parsing/ParserContextImpl.h +++ b/frontend/lib/parsing/ParserContextImpl.h @@ -1865,7 +1865,7 @@ owned ParserContext::buildLoopIndexDecl(YYLTYPE location, /*typeExpression*/ nullptr, /*initExpression*/ nullptr); builder->noteDeclNameLocation(var.get(), convLoc); - builder->copyExprParenthLocation(e, var.get()); + builder->copyExprParenLocation(e, var.get()); builder->deleteAllLocations(e); // Delete the location of 'e' because it's about to be deallocated; // we don't want a new allocation of an AST node to have the same pointer @@ -1895,8 +1895,8 @@ owned ParserContext::buildLoopIndexDecl(YYLTYPE location, std::move(elements), /*typeExpression*/ nullptr, /*initExpression*/ nullptr); - builder->copyExprParenthLocation(e, td.get()); - builder->deleteExprParenthLocation(e); + builder->copyExprParenLocation(e, td.get()); + builder->deleteExprParenLocation(e); // See the comment above for why we delete the location of 'e'. return td; } else { @@ -1988,8 +1988,8 @@ FnCall* ParserContext::wrapCalledExpressionInNew(YYLTYPE location, auto newExpr = New::build(builder, convertLocation(location), toOwned(calledExpr), management); - builder->copyExprParenthLocation(fnCall, newExpr.get()); - builder->deleteExprParenthLocation(fnCall); + builder->copyExprParenLocation(fnCall, newExpr.get()); + builder->deleteExprParenLocation(fnCall); child = std::move(newExpr); // Extend the location of the call to the left and patch the location. diff --git a/frontend/lib/parsing/bison-chpl-lib.cpp b/frontend/lib/parsing/bison-chpl-lib.cpp index a2b72ec092bb..c1a0c319329d 100644 --- a/frontend/lib/parsing/bison-chpl-lib.cpp +++ b/frontend/lib/parsing/bison-chpl-lib.cpp @@ -8524,7 +8524,7 @@ YYLTYPE yylloc = yyloc_default; case 363: /* fn_decl_receiver_expr: TLP expr TRP */ #line 2561 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-1].expr), LOC((yyloc))); + BUILDER->tryNoteExprParenLocation((yyvsp[-1].expr), LOC((yyloc))); (yyval.expr) = (yyvsp[-1].expr); } #line 8531 "bison-chpl-lib.cpp" @@ -9940,7 +9940,7 @@ YYLTYPE yylloc = yyloc_default; case 619: /* new_expr: TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP */ #line 3348 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-1].maybeNamedActualList), actuals, actualNames); @@ -9957,7 +9957,7 @@ YYLTYPE yylloc = yyloc_default; case 620: /* new_expr: TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP */ #line 3361 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-4].expr), LOC2((yylsp[-5]), (yylsp[-3]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-1].maybeNamedActualList), actuals, actualNames); @@ -9974,7 +9974,7 @@ YYLTYPE yylloc = yyloc_default; case 621: /* new_expr: TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP TQUESTION */ #line 3374 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-2].maybeNamedActualList), actuals, actualNames); @@ -9992,7 +9992,7 @@ YYLTYPE yylloc = yyloc_default; case 622: /* new_expr: TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP TQUESTION */ #line 3388 "chpl.ypp" { - BUILDER->tryNoteExprParenthLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); + BUILDER->tryNoteExprParenLocation((yyvsp[-5].expr), LOC2((yylsp[-6]), (yylsp[-4]))); AstList actuals; std::vector actualNames; context->consumeNamedActuals((yyvsp[-2].maybeNamedActualList), actuals, actualNames); @@ -10237,7 +10237,7 @@ YYLTYPE yylloc = yyloc_default; #line 3597 "chpl.ypp" { // Use 'tryNote' here in case an expression like ((x)) comes along. - BUILDER->tryNoteExprParenthLocation((yyvsp[-1].expr), LOC((yyloc))); + BUILDER->tryNoteExprParenLocation((yyvsp[-1].expr), LOC((yyloc))); (yyval.expr) = (yyvsp[-1].expr); } #line 10244 "bison-chpl-lib.cpp" diff --git a/frontend/lib/parsing/chpl.ypp b/frontend/lib/parsing/chpl.ypp index 786a2a83dad4..e745b7a0bcd1 100644 --- a/frontend/lib/parsing/chpl.ypp +++ b/frontend/lib/parsing/chpl.ypp @@ -2559,7 +2559,7 @@ fn_decl_receiver_expr: ident_expr | TLP expr TRP { - BUILDER->tryNoteExprParenthLocation($2, LOC(@$)); + BUILDER->tryNoteExprParenLocation($2, LOC(@$)); $$ = $2; } ; @@ -3346,7 +3346,7 @@ new_expr: see if we can remove them. */ | TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP %prec TNOELSE { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3359,7 +3359,7 @@ new_expr: } | TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP %prec TNOELSE { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3372,7 +3372,7 @@ new_expr: } | TNEW TOWNED TLP expr TRP TLP opt_actual_ls TRP TQUESTION { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3386,7 +3386,7 @@ new_expr: } | TNEW TSHARED TLP expr TRP TLP opt_actual_ls TRP TQUESTION { - BUILDER->tryNoteExprParenthLocation($4, LOC2(@3, @5)); + BUILDER->tryNoteExprParenLocation($4, LOC2(@3, @5)); AstList actuals; std::vector actualNames; context->consumeNamedActuals($7, actuals, actualNames); @@ -3596,7 +3596,7 @@ parenthesized_expr: TLP opt_try_expr TRP { // Use 'tryNote' here in case an expression like ((x)) comes along. - BUILDER->tryNoteExprParenthLocation($2, LOC(@$)); + BUILDER->tryNoteExprParenLocation($2, LOC(@$)); $$ = $2; } | TLP tuple_component TCOMMA TRP diff --git a/frontend/lib/uast/post-parse-checks.cpp b/frontend/lib/uast/post-parse-checks.cpp index b611672bba12..fb13e0d514c2 100644 --- a/frontend/lib/uast/post-parse-checks.cpp +++ b/frontend/lib/uast/post-parse-checks.cpp @@ -798,7 +798,7 @@ static void collectEqualPrecedenceOpsWithoutParens(Context* context, if (auto childOp = child->toOpCall()) { if (childOp->numActuals() == 2 && binOpPrecedence(childOp->op()) == prec) { // The child only counts as a 'problem' if it's not parenthesized. - if (parsing::locateExprParenthWithAst(context, childOp).line() == -1) { + if (parsing::locateExprParenWithAst(context, childOp).line() == -1) { collectEqualPrecedenceOpsWithoutParens(context, childOp, prec, ops, operands); return; } diff --git a/tools/chapel-py/src/method-tables/uast-methods.h b/tools/chapel-py/src/method-tables/uast-methods.h index 507a3cd2a8b3..172975e01505 100644 --- a/tools/chapel-py/src/method-tables/uast-methods.h +++ b/tools/chapel-py/src/method-tables/uast-methods.h @@ -108,9 +108,9 @@ CLASS_BEGIN(AstNode) std::optional, auto loc = chpl::parsing::locateCurlyBracesWithAst(context, node); return getValidLocation(loc)) - PLAIN_GETTER(AstNode, parenth_location, "Get the Location of the parentheses of this AstNode node", + PLAIN_GETTER(AstNode, paren_location, "Get the Location of the parentheses of this AstNode node", std::optional, - auto loc = chpl::parsing::locateExprParenthWithAst(context, node); + auto loc = chpl::parsing::locateExprParenWithAst(context, node); return getValidLocation(loc)) CLASS_END(AstNode) diff --git a/tools/chpl-language-server/src/symbol_signature.py b/tools/chpl-language-server/src/symbol_signature.py index a3c0d1572a36..5e300fc0e15d 100644 --- a/tools/chpl-language-server/src/symbol_signature.py +++ b/tools/chpl-language-server/src/symbol_signature.py @@ -357,7 +357,7 @@ def _fncall_to_string(call: chapel.FnCall) -> List[Component]: comps.extend(_wrap_in(call_args, (openbr, closebr))) - comps = _wrap_in(comps, ("(", ")")) if call.parenth_location() else comps + comps = _wrap_in(comps, ("(", ")")) if call.paren_location() else comps return comps @@ -418,7 +418,7 @@ def is_postfix(op: str) -> bool: comps.extend(_node_to_string(call.actual(0))) comps.append(_wrap_str(bop_to_string(call.op()))) comps.extend(_node_to_string(call.actual(1))) - comps = _wrap_in(comps, ("(", ")")) if call.parenth_location() else comps + comps = _wrap_in(comps, ("(", ")")) if call.paren_location() else comps return comps diff --git a/tools/chplcheck/src/rules.py b/tools/chplcheck/src/rules.py index c7192002098d..b6e66f2748d0 100644 --- a/tools/chplcheck/src/rules.py +++ b/tools/chplcheck/src/rules.py @@ -292,7 +292,7 @@ def ControlFlowParentheses( return True # No parentheses to speak of - paren_loc = subject.parenth_location() + paren_loc = subject.paren_location() if paren_loc is None: return True @@ -305,7 +305,7 @@ def RemoveControlFlowParentheses(context: Context, result: BasicRuleResult): # Since we're here, these should already be non-None. subject = result.data assert subject - paren_loc = subject.parenth_location() + paren_loc = subject.paren_location() assert paren_loc # If parentheses span multiple lines, don't provide a fixit,