r342721 - [CodeComplete] Generate completion fix-its for C code as well
Ivan Donchevskii via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 21 04:23:22 PDT 2018
Author: yvvan
Date: Fri Sep 21 04:23:22 2018
New Revision: 342721
URL: http://llvm.org/viewvc/llvm-project?rev=342721&view=rev
Log:
[CodeComplete] Generate completion fix-its for C code as well
Current completion fix-its approach does not provide OtherOpBase for C code.
But we can easily proceed in this case taking the original Base type.
Differential Revision: https://reviews.llvm.org/D52261
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/CodeCompletion/member-access.c
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=342721&r1=342720&r2=342721&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Sep 21 04:23:22 2018
@@ -1766,6 +1766,8 @@ Parser::ParsePostfixExpressionSuffix(Exp
Expr *Base = LHS.get();
Expr *CorrectedBase = CorrectedLHS.get();
+ if (!CorrectedBase && !getLangOpts().CPlusPlus)
+ CorrectedBase = Base;
// Code completion for a member access expression.
Actions.CodeCompleteMemberReferenceExpr(
Modified: cfe/trunk/test/CodeCompletion/member-access.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/member-access.c?rev=342721&r1=342720&r2=342721&view=diff
==============================================================================
--- cfe/trunk/test/CodeCompletion/member-access.c (original)
+++ cfe/trunk/test/CodeCompletion/member-access.c Fri Sep 21 04:23:22 2018
@@ -10,3 +10,22 @@ void test(struct Point *p) {
// CHECK-CC1: x
// CHECK-CC1: y
// CHECK-CC1: z
+}
+
+struct Point2 {
+ float x;
+};
+
+void test2(struct Point2 p) {
+ p->
+}
+
+void test3(struct Point2 *p) {
+ p.
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:20:6 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: x (requires fix-it: {20:4-20:6} to ".")
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:24:5 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: x (requires fix-it: {24:4-24:5} to "->")
More information about the cfe-commits
mailing list