[clang] 8837ef4 - [clang] Apply FixIts to members declared via `using` in derived classes
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 17 01:13:37 PDT 2022
Author: Denis Fatkulin
Date: 2022-08-17T10:09:48+02:00
New Revision: 8837ef4d373be3f9b4ea297596ee917a1a91377e
URL: https://github.com/llvm/llvm-project/commit/8837ef4d373be3f9b4ea297596ee917a1a91377e
DIFF: https://github.com/llvm/llvm-project/commit/8837ef4d373be3f9b4ea297596ee917a1a91377e.diff
LOG: [clang] Apply FixIts to members declared via `using` in derived classes
FixIt don't switch to arrow in derrived members with `using`
Example code:
```
struct Bar {
void foo();
};
struct Baz {
using Bar::foo;
};
void test(Baz* ptr) {
ptr.^
}
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D131088
Added:
Modified:
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/member-access.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index f4303f6ec6bf..6d5769a39627 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1098,7 +1098,8 @@ void ResultBuilder::MaybeAddResult(Result R, DeclContext *CurContext) {
getBasePriority(Using->getTargetDecl()),
R.Qualifier, false,
(R.Availability == CXAvailability_Available ||
- R.Availability == CXAvailability_Deprecated));
+ R.Availability == CXAvailability_Deprecated),
+ std::move(R.FixIts));
Result.ShadowDecl = Using;
MaybeAddResult(Result, CurContext);
return;
@@ -1273,7 +1274,8 @@ void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
getBasePriority(Using->getTargetDecl()),
R.Qualifier, false,
(R.Availability == CXAvailability_Available ||
- R.Availability == CXAvailability_Deprecated));
+ R.Availability == CXAvailability_Deprecated),
+ std::move(R.FixIts));
Result.ShadowDecl = Using;
AddResult(Result, CurContext, Hiding);
return;
diff --git a/clang/test/CodeCompletion/member-access.cpp b/clang/test/CodeCompletion/member-access.cpp
index 2c611b471580..4a5d1c66a25a 100644
--- a/clang/test/CodeCompletion/member-access.cpp
+++ b/clang/test/CodeCompletion/member-access.cpp
@@ -311,3 +311,25 @@ void testMembersFromBasesInDependentContext() {
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:310:19 %s -o - | FileCheck -check-prefix=CHECK-MEMBERS-FROM-BASE-DEPENDENT %s
// CHECK-MEMBERS-FROM-BASE-DEPENDENT: [#Base4#]base4
}
+
+namespace members_using_fixits {
+ struct Bar {
+ void method();
+ int field;
+ };
+ struct Baz: Bar {
+ using Bar::method;
+ using Bar::field;
+ };
+ void testMethod(Baz* ptr) {
+ ptr.m
+ }
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:325:10 %s -o - | FileCheck -check-prefix=CHECK-METHOD-DECLARED-VIA-USING %s
+ // CHECK-METHOD-DECLARED-VIA-USING: [#void#]method() (requires fix-it: {325:8-325:9} to "->")
+
+ void testField(Baz* ptr) {
+ ptr.f
+ }
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:331:10 %s -o - | FileCheck -check-prefix=CHECK-FIELD-DECLARED-VIA-USING %s
+ // CHECK-FIELD-DECLARED-VIA-USING: [#int#]field (requires fix-it: {331:8-331:9} to "->")
+}
More information about the cfe-commits
mailing list