diff options
author | Eduardo Caldas <ecaldas@google.com> | 2020-08-07 18:42:35 +0000 |
---|---|---|
committer | Eduardo Caldas <ecaldas@google.com> | 2020-08-10 15:47:20 +0000 |
commit | f9500cc487573c55ea37b4ee6e9162d115753a48 (patch) | |
tree | 0a11d0017b62ec073d21fc4823fc669e1c275947 /clang/unittests/Tooling/Syntax/TreeTest.cpp | |
parent | 7406eb4f6afd8df9bd4dbb918f5e7005ba71d58c (diff) | |
download | llvm-f9500cc487573c55ea37b4ee6e9162d115753a48.zip llvm-f9500cc487573c55ea37b4ee6e9162d115753a48.tar.gz llvm-f9500cc487573c55ea37b4ee6e9162d115753a48.tar.bz2 |
[SyntaxTree] Expand support for `NestedNameSpecifier`
Summary:
We want NestedNameSpecifier syntax nodes to be generally supported, not
only for `DeclRefExpr` and `DependentScopedDeclRefExpr`.
To achieve this we:
* Use the `RecursiveASTVisitor`'s API to traverse
`NestedNameSpecifierLoc`s and automatically create its syntax nodes
* Add links from the `NestedNameSpecifierLoc`s to their syntax nodes.
In this way, from any semantic construct that has a `NestedNameSpecifier`,
we implicitly generate its syntax node via RAV and we can easily access
this syntax node via the links we added.
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/Syntax/TreeTest.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index fa5da1f..4610166 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -2973,7 +2973,8 @@ using namespace ::ns; `-UsingNamespaceDirective |-using |-namespace - |-:: + |-NestedNameSpecifier + | `-:: |-ns `-; )txt")); @@ -3002,8 +3003,10 @@ using ns::a; | `-} `-UsingDeclaration |-using - |-ns - |-:: + |-NestedNameSpecifier + | |-IdentifierNameSpecifier + | | `-ns + | `-:: |-a `-; )txt")); @@ -3207,11 +3210,13 @@ template <class T> struct X<T>::Y {}; |-> `-SimpleDeclaration |-struct - |-X - |-< - |-T - |-> - |-:: + |-NestedNameSpecifier + | |-SimpleTemplateNameSpecifier + | | |-X + | | |-< + | | |-T + | | `-> + | `-:: |-Y |-{ |-} @@ -3245,15 +3250,19 @@ template <class T> struct X { |-{ |-UsingDeclaration | |-using - | |-T - | |-:: + | |-NestedNameSpecifier + | | |-IdentifierNameSpecifier + | | | `-T + | | `-:: | |-foo | `-; |-UsingDeclaration | |-using | |-typename - | |-T - | |-:: + | |-NestedNameSpecifier + | | |-IdentifierNameSpecifier + | | | `-T + | | `-:: | |-bar | `-; |-} |