This is an archive of the discontinued LLVM Phabricator instance.

[Syntax] Build nodes for template declarations.
ClosedPublic

Authored by ilya-biryukov on Jan 7 2020, 7:16 AM.

Details

Reviewers
gribozavr2
Summary

Handles template declaration of all kinds.

Also builds template declaration nodes for specializations and explicit
instantiations of classes.

Some missing things will be addressed in the follow-up patches:

  • specializations of functions and variables,
  • template parameters.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Jan 7 2020, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2020, 7:16 AM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: diff.json, console-log.txt

Unit tests: pass. 61849 tests passed, 0 failed and 781 were skipped.

clang-tidy: unknown.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

gribozavr2 accepted this revision.Jan 15 2020, 12:20 PM
gribozavr2 added inline comments.
clang/lib/Tooling/Syntax/BuildTree.cpp
190

Three slashes for docs.

clang/unittests/Tooling/Syntax/TreeTest.cpp
738

Could you also add an out-of-line definition of X::foo? It will have two template parameter lists, which is a special case.

This revision is now accepted and ready to land.Jan 15 2020, 12:20 PM
gribozavr2 added inline comments.Jan 15 2020, 12:21 PM
clang/lib/Tooling/Syntax/BuildTree.cpp
930

Why is this range maybe-delayed?

hlopko added a subscriber: hlopko.Mar 18 2020, 2:38 AM

Let's continue the review at https://reviews.llvm.org/D76346.

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

Done.

930

E.g because template <class T> struct cls {}; is doesn't need delaying, but template <class T> int var = 10;` does (SimpleDeclaration is processed before Declarator). I'll try to come up with a more fitting design after I submit this and https://reviews.llvm.org/D72446.

clang/unittests/Tooling/Syntax/TreeTest.cpp
738

Example:

template <class T>
struct X {

template <class U>
U foo();

};

template <class T>
template <class U>
U X<T>::foo() {}

Discussed offline, RAV doesn't visit TemplateParameters and therefore we're not creating a node for the first template parameter (in bold). We could overcome this in the BuildTree.cpp, but more principled solution would be to teach RAV to visit TemplateParameters. In a separate patch.

gribozavr2 closed this revision.Mar 18 2020, 7:59 AM