forked from OSchip/llvm-project
[PCH/Modules] In ASTReader::completeVisibleDeclsMap, make sure to visit all
modules when getting the decls for a namespace or translation unit. Otherwise the code-completion results will not be complete. rdar://12889089 llvm-svn: 170596
This commit is contained in:
parent
349d1a35ff
commit
2810e9dee0
|
@ -5429,13 +5429,15 @@ namespace {
|
||||||
ASTReader &Reader;
|
ASTReader &Reader;
|
||||||
llvm::SmallVectorImpl<const DeclContext *> &Contexts;
|
llvm::SmallVectorImpl<const DeclContext *> &Contexts;
|
||||||
llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> > &Decls;
|
llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> > &Decls;
|
||||||
|
bool VisitAll;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeclContextAllNamesVisitor(ASTReader &Reader,
|
DeclContextAllNamesVisitor(ASTReader &Reader,
|
||||||
SmallVectorImpl<const DeclContext *> &Contexts,
|
SmallVectorImpl<const DeclContext *> &Contexts,
|
||||||
llvm::DenseMap<DeclarationName,
|
llvm::DenseMap<DeclarationName,
|
||||||
SmallVector<NamedDecl *, 8> > &Decls)
|
SmallVector<NamedDecl *, 8> > &Decls,
|
||||||
: Reader(Reader), Contexts(Contexts), Decls(Decls) { }
|
bool VisitAll)
|
||||||
|
: Reader(Reader), Contexts(Contexts), Decls(Decls), VisitAll(VisitAll) { }
|
||||||
|
|
||||||
static bool visit(ModuleFile &M, void *UserData) {
|
static bool visit(ModuleFile &M, void *UserData) {
|
||||||
DeclContextAllNamesVisitor *This
|
DeclContextAllNamesVisitor *This
|
||||||
|
@ -5476,7 +5478,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FoundAnything;
|
return FoundAnything && !This->VisitAll;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5502,7 +5504,8 @@ void ASTReader::completeVisibleDeclsMap(const DeclContext *DC) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclContextAllNamesVisitor Visitor(*this, Contexts, Decls);
|
DeclContextAllNamesVisitor Visitor(*this, Contexts, Decls,
|
||||||
|
/*VisitAll=*/DC->isFileContext());
|
||||||
ModuleMgr.visit(&DeclContextAllNamesVisitor::visit, &Visitor);
|
ModuleMgr.visit(&DeclContextAllNamesVisitor::visit, &Visitor);
|
||||||
++NumVisibleDeclContextsRead;
|
++NumVisibleDeclContextsRead;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
// <rdar://12889089>
|
||||||
|
|
||||||
|
#ifndef HEADER1
|
||||||
|
#define HEADER1
|
||||||
|
|
||||||
|
// CHECK-TU: FunctionDecl:{ResultType void}{TypedText foo}
|
||||||
|
void foo();
|
||||||
|
|
||||||
|
namespace Cake {
|
||||||
|
// CHECK-NAMESPACE: FunctionDecl:{ResultType void}{TypedText lie}
|
||||||
|
void lie();
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif !defined(HEADER2)
|
||||||
|
#define HEADER2
|
||||||
|
|
||||||
|
namespace Cake {
|
||||||
|
extern int Baz;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void func() {
|
||||||
|
Cake::
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RUN: c-index-test -write-pch %t1.h.pch %s
|
||||||
|
// RUN: c-index-test -write-pch %t2.h.pch %s -include %t1.h
|
||||||
|
// RUN: c-index-test -code-completion-at=%s:25:1 %s -include %t2.h | FileCheck -check-prefix=CHECK-TU %s
|
||||||
|
// RUN: c-index-test -code-completion-at=%s:25:7 %s -include %t2.h | FileCheck -check-prefix=CHECK-NAMESPACE %s
|
Loading…
Reference in New Issue