[PATCH] D28514: [CodeCompletion] Reset the hidden declaration obtained after lookup when caching UsingShadowDecls

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 18 08:25:14 PST 2017


arphaman updated this revision to Diff 84842.
arphaman marked an inline comment as done.
arphaman added a comment.

Avoid the hidden declaration in `VisibleDeclsRecord::checkHidden` instead of the decl consumer in code-completion


Repository:
  rL LLVM

https://reviews.llvm.org/D28514

Files:
  lib/Sema/SemaLookup.cpp
  test/Index/complete-cached-globals.cpp


Index: test/Index/complete-cached-globals.cpp
===================================================================
--- /dev/null
+++ test/Index/complete-cached-globals.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+namespace SomeNamespace {
+    class SomeClass {
+    };
+    void SomeFunction();
+}
+
+using SomeNamespace::SomeClass;
+using SomeNamespace::SomeFunction;
+
+static void foo() {
+  return;
+}
+
+// rdar://23454249
+
+// RUN: c-index-test -code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
+
+// CHECK-CC1: ClassDecl:{TypedText SomeClass} (50)
+// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText SomeFunction}{LeftParen (}{RightParen )} (50)
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeClass}
+// CHECK-CC1-NOT: {Text SomeNamespace::}{TypedText SomeFunction}
Index: lib/Sema/SemaLookup.cpp
===================================================================
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3428,6 +3428,11 @@
           SM == ShadowMaps.rbegin())
         continue;
 
+      // A shadow declaration that's created by a resolved using declaration
+      // is not hidden by the using declaration.
+      if (isa<UsingShadowDecl>(ND) && isa<UsingDecl>(D))
+        continue;
+
       // We've found a declaration that hides this one.
       return D;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28514.84842.patch
Type: text/x-patch
Size: 1558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170118/dc7ddfdd/attachment.bin>


More information about the cfe-commits mailing list