[all-commits] [llvm/llvm-project] 1ad150: [Syntax] Allow to mutate syntax trees

Ilya Biryukov via All-commits all-commits at lists.llvm.org
Wed Dec 18 03:20:07 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 1ad15046dcf6ff8bafc4a1ea13f214f8d6ba7de6
      https://github.com/llvm/llvm-project/commit/1ad15046dcf6ff8bafc4a1ea13f214f8d6ba7de6
  Author: Ilya Biryukov <ibiryukov at google.com>
  Date:   2019-12-18 (Wed, 18 Dec 2019)

  Changed paths:
    M clang/include/clang/Tooling/Syntax/BuildTree.h
    A clang/include/clang/Tooling/Syntax/Mutations.h
    M clang/include/clang/Tooling/Syntax/Tokens.h
    M clang/include/clang/Tooling/Syntax/Tree.h
    M clang/lib/Tooling/Syntax/BuildTree.cpp
    M clang/lib/Tooling/Syntax/CMakeLists.txt
    A clang/lib/Tooling/Syntax/ComputeReplacements.cpp
    A clang/lib/Tooling/Syntax/Mutations.cpp
    A clang/lib/Tooling/Syntax/Synthesis.cpp
    M clang/lib/Tooling/Syntax/Tokens.cpp
    M clang/lib/Tooling/Syntax/Tree.cpp
    M clang/unittests/Tooling/Syntax/CMakeLists.txt
    M clang/unittests/Tooling/Syntax/TreeTest.cpp

  Log Message:
  -----------
  [Syntax] Allow to mutate syntax trees

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




More information about the All-commits mailing list