aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-08-17 05:26:33 +0000
committerDouglas Gregor <dgregor@apple.com>2012-08-17 05:26:33 +0000
commitfb4306756208118d66f63abdd82cc10b19b5e4ba (patch)
treec585bd64f455ecc09ecf5cb9cf9a84211b5949bd
parent27bec77f5eb0920b401497be32713cb42339edef (diff)
When we need the complete set of visible declarations from a
declaration context, check whether the primary context---not the current context---has any external visible declarations. Fixes PR13616. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162083 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclLookups.h4
-rw-r--r--test/Index/complete-preamble.cpp8
-rw-r--r--test/Index/complete-preamble.h6
3 files changed, 16 insertions, 2 deletions
diff --git a/include/clang/AST/DeclLookups.h b/include/clang/AST/DeclLookups.h
index b8abe97be1..867b465257 100644
--- a/include/clang/AST/DeclLookups.h
+++ b/include/clang/AST/DeclLookups.h
@@ -67,7 +67,7 @@ public:
DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
DeclContext *Primary = const_cast<DeclContext*>(this)->getPrimaryContext();
- if (hasExternalVisibleStorage())
+ if (Primary->hasExternalVisibleStorage())
getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary);
if (StoredDeclsMap *Map = Primary->buildLookup())
return all_lookups_iterator(Map->begin(), Map->end());
@@ -76,7 +76,7 @@ DeclContext::all_lookups_iterator DeclContext::lookups_begin() const {
DeclContext::all_lookups_iterator DeclContext::lookups_end() const {
DeclContext *Primary = const_cast<DeclContext*>(this)->getPrimaryContext();
- if (hasExternalVisibleStorage())
+ if (Primary->hasExternalVisibleStorage())
getParentASTContext().getExternalSource()->completeVisibleDeclsMap(Primary);
if (StoredDeclsMap *Map = Primary->buildLookup())
return all_lookups_iterator(Map->end(), Map->end());
diff --git a/test/Index/complete-preamble.cpp b/test/Index/complete-preamble.cpp
new file mode 100644
index 0000000000..8f48105225
--- /dev/null
+++ b/test/Index/complete-preamble.cpp
@@ -0,0 +1,8 @@
+#include "complete-preamble.h"
+void f() {
+ std::
+}
+
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:3:8 %s -o - | FileCheck -check-prefix=CC1 %s
+// CHECK-CC1: {ResultType void}{TypedText wibble}{LeftParen (}{RightParen )} (50) (parent: Namespace 'std')
+
diff --git a/test/Index/complete-preamble.h b/test/Index/complete-preamble.h
new file mode 100644
index 0000000000..e696284c09
--- /dev/null
+++ b/test/Index/complete-preamble.h
@@ -0,0 +1,6 @@
+namespace std {
+ void wibble();
+}
+
+namespace std {
+}