r349655 - [CodeComplete] Properly determine qualifiers of 'this' in a lambda
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 19 10:01:25 PST 2018
Author: ibiryukov
Date: Wed Dec 19 10:01:24 2018
New Revision: 349655
URL: http://llvm.org/viewvc/llvm-project?rev=349655&view=rev
Log:
[CodeComplete] Properly determine qualifiers of 'this' in a lambda
Summary:
The clang used to pick up the qualifiers of the lamba's call operator
(which is always const) and fail to show non-const methods of 'this' in
completion results.
Reviewers: kadircet
Reviewed By: kadircet
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D55885
Added:
cfe/trunk/test/CodeCompletion/this-quals.cpp
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=349655&r1=349654&r2=349655&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed Dec 19 10:01:24 2018
@@ -3737,11 +3737,9 @@ void Sema::CodeCompleteOrdinaryName(Scop
// 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,
Added: cfe/trunk/test/CodeCompletion/this-quals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/this-quals.cpp?rev=349655&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/this-quals.cpp (added)
+++ cfe/trunk/test/CodeCompletion/this-quals.cpp Wed Dec 19 10:01:24 2018
@@ -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
+ };
+};
+
+
More information about the cfe-commits
mailing list