llvm-project/clang/tools
Sean Callanan 967d438439 Add support for remembering origins to ExternalASTMerger
ExternalASTMerger has hitherto relied on being able to look up 
any Decl through its named DeclContext chain. This works for 
many cases, but causes problems for function-local structs, 
which cannot be looked up in their containing FunctionDecl. An
example case is

void f() {
  { struct S { int a; }; }
  { struct S { bool b; }; }
}

It is not possible to lookup either of the two Ses individually 
(or even to provide enough information to disambiguate) after 
parsing is over; and there is typically no need to, since they 
are invisible to the outside world.

However, ExternalASTMerger needs to be able to complete either 
S on demand. This led to an XFAIL on test/Import/local-struct, 
which this patch removes. The way the patch works is:

It defines a new data structure, ExternalASTMerger::OriginMap,
which clients are expected to maintain (default-constructing 
if the origin does not have an ExternalASTMerger servicing it)
As DeclContexts are imported, if they cannot be looked up by 
name they are placed in the OriginMap. This allows 
ExternalASTMerger to complete them later if necessary.
As DeclContexts are imported from an origin that already has 
its own OriginMap, the origins are forwarded – but only for 
those DeclContexts that are actually used. This keeps the 
amount of stored data minimal.

The patch also applies several improvements from review:

- Thoroughly documents the interface to ExternalASTMerger;
- Adds optional logging to help track what's going on; and
- Cleans up a bunch of braces and dangling elses.

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

llvm-svn: 314336
2017-09-27 19:57:58 +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 [index] Generate class & metaclass manglings for objc 2017-09-22 16:58:57 +00:00
clang-check Remove 'Filename' parameter from BeginSourceFileAction. 2017-06-09 01:36:10 +00:00
clang-diff [clang-diff] Properly clear the selection in HTML diff 2017-08-23 16:52:15 +00:00
clang-format Update for llvm change. 2017-09-08 00:01:26 +00:00
clang-format-vs clang-format plugin: Add missing NL (new line) at EOF (end of file) 2017-09-22 21:47:39 +00:00
clang-func-mapping Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00
clang-fuzzer [clang-proto-fuzzer] Fix clang-proto-to-cxx build. 2017-08-23 19:58:07 +00:00
clang-import-test Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
clang-offload-bundler Update for llvm change. 2017-09-08 00:01:26 +00:00
clang-refactor [refactor] Use CommonOptionsParser in clang-refactor 2017-09-14 13:16:14 +00:00
clang-rename clang-rename: let -force handle multiple renames 2017-09-11 20:18:38 +00:00
diag-build Briefly document diag-build.sh 2013-12-28 21:59:11 +00:00
diagtool Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00
driver Put target deduced from executable name at the start of argument list 2017-09-20 15:22:27 +00:00
libclang [index] Generate class & metaclass manglings for objc 2017-09-22 16:58:57 +00:00
scan-build [scan-build] Patch to scan-build tool to support "--target=<value>" flag 2017-05-26 19:25:32 +00:00
scan-build-py [scan-build-py] Patch to fix "-analyzer-config" option 2017-07-19 00:29:41 +00:00
scan-view Add coding and shebang. 2017-03-02 18:47:22 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00