llvm-project/clang/tools
Sean Callanan 7d982509b8 Testbed and skeleton of a new expression parser
Recommitted after formal approval.

LLVM's JIT is now the foundation of dynamic-compilation features for many languages. Clang also has low-level support for dynamic compilation (ASTImporter and ExternalASTSource, notably). How the compiler is set up for dynamic parsing is generally left up to individual clients, for example LLDB's C/C++/Objective-C expression parser and the ROOT project.

Although this arrangement offers external clients the flexibility to implement dynamic features as they see fit, the lack of an in-tree client means that subtle bugs can be introduced that cause regressions in the external clients but aren't caught by tests (or users) until much later. LLDB for example regularly encounters complicated ODR violation scenarios where it is not immediately clear who is at fault.

Other external clients (notably, Cling) rely on similar functionality, and another goal is to break this functionality up into composable parts so that any client can be built easily on top of Clang without requiring extensive additional code.

I propose that the parts required to build a simple expression parser be added to Clang. Initially, I aim to have the following features:

A piece that looks up external declarations from a variety of sources (e.g., from previous dynamic compilations, from modules, or from DWARF) and uses clear conflict resolution rules to reconcile differences, with easily understood errors. This functionality will be supported by in-tree tests.
A piece that works hand in hand with the LLVM JIT to resolve the locations of external declarations so that e.g. variables can be redeclared and (for high-performance applications like DTrace) external variables can be accessed directly from the registers where they reside.
This commit adds a tester that parses a sequence of source files and then uses them as source data for an expression. External references are resolved using an ExternalASTSource that responds to name queries using an ASTImporter. This is the setup that LLDB uses, and the motivating reason for MinimalImport in ASTImporter. When complete, this tester will implement the first of the above goals.

Differential Revision: https://reviews.llvm.org/D27180

llvm-svn: 290367
2016-12-22 20:03:14 +00:00
..
arcmt-test [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
c-arcmt-test Remove autoconf support 2016-01-26 21:30:40 +00:00
c-index-test [libclang] Restore the CXXRecordDecl path for clang_Type_getNumTemplateArguments and clang_Type_getTemplateArgumentAsType 2016-12-16 21:40:16 +00:00
clang-check Frontend: Simplify ownership model for clang's output streams. 2016-07-15 00:55:40 +00:00
clang-format clang-format: Separate out a language kind for ObjC. 2016-12-12 12:42:29 +00:00
clang-format-vs clang-format-vsix: add command to format document 2016-12-16 01:51:43 +00:00
clang-fuzzer Add missing header in ClangFuzzer (after r275882 cleanup) 2016-07-18 20:33:09 +00:00
clang-import-test Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
clang-offload-bundler [CMake] Fixing clang standalone build 2016-11-19 21:14:59 +00:00
diag-build Briefly document diag-build.sh 2013-12-28 21:59:11 +00:00
diagtool [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
driver [clang] Fix D26214: Move error handling out of MC and to the callers. 2016-12-06 02:49:16 +00:00
libclang [c++1z] P0195R2: Support pack-expansion of using-declarations. 2016-12-20 21:35:28 +00:00
scan-build scan-build: Add an option to show the description in the list of defect 2016-08-01 08:04:45 +00:00
scan-build-py [analyzer][scan-build-py] subprocess output handling reviewed in clang module 2016-09-24 00:20:59 +00:00
scan-view Remove autoconf support 2016-01-26 21:30:40 +00:00
CMakeLists.txt Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00