This is an archive of the discontinued LLVM Phabricator instance.

Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen.
ClosedPublic

Authored by oontvoo on Jul 9 2020, 8:20 PM.

Diff Detail

Event Timeline

oontvoo created this revision.Jul 9 2020, 8:20 PM
Herald added a project: Restricted Project. · View Herald Transcript
gribozavr2 accepted this revision.Jul 10 2020, 9:50 AM

Could you take a look at test failures and check if they are relevant? linux > Clang.AST::ast-dump-attr.cpp looks extremely close to the area you're working on.

I'm not quite comfortable adding this code without unittests. We don't have a great way to unit test the AST, but I think we should try. I think clang/unittests/AST/MatchVerifier.h could help here. The test could match a while loop with AST matchers, and then assert that the source locations are what we expect. The while loop could come from the code directly, or be instantiated from a template; also test what happens for parse errors.

clang/include/clang/AST/Stmt.h
2292–2293

I'd prefer to unabbreviate here. (use LParenLoc as well)

2301–2302

I'd prefer to unabbreviate here. (use LParenLoc as well)

This revision is now accepted and ready to land.Jul 10 2020, 9:50 AM
riccibruno requested changes to this revision.Jul 10 2020, 10:07 AM
riccibruno added a subscriber: riccibruno.
riccibruno added inline comments.
clang/lib/Serialization/ASTReaderStmt.cpp
275

The serialization part is missing (this is the reason for the test failures).

This revision now requires changes to proceed.Jul 10 2020, 10:07 AM
oontvoo updated this revision to Diff 277115.Jul 10 2020, 12:02 PM
oontvoo marked 3 inline comments as done.

Added unit test and the missing serialisation code

riccibruno accepted this revision.Jul 10 2020, 1:39 PM

No objection from me, but I am not a reviewer. I am just accepting this to cancel my comment on the missing serialization.

This revision is now accepted and ready to land.Jul 10 2020, 1:39 PM

No objection from me, but I am not a reviewer. I am just accepting this to cancel my comment on the missing serialization.

No worries. Thanks for your input!

I think Dmitri has already accepted this (pending additional test and variables renaming, which I've done).
I'm re-running the sanitizer tests to make sure it's not related then will commit, unless someone else would like to chime in ...

gribozavr2 accepted this revision.Jul 10 2020, 1:56 PM
This revision was automatically updated to reflect the committed changes.

Hi, your git commit contains extra Phabricator tags. You can drop Reviewers: Subscribers: Tags: and the text Summary: from the git commit with the following script:

arcfilter () {
        arc amend
        git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
}

Reviewed By: is considered important by some people. Please keep the tag. (--date=now is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time))

llvm/utils/git/pre-push.py can validate the message does not include unneeded tags.