llvm-project/clang/test/Import
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
..
clang-flags Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
conflicting-struct [ASTImporter] Improve handling of incomplete types 2017-05-13 00:46:33 +00:00
direct clang-import-test had some dead code. I did the following to eliminate it: 2017-07-10 23:47:00 +00:00
empty-struct Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
enum [clang-import-test] Test that enumerators and their values are found. 2017-07-11 00:29:37 +00:00
error-in-expression Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
error-in-import Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
extern-c-function Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
forward-declared-objc-class Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
forward-declared-struct Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
import-overrides Add testcase for r305850. 2017-07-07 21:51:11 +00:00
in-class-initializer Added an Importer test for in-class member initializers. 2017-04-27 18:10:29 +00:00
indirect-struct-member-access Call setMustBuildLookupTable on TagDecls in ExternalASTMerger 2017-06-17 00:12:38 +00:00
local-struct Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
local-struct-use-origins Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
member-in-struct [clang-import-test] Lookup inside contexts 2017-04-11 19:33:35 +00:00
missing-import Testbed and skeleton of a new expression parser 2016-12-22 20:03:14 +00:00
multiple-forward-declarations [clang-import-test] Lookup inside contexts 2017-04-11 19:33:35 +00:00
objc-definitions-in-expression Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
objc-method [ExternalASTMerger] Import Objective-C classes 2017-07-25 19:54:22 +00:00
overloaded-function [clang-import-test] Lookup inside contexts 2017-04-11 19:33:35 +00:00
struct-and-var Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
struct-in-namespace [clang-import-test] Lookup inside contexts 2017-04-11 19:33:35 +00:00
struct-layout This adds the argument --dump-ir to clang-import-test, which allows 2017-08-07 22:27:30 +00:00
template Add support for remembering origins to ExternalASTMerger 2017-09-27 19:57:58 +00:00
template-specialization [clang-import-test] Lookup inside contexts 2017-04-11 19:33:35 +00:00