diff options
author | Sean Callanan <scallanan@apple.com> | 2017-04-11 19:33:35 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2017-04-11 19:33:35 +0000 |
commit | 3975e67148c7382405ddd5b9004cdad6836cf443 (patch) | |
tree | 3445341e265534e27aa5561d2788b76f6ebed5aa /test/Import | |
parent | 44e7dd4bbbba32a53c0c57a3de45904b5fb084d6 (diff) |
[clang-import-test] Lookup inside contexts
clang-import-test has until now been only able to report top-level Decls.
This is clearly insufficient; we should be able to look inside structs
and namespaces also. This patch adds new test cases for a variety of
lookups inside existing ASTContexts, and adds the functionality necessar
to make most of these testcases work. (One testcase is known to fail
because of ASTImporter limitations when importing templates; I'll look
into that separately.)
This patch also separates the core functionality out into
ExternalASTMerger, an interface that allows clients like LLDB to make
use of it. clang-import-test now only has the machinery necessary to
set up the tests.
Differential revision: https://reviews.llvm.org/D30435
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299976 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Import')
-rw-r--r-- | test/Import/forward-declared-struct/Inputs/S1.c | 1 | ||||
-rw-r--r-- | test/Import/forward-declared-struct/Inputs/S2.c | 3 | ||||
-rw-r--r-- | test/Import/forward-declared-struct/test.c | 5 | ||||
-rw-r--r-- | test/Import/member-in-struct/Inputs/S.c | 3 | ||||
-rw-r--r-- | test/Import/member-in-struct/test.c | 5 | ||||
-rw-r--r-- | test/Import/multiple-forward-declarations/Inputs/S1.c | 1 | ||||
-rw-r--r-- | test/Import/multiple-forward-declarations/Inputs/S2.c | 1 | ||||
-rw-r--r-- | test/Import/multiple-forward-declarations/test.c | 4 | ||||
-rw-r--r-- | test/Import/overloaded-function/Inputs/F1.c | 1 | ||||
-rw-r--r-- | test/Import/overloaded-function/Inputs/F2.c | 4 | ||||
-rw-r--r-- | test/Import/overloaded-function/test.c | 7 | ||||
-rw-r--r-- | test/Import/struct-in-namespace/Inputs/N1.cpp | 11 | ||||
-rw-r--r-- | test/Import/struct-in-namespace/Inputs/N2.cpp | 5 | ||||
-rw-r--r-- | test/Import/struct-in-namespace/Inputs/N3.cpp | 5 | ||||
-rw-r--r-- | test/Import/struct-in-namespace/test.cpp | 7 | ||||
-rw-r--r-- | test/Import/template-specialization/Inputs/T.cpp | 14 | ||||
-rw-r--r-- | test/Import/template-specialization/test.cpp | 7 |
17 files changed, 84 insertions, 0 deletions
diff --git a/test/Import/forward-declared-struct/Inputs/S1.c b/test/Import/forward-declared-struct/Inputs/S1.c new file mode 100644 index 0000000000..28377c2760 --- /dev/null +++ b/test/Import/forward-declared-struct/Inputs/S1.c @@ -0,0 +1 @@ +struct S; diff --git a/test/Import/forward-declared-struct/Inputs/S2.c b/test/Import/forward-declared-struct/Inputs/S2.c new file mode 100644 index 0000000000..b0876d27df --- /dev/null +++ b/test/Import/forward-declared-struct/Inputs/S2.c @@ -0,0 +1,3 @@ +struct S { + int a; +}; diff --git a/test/Import/forward-declared-struct/test.c b/test/Import/forward-declared-struct/test.c new file mode 100644 index 0000000000..7ccdcf9e97 --- /dev/null +++ b/test/Import/forward-declared-struct/test.c @@ -0,0 +1,5 @@ +// RUN: clang-import-test -import %S/Inputs/S1.c --import %S/Inputs/S2.c -expression %s +void expr() { + struct S MyS; + MyS.a = 3; +} diff --git a/test/Import/member-in-struct/Inputs/S.c b/test/Import/member-in-struct/Inputs/S.c new file mode 100644 index 0000000000..b0876d27df --- /dev/null +++ b/test/Import/member-in-struct/Inputs/S.c @@ -0,0 +1,3 @@ +struct S { + int a; +}; diff --git a/test/Import/member-in-struct/test.c b/test/Import/member-in-struct/test.c new file mode 100644 index 0000000000..bde2b60d27 --- /dev/null +++ b/test/Import/member-in-struct/test.c @@ -0,0 +1,5 @@ +// RUN: clang-import-test -import %S/Inputs/S.c -expression %s +void expr() { + struct S MyS; + MyS.a = 3; +} diff --git a/test/Import/multiple-forward-declarations/Inputs/S1.c b/test/Import/multiple-forward-declarations/Inputs/S1.c new file mode 100644 index 0000000000..28377c2760 --- /dev/null +++ b/test/Import/multiple-forward-declarations/Inputs/S1.c @@ -0,0 +1 @@ +struct S; diff --git a/test/Import/multiple-forward-declarations/Inputs/S2.c b/test/Import/multiple-forward-declarations/Inputs/S2.c new file mode 100644 index 0000000000..28377c2760 --- /dev/null +++ b/test/Import/multiple-forward-declarations/Inputs/S2.c @@ -0,0 +1 @@ +struct S; diff --git a/test/Import/multiple-forward-declarations/test.c b/test/Import/multiple-forward-declarations/test.c new file mode 100644 index 0000000000..fdaaaf6114 --- /dev/null +++ b/test/Import/multiple-forward-declarations/test.c @@ -0,0 +1,4 @@ +// RUN: clang-import-test -import %S/Inputs/S1.c --import %S/Inputs/S2.c -expression %s +void expr() { + struct S *MySPtr; +} diff --git a/test/Import/overloaded-function/Inputs/F1.c b/test/Import/overloaded-function/Inputs/F1.c new file mode 100644 index 0000000000..fb548b464f --- /dev/null +++ b/test/Import/overloaded-function/Inputs/F1.c @@ -0,0 +1 @@ +void f(int arg) { } diff --git a/test/Import/overloaded-function/Inputs/F2.c b/test/Import/overloaded-function/Inputs/F2.c new file mode 100644 index 0000000000..937efe54d8 --- /dev/null +++ b/test/Import/overloaded-function/Inputs/F2.c @@ -0,0 +1,4 @@ +struct S { int a; }; + +void f(const char *arg) { } +void f(S arg) { } diff --git a/test/Import/overloaded-function/test.c b/test/Import/overloaded-function/test.c new file mode 100644 index 0000000000..4f7781bc8e --- /dev/null +++ b/test/Import/overloaded-function/test.c @@ -0,0 +1,7 @@ +// RUN: clang-import-test -import %S/Inputs/F1.c -import %S/Inputs/F2.c -expression %s +void expr() { + f(2); + f("world"); + S s; + f(s); +} diff --git a/test/Import/struct-in-namespace/Inputs/N1.cpp b/test/Import/struct-in-namespace/Inputs/N1.cpp new file mode 100644 index 0000000000..ddb67a5162 --- /dev/null +++ b/test/Import/struct-in-namespace/Inputs/N1.cpp @@ -0,0 +1,11 @@ +namespace N { + struct S { + int a; + }; +} + +namespace N { + struct T { + int b; + }; +} diff --git a/test/Import/struct-in-namespace/Inputs/N2.cpp b/test/Import/struct-in-namespace/Inputs/N2.cpp new file mode 100644 index 0000000000..ad97d5dd52 --- /dev/null +++ b/test/Import/struct-in-namespace/Inputs/N2.cpp @@ -0,0 +1,5 @@ +namespace N { + struct U { + int c; + }; +} diff --git a/test/Import/struct-in-namespace/Inputs/N3.cpp b/test/Import/struct-in-namespace/Inputs/N3.cpp new file mode 100644 index 0000000000..e0ec414674 --- /dev/null +++ b/test/Import/struct-in-namespace/Inputs/N3.cpp @@ -0,0 +1,5 @@ +namespace M { + struct V { + int d; + }; +} diff --git a/test/Import/struct-in-namespace/test.cpp b/test/Import/struct-in-namespace/test.cpp new file mode 100644 index 0000000000..fd14d82d17 --- /dev/null +++ b/test/Import/struct-in-namespace/test.cpp @@ -0,0 +1,7 @@ +// RUN: clang-import-test -import %S/Inputs/N1.cpp -import %S/Inputs/N2.cpp -import %S/Inputs/N3.cpp -expression %s +void expr() { + N::S s; + N::T t; + N::U u; + int d = s.a + t.b + u.c; +} diff --git a/test/Import/template-specialization/Inputs/T.cpp b/test/Import/template-specialization/Inputs/T.cpp new file mode 100644 index 0000000000..b31e2439ef --- /dev/null +++ b/test/Import/template-specialization/Inputs/T.cpp @@ -0,0 +1,14 @@ +template <typename T> struct A { +}; + +template <> struct A<int> { + struct B { + int f; + }; +}; + +template <> struct A<bool> { + struct B { + int g; + }; +}; diff --git a/test/Import/template-specialization/test.cpp b/test/Import/template-specialization/test.cpp new file mode 100644 index 0000000000..43996c53a7 --- /dev/null +++ b/test/Import/template-specialization/test.cpp @@ -0,0 +1,7 @@ +// RUN: clang-import-test -import %S/Inputs/T.cpp -expression %s +// XFAIL: * +void expr() { + A<int>::B b1; + A<bool>::B b2; + b1.f + b2.g; +} |