C++ modules: fix a bug where loading a declaration with some name would prevent
name lookup from lazily deserializing the other declarations with the same
name, by tracking a bit to indicate whether a name in a DeclContext might have
additional external results. This also allows lazier reconciling of the lookup
table if a module import adds decls to a pre-existing DC.
However, this exposes a pre-existing bug, which causes a regression in
test/Modules/decldef.mm: if we have a reference to a declaration, and a
later-imported module adds a redeclaration, nothing causes us to load that
redeclaration when we use or emit the reference (which can manifest as a
reference to an undefined inline function, a use of an incomplete type, and so
on). decldef.mm has been extended with an additional testcase which fails with
or without this change.
llvm-svn: 190293
diff --git a/clang/test/Modules/Inputs/def.h b/clang/test/Modules/Inputs/def.h
index eb7eb7e..6fa83d3 100644
--- a/clang/test/Modules/Inputs/def.h
+++ b/clang/test/Modules/Inputs/def.h
@@ -17,4 +17,11 @@
public:
void func();
};
+
+namespace Def3NS {
+ class Def3 {
+ public:
+ void func();
+ };
+}
#endif
diff --git a/clang/test/Modules/Inputs/namespaces-top.h b/clang/test/Modules/Inputs/namespaces-top.h
index 0c607f5..7aa8490 100644
--- a/clang/test/Modules/Inputs/namespaces-top.h
+++ b/clang/test/Modules/Inputs/namespaces-top.h
@@ -12,3 +12,8 @@
namespace N12 { }
+namespace N13 {
+ void f();
+ int f(int);
+ void (*p)() = &f;
+}
diff --git a/clang/test/Modules/cxx-templates.cpp b/clang/test/Modules/cxx-templates.cpp
index 0949436b..9e6cd17 100644
--- a/clang/test/Modules/cxx-templates.cpp
+++ b/clang/test/Modules/cxx-templates.cpp
@@ -82,11 +82,8 @@
SomeTemplate<char*> some_template_char_ptr;
SomeTemplate<char&> some_template_char_ref;
-// FIXME: There should only be two 'f's here.
// CHECK-GLOBAL: DeclarationName 'f'
// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
-// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
-// CHECK-GLOBAL-NEXT: |-FunctionTemplate {{.*}} 'f'
// CHECK-GLOBAL-NEXT: `-FunctionTemplate {{.*}} 'f'
// CHECK-NAMESPACE-N: DeclarationName 'f'
diff --git a/clang/test/Modules/decldef.mm b/clang/test/Modules/decldef.mm
index c693c7f..3569493 100644
--- a/clang/test/Modules/decldef.mm
+++ b/clang/test/Modules/decldef.mm
@@ -6,8 +6,10 @@
@class Def;
Def *def;
-class Def2;
+class Def2; // expected-note {{forward decl}}
Def2 *def2;
+namespace Def3NS { class Def3; } // expected-note {{forward decl}}
+Def3NS::Def3 *def3;
@interface Unrelated
- defMethod;
@@ -39,5 +41,9 @@
}
void testDef2() {
- def2->func();
+ // FIXME: These should both work, since we've (implicitly) imported
+ // decldef.Def here, but they don't, because nothing has triggered the lazy
+ // loading of the definitions of these classes.
+ def2->func(); // expected-error {{incomplete}}
+ def3->func(); // expected-error {{incomplete}}
}
diff --git a/clang/test/Modules/namespaces.cpp b/clang/test/Modules/namespaces.cpp
index 426e002..8c225e0 100644
--- a/clang/test/Modules/namespaces.cpp
+++ b/clang/test/Modules/namespaces.cpp
@@ -75,3 +75,10 @@
// expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter here}}
// expected-note@Inputs/namespaces-right.h:67 {{passing argument to parameter here}}
+
+// Test that bringing in one name from an overload set does not hide the rest.
+void testPartialImportOfOverloadSet() {
+ void (*p)() = N13::p;
+ p();
+ N13::f(0);
+}