[all-commits] [llvm/llvm-project] 477e4b: [AST] Add generator for source location introspection
Stephen Kelly via All-commits
all-commits at lists.llvm.org
Sun Mar 14 15:36:56 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 477e4b974653f92960c0bf569d88da7baacef68a
https://github.com/llvm/llvm-project/commit/477e4b974653f92960c0bf569d88da7baacef68a
Author: Stephen Kelly <steveire at gmail.com>
Date: 2021-03-14 (Sun, 14 Mar 2021)
Changed paths:
A clang/include/clang/Tooling/NodeIntrospection.h
M clang/lib/Tooling/CMakeLists.txt
A clang/lib/Tooling/DumpTool/APIData.h
A clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
A clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
A clang/lib/Tooling/DumpTool/CMakeLists.txt
A clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
A clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
A clang/lib/Tooling/NodeIntrospection.cpp
M clang/unittests/CMakeLists.txt
A clang/unittests/Introspection/CMakeLists.txt
A clang/unittests/Introspection/IntrospectionTest.cpp
M llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
A llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
M llvm/utils/gn/secondary/clang/unittests/BUILD.gn
A llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn
Log Message:
-----------
[AST] Add generator for source location introspection
Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.
Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.
This new API can be used to implement 'srcloc' output in clang-query:
http://ce.steveire.com/z/m_kTIo
The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:
https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching
In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc. Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.
Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively. Currently a
break on any platform causes a revert of the entire feature. This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.
Differential Revision: https://reviews.llvm.org/D93164
More information about the All-commits
mailing list