2013-06-25 09:25:15 +08:00
|
|
|
template<typename T> struct SomeTemplate {};
|
When we perform dependent name lookup during template instantiation, it's not
sufficient to only consider names visible at the point of instantiation,
because that may not include names that were visible when the template was
defined. More generally, if the instantiation backtrace goes through a module
M, then every declaration visible within M should be available to the
instantiation. Any of those declarations might be part of the interface that M
intended to export to a template that it instantiates.
The fix here has two parts:
1) If we find a non-visible declaration during name lookup during template
instantiation, check whether the declaration was visible from the defining
module of all entities on the active template instantiation stack. The defining
module is not the owning module in all cases: we look at the module in which a
template was defined, not the module in which it was first instantiated.
2) Perform pending instantiations at the end of a module, not at the end of the
translation unit. This is general goodness, since it significantly cuts down
the amount of redundant work that is performed in every TU importing a module,
and also implicitly adds the module containing the point of instantiation to
the set of modules checked for declarations in a lookup within a template
instantiation.
There's a known issue here with template instantiations performed while
building a module, if additional imports are added later on. I'll fix that
in a subsequent commit.
llvm-svn: 187167
2013-07-26 07:08:39 +08:00
|
|
|
|
|
|
|
struct DefinedInCommon {
|
|
|
|
void f();
|
|
|
|
struct Inner {};
|
|
|
|
friend void FoundByADL(DefinedInCommon);
|
|
|
|
};
|
2013-10-16 06:02:41 +08:00
|
|
|
|
|
|
|
template<typename T> struct CommonTemplate {
|
|
|
|
enum E { a = 1, b = 2, c = 3 };
|
|
|
|
};
|
2014-03-23 10:30:01 +08:00
|
|
|
|
|
|
|
namespace Std {
|
|
|
|
template<typename T> struct WithFriend {
|
|
|
|
friend bool operator!=(const WithFriend &A, const WithFriend &B) { return false; }
|
|
|
|
};
|
|
|
|
}
|
2014-03-24 03:45:26 +08:00
|
|
|
|
|
|
|
namespace Std {
|
|
|
|
template<typename T> void f() {
|
|
|
|
extern T g();
|
|
|
|
}
|
|
|
|
}
|
2014-05-07 10:25:43 +08:00
|
|
|
|
|
|
|
template<typename T> struct TemplateInstantiationVisibility { typedef int type; };
|
2014-05-20 04:59:20 +08:00
|
|
|
|
|
|
|
template<typename T> struct Outer {
|
|
|
|
template<typename U> struct Inner {
|
2014-07-11 08:20:06 +08:00
|
|
|
static constexpr int f();
|
|
|
|
static constexpr int g();
|
2014-05-20 04:59:20 +08:00
|
|
|
};
|
|
|
|
};
|
2014-05-23 04:59:29 +08:00
|
|
|
|
|
|
|
template<typename T> struct WithPartialSpecialization {};
|
|
|
|
typedef WithPartialSpecialization<int*> WithPartialSpecializationUse;
|
2014-05-24 05:00:28 +08:00
|
|
|
|
|
|
|
template<typename T> struct WithExplicitSpecialization;
|
|
|
|
typedef WithExplicitSpecialization<int> WithExplicitSpecializationUse;
|