merged context, pull in the lexical decls in that context, since one of them
may complete the redecl chain.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216652
91177308-0d34-0410-b5e6-
96231b3b80d8
// If this is a named declaration, complete it by looking it up
// within its context.
//
- // FIXME: We don't currently handle the cases where we can't do this;
- // merging a class definition that contains unnamed entities should merge
- // those entities. Likewise, merging a function definition should merge
+ // FIXME: Merging a function definition should merge
// all mergeable entities within it.
if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
updateOutOfDateIdentifier(*II);
} else
DC->lookup(Name);
+ } else if (needsAnonymousDeclarationNumber(cast<NamedDecl>(D))) {
+ // FIXME: It'd be nice to do something a bit more targeted here.
+ D->getDeclContext()->decls_begin();
}
}
}
continue;
DeclContext *CanonDef = D->getDeclContext();
- DeclContext::lookup_result R = CanonDef->lookup(D->getDeclName());
bool Found = false;
const Decl *DCanon = D->getCanonicalDecl();
+ for (auto RI : D->redecls()) {
+ if (RI->getLexicalDeclContext() == CanonDef) {
+ Found = true;
+ break;
+ }
+ }
+ if (Found)
+ continue;
+
llvm::SmallVector<const NamedDecl*, 4> Candidates;
+ DeclContext::lookup_result R = CanonDef->lookup(D->getDeclName());
for (DeclContext::lookup_iterator I = R.begin(), E = R.end();
!Found && I != E; ++I) {
for (auto RI : (*I)->redecls()) {
typedef PartiallyInstantiatePartialSpec<int*> PartiallyInstantiatePartialSpecHelper;
void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>);
-inline int InstantiateWithAnonymousDeclsA(WithAnonymousDecls<int> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d); }
+inline int InstantiateWithAnonymousDeclsA(WithAnonymousDecls<int> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; }
+inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x);
void InstantiateWithAliasTemplate(WithAliasTemplate<int>::X<char>);
inline int InstantiateWithAnonymousDeclsB(WithAnonymousDecls<int> x) {
- return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d);
+ return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e;
+}
+inline int InstantiateWithAnonymousDeclsB2(WithAnonymousDecls<char> x) {
+ return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e;
}
@import cxx_templates_a;
struct { bool k; };
union { int a, b; };
struct { int c, d; } s;
+ enum { e = 123 };
typedef int X;
};
--- /dev/null
+@import cxx_templates_common;
+
+inline int InstantiateWithAnonymousDeclsD(WithAnonymousDecls<char> x) { return (x.k ? x.a : x.b) + (x.k ? x.s.c : x.s.d) + x.e; }
header "cxx-templates-c.h"
}
+module cxx_templates_d {
+ header "cxx-templates-d.h"
+}
+
module cxx_decls {
module unimported {
header "cxx-decls-unimported.h"
@import cxx_templates_a;
@import cxx_templates_b;
@import cxx_templates_c;
+@import cxx_templates_d;
@import cxx_templates_common;
template<typename, char> struct Tmpl_T_C {};
using AliasTemplateMergingTest = WithAliasTemplate<int>::X<char>;
-int AnonymousDeclsMergingTest(WithAnonymousDecls<int> WAD) {
+int AnonymousDeclsMergingTest(WithAnonymousDecls<int> WAD, WithAnonymousDecls<char> WADC) {
return InstantiateWithAnonymousDeclsA(WAD) +
- InstantiateWithAnonymousDeclsB(WAD);
+ InstantiateWithAnonymousDeclsB(WAD) +
+ InstantiateWithAnonymousDeclsB2(WADC) +
+ InstantiateWithAnonymousDeclsD(WADC);
}
@import cxx_templates_common;