summaryrefslogtreecommitdiffstats
path: root/clang/lib/Tooling/Syntax/BuildTree.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Syntax] Assert invariants on tree structure and fix a bug in mutationsIlya Biryukov2020-01-141-1/+3
| | | | | | | | Add checks for some structural invariants when building and mutating the syntax trees. Fix a bug failing the invariants after mutations: the parent of nodes added into the tree was null.
* [Syntax] Build spanning SimpleDecalration for classes, structs, etcIlya Biryukov2020-01-031-3/+7
| | | | | | | When they are free-standing, e.g. `struct X;` or `struct X {};`. Although this complicates the common case (of free-standing class declarations), this ensures the less common case (e.g. `struct X {} a;`) are handled uniformly and produce similar syntax trees.
* [Syntax] Use a hash table to search for tokens by their locationIlya Biryukov2019-12-181-9/+10
| | | | | | | | This is both more efficient and avoids corner cases in `SourceManager::isBeforeInTranslationUnit`. The change is trivial and clearly a performance improvement on the hot path of building the syntax tree, so sending without review.
* [Syntax] Allow to mutate syntax treesIlya Biryukov2019-12-181-10/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds facilities to mutate the syntax trees and produce corresponding text replacements. The public interface of the syntax library now includes facilities to: 1. perform type-safe modifications of syntax trees, 2. compute textual replacements to apply the modifications, 3. create syntax trees not backed by the source code. For each of the three, we only add a few example transformations in this patch to illustrate the idea, support for more kinds of nodes and transformations will be done in follow-up patches. The high-level mutation operations are implemented on top of operations that allow to arbitrarily change the trees. They are considered to be implementation details and are not available to the users of the library. Reviewers: sammccall, gribozavr2 Reviewed By: gribozavr2 Subscribers: merge_guards_bot, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64573
* [Syntax] Build nodes for simple cases of top level declarationsIlya Biryukov2019-12-121-1/+74
| | | | | | | | | | | | | | | | Summary: More complicated nodes (e.g. template declarations) will be implemented in the follow-up patches. Reviewers: gribozavr2 Reviewed By: gribozavr2 Subscribers: merge_guards_bot, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70856
* [Syntax] Build SimpleDeclaration node that groups multiple declaratorsIlya Biryukov2019-11-291-35/+136
| | | | | | | | | | | | | | | | | | | | Summary: Also remove the temporary TopLevelDeclaration node and add UnknownDeclaration to represent other unknown nodes. See the follow-up change for building more top-level declarations. Adding declarators is also pretty involved and will be done in another follow-up patch. Reviewers: gribozavr2 Reviewed By: gribozavr2 Subscribers: merge_guards_bot, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70787
* [Syntax] Add a comment explaining the pointer keys in std::map<Token*, ...>. NFCIlya Biryukov2019-11-291-0/+2
|
* [Syntax] Remove unused parameter from `TreeBuilder::markChildToken`. NFCIlya Biryukov2019-11-291-20/+15
|
* [Syntax] Silence "unused function" warning in no-assert builds. NFCIlya Biryukov2019-11-071-0/+2
| | | | A helper `isImpicitExpr` is only used inside assert.
* [Syntax] Add nodes for most common statementsIlya Biryukov2019-11-061-6/+204
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Most of the statements mirror the ones provided by clang AST. Major differences are: - expressions are wrapped into 'ExpressionStatement' instead of being a subclass of statement, - semicolons are always consumed by the leaf expressions (return, expression satement, etc), - some clang statements are not handled yet, we wrap those into an UnknownStatement class, which is not present in clang. We also define an 'Expression' and 'UnknownExpression' classes in order to produce 'ExpressionStatement' where needed. The actual implementation of expressions is not yet ready, it will follow later. Reviewers: sammccall Reviewed By: sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63835
* [Syntax] Do not add a node for 'eof' into the treeIlya Biryukov2019-08-061-4/+8
| | | | | | | | | | | | | | | | | | Summary: While useful as a sentinel value when iterating over tokens, having 'eof' in the tree, seems to do more harm than good. Reviewers: sammccall Reviewed By: sammccall Subscribers: javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64576 llvm-svn: 368062
* [Syntax] Move roles into a separate enumIlya Biryukov2019-07-091-4/+6
| | | | | | To align with reviewer's suggestions. llvm-svn: 365479
* Reland r365355: [Syntax] Introduce syntax treesIlya Biryukov2019-07-091-0/+271
| | | | | | With a fix to a PS4 buildbot crash. llvm-svn: 365466
* Revert rL365355 : [Syntax] Introduce syntax treesSimon Pilgrim2019-07-091-271/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: A tooling-focused alternative to the AST. This commit focuses on the memory-management strategy and the structure of the AST. More to follow later: - Operations to mutate the syntax trees and corresponding textual replacements. - Mapping between clang AST nodes and syntax tree nodes. - More node types corresponding to the language constructs. Reviewers: sammccall Reviewed By: sammccall Subscribers: llvm-commits, mgorny, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61637 ........ Fixes buildbots which were crashing on SyntaxTests.exe llvm-svn: 365465
* Add parentheses to silence warnings.Bill Wendling2019-07-081-6/+6
| | | | llvm-svn: 365395
* [Syntax] Introduce syntax treesIlya Biryukov2019-07-081-0/+271
Summary: A tooling-focused alternative to the AST. This commit focuses on the memory-management strategy and the structure of the AST. More to follow later: - Operations to mutate the syntax trees and corresponding textual replacements. - Mapping between clang AST nodes and syntax tree nodes. - More node types corresponding to the language constructs. Reviewers: sammccall Reviewed By: sammccall Subscribers: llvm-commits, mgorny, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61637 llvm-svn: 365355
OpenPOWER on IntegriCloud