[PATCH] D52261: [Sema] Generate completion fix-its for C code as well
Ivan Donchevskii via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 21 04:25:37 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC342721: [CodeComplete] Generate completion fix-its for C code as well (authored by yvvan, committed by ).
Repository:
rC Clang
https://reviews.llvm.org/D52261
Files:
lib/Parse/ParseExpr.cpp
test/CodeCompletion/member-access.c
Index: test/CodeCompletion/member-access.c
===================================================================
--- test/CodeCompletion/member-access.c
+++ test/CodeCompletion/member-access.c
@@ -10,3 +10,22 @@
// 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 "->")
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1766,6 +1766,8 @@
Expr *Base = LHS.get();
Expr *CorrectedBase = CorrectedLHS.get();
+ if (!CorrectedBase && !getLangOpts().CPlusPlus)
+ CorrectedBase = Base;
// Code completion for a member access expression.
Actions.CodeCompleteMemberReferenceExpr(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52261.166445.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180921/410b898d/attachment.bin>
More information about the cfe-commits
mailing list