[PATCH] D55885: [CodeComplete] Properly determine qualifiers of 'this' in a lambda

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 19 10:04:44 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL349655: [CodeComplete] Properly determine qualifiers of 'this' in a lambda (authored by ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55885/new/

https://reviews.llvm.org/D55885

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/this-quals.cpp


Index: cfe/trunk/test/CodeCompletion/this-quals.cpp
===================================================================
--- cfe/trunk/test/CodeCompletion/this-quals.cpp
+++ cfe/trunk/test/CodeCompletion/this-quals.cpp
@@ -0,0 +1,21 @@
+class foo {
+  void mut_func() {
+    [this]() {
+
+    }();
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+    // CHECK-CC1: const_func
+    // CHECK-CC1: mut_func
+  }
+
+  void const_func() const {
+    [this]() {
+
+    }();
+    // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:13:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+    // CHECK-CC2-NOT: mut_func
+    // CHECK-CC2: const_func
+  };
+};
+
+
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -3737,11 +3737,9 @@
 
   // If we are in a C++ non-static member function, check the qualifiers on
   // the member function to filter/prioritize the results list.
-  if (CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext)) {
-    if (CurMethod->isInstance()) {
-      Results.setObjectTypeQualifiers(CurMethod->getTypeQualifiers());
-    }
-  }
+  auto ThisType = getCurrentThisType();
+  if (!ThisType.isNull())
+    Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers());
 
   CodeCompletionDeclConsumer Consumer(Results, CurContext);
   LookupVisibleDecls(S, LookupOrdinaryName, Consumer,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55885.178907.patch
Type: text/x-patch
Size: 1551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181219/df7db457/attachment.bin>


More information about the cfe-commits mailing list