Skip to content

Updated TupleExpr's getSourceRange to inspect child elements source ranges #5321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 18, 2016
Merged

Updated TupleExpr's getSourceRange to inspect child elements source ranges #5321

merged 2 commits into from
Oct 18, 2016

Conversation

mxswd
Copy link
Contributor

@mxswd mxswd commented Oct 16, 2016

In a TupleExpr, if the parens are both invalid, then you can only have a
valid range iff both the first element and last element have valid ranges.
Source ranges also have the property:
  Start.isValid() == End.isValid()
For example, given the buffer "one", of the form:
(tuple_expr
  (declref_expr range=[test.swift:1:0 - line:1:2] ...)
  (declref_expr range=invalid ...))
the range of this TupleExpr is SourceLoc() (invalid).
      v invalid                v invalid
      (     one,         two   )
      valid ^    invalid ^
COL:  xxxxxx012xxxxxxxxxxxxxxxxx
but the SourceRange of 'one' is 1:0 - 1:2.

Also added triple and quadruple tests.

@mxswd
Copy link
Contributor Author

mxswd commented Oct 16, 2016

@jrose-apple thoughts?

@jrose-apple
Copy link
Contributor

Looks good. Can you add a test for a tuple of all-invalid-location elements?

@mxswd
Copy link
Contributor Author

mxswd commented Oct 17, 2016

Yup sure thing.

@mxswd
Copy link
Contributor Author

mxswd commented Oct 18, 2016

I do already have a test for a tuple of invalid source ranges.

SmallVector<Expr *, 2> subExprsInvalid({ two, three });
SmallVector<Identifier, 2> subExprNamesInvalid(2, Identifier());
auto allInvalid = TupleExpr::createImplicit(C.Ctx, subExprsInvalid, subExprNamesInvalid);

But I did notice I had a typo in one of the strings.

@jrose-apple
Copy link
Contributor

Ah, whoops. Sorry to miss that.

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test and merge

1 similar comment
@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test and merge

@shahmishal shahmishal merged commit f08601f into swiftlang:master Oct 18, 2016
@mxswd mxswd deleted the tuple-expr-sourcerange branch October 18, 2016 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants