This is an archive of the discontinued LLVM Phabricator instance.

[SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes
ClosedPublic

Authored by eduucaldas on Jul 22 2020, 10:50 AM.

Details

Diff Detail

Event Timeline

eduucaldas created this revision.Jul 22 2020, 10:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2020, 10:50 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
eduucaldas marked 6 inline comments as done.
eduucaldas added inline comments.
clang/include/clang/Tooling/Syntax/Nodes.h
101–105

All of this is ephemeral, we are gonna have just one Name Specifier with a PointerUnion.

204–258

(bis) All of this is temporary, we are gonna have just one Name Specifier with a PointerUnion.

clang/lib/Tooling/Syntax/BuildTree.cpp
763–764

We extracted the logic into getUnqualifiedSourceRange

843–862

This is the same logic as DeclRefExpr! Exacly the same code!
DependentScopeDeclRefExpr is important because it enables T::template S<U>::

clang/lib/Tooling/Syntax/Nodes.cpp
119–127

(bis) All of this is temporary, we are gonna have just one Name Specifier with a PointerUnion.

clang/unittests/Tooling/Syntax/TreeTest.cpp
964–970

I noticed that we don't need that as everything is dependent on the template anyways

Update API to new nested-name-specifier grammar rule

What is this diff based on? On the left I see, for example, NamespaceNameSpecifier, which is not in the repository yet.

clang/lib/Tooling/Syntax/BuildTree.cpp
746–821

s/treat/support/

Also, use llvm::report_fatal_error instead? assert is not supposed to ever trigger.

  • Improve getLocalSourceRange
  • nested-name-specifier is now a ::-separated list of name-specifiers
  • Remove UnknownNameSpecifier, answer to comments
eduucaldas marked an inline comment as done.Jul 24 2020, 10:20 AM
gribozavr2 added inline comments.Jul 24 2020, 12:10 PM
clang/include/clang/Tooling/Syntax/Nodes.h
297

You can remove this todo now.

clang/lib/Tooling/Syntax/BuildTree.cpp
748

Please use isa<DecltypeType>(T) and inline this expression into its only user.

753

Ditto, please use isa and inline into the only user.

803

... except in the case of incorrect code. Feel free to just add a TODO.

819

Please use isa<GlobalNameSpecifier>(NS).

821

Could you add an overload for foldNode that takes a NestedNameSpecifierLoc but ignores it, just like we have an overload of foldNode that takes a TypeLoc but ignores it?

831

Please don't use C++17, Clang uses C++14 now.

834

WDYM by "upstream"?

clang/unittests/Tooling/Syntax/TreeTest.cpp
879–881

TS => ST (struct template?)

885

ST

eduucaldas marked 9 inline comments as done.
  • Answer code review
  • Simpler logic for getUnqualifiedIdSourceRange and inline it
  • Remove ambiguously named variable NNS
eduucaldas marked 2 inline comments as done.Jul 27 2020, 7:09 AM
eduucaldas added inline comments.
clang/lib/Tooling/Syntax/BuildTree.cpp
834

I meant to put that logic under the DeclRefExpr node, instead of here. But I found a way of writing this logic in a simpler way :). So I just inlined it!

eduucaldas marked an inline comment as done.Jul 27 2020, 7:09 AM
gribozavr2 accepted this revision.Jul 27 2020, 10:00 AM
This revision is now accepted and ready to land.Jul 27 2020, 10:00 AM
eduucaldas updated this revision to Diff 283622.Aug 6 2020, 8:47 AM
  • Update comments to reflect change in API.
eduucaldas added inline comments.Aug 6 2020, 10:45 AM
clang/lib/Tooling/Syntax/BuildTree.cpp
784

Newbie mistake. Corrected in latter commit

eduucaldas updated this revision to Diff 283875.Aug 7 2020, 5:19 AM

rebase to add this commit from a further patch

  • [SyntaxTree] Fix crash on name specifier.
gribozavr2 accepted this revision.Aug 7 2020, 5:44 AM

Last version sent upstream

eduucaldas retitled this revision from WIP: Add complete id-expression support to syntax trees to [SyntaxTree] Use simplified grammar rule for `NestedNameSpecifier` grammar nodes.Aug 10 2020, 2:47 AM
eduucaldas edited the summary of this revision. (Show Details)