Migrate Declarators to use the List API
authorEduardo Caldas <ecaldas@google.com>
Mon, 28 Sep 2020 09:33:11 +0000 (09:33 +0000)
committerEduardo Caldas <ecaldas@google.com>
Thu, 1 Oct 2020 13:56:31 +0000 (13:56 +0000)
commit5011d43108d1de30a056d66e73fa19062e0e84b7
treef29368155c36ee8b4c6bd62226dd3129757e7a9a
parent79fbcbff41734e3d07e6200d33c3e40732dfae6a
Migrate Declarators to use the List API

After this change all nodes that have a delimited-list are using the
`List` API.

Implementation details:
Let's look at a declaration with multiple declarators:
`int a, b;`
To generate a declarator list node we need to have the range of
declarators: `a, b`:
However, the `ClangAST` actually stores them as separate declarations:
`int a   ;`
`int    b;`
We solve that by appropriately marking the declarators on each separate
declaration in the `ClangAST` and then for the final declarator `int
b`, shrinking its range to fit to the already marked declarators.

Differential Revision: https://reviews.llvm.org/D88403
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Nodes.cpp
clang/lib/Tooling/Syntax/Synthesis.cpp
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
clang/unittests/Tooling/Syntax/SynthesisTest.cpp