From: Ivan Donchevskii Date: Fri, 21 Sep 2018 11:23:22 +0000 (+0000) Subject: [CodeComplete] Generate completion fix-its for C code as well X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=60a16ef04b8e435f1e8fbf16c960a0cf7b7a5612;p=platform%2Fupstream%2Fllvm.git [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 llvm-svn: 342721 --- diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 0c14f62..b9028bf 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1766,6 +1766,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { Expr *Base = LHS.get(); Expr *CorrectedBase = CorrectedLHS.get(); + if (!CorrectedBase && !getLangOpts().CPlusPlus) + CorrectedBase = Base; // Code completion for a member access expression. Actions.CodeCompleteMemberReferenceExpr( diff --git a/clang/test/CodeCompletion/member-access.c b/clang/test/CodeCompletion/member-access.c index 226e182..72afbf2 100644 --- a/clang/test/CodeCompletion/member-access.c +++ b/clang/test/CodeCompletion/member-access.c @@ -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 "->")