dgoldman updated this revision to Diff 269269. dgoldman marked an inline comment as done. dgoldman added a comment.
- Minor comment fixes Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81263/new/ https://reviews.llvm.org/D81263 Files: clang/lib/Sema/SemaCodeComplete.cpp clang/test/CodeCompletion/objc-member-access.m Index: clang/test/CodeCompletion/objc-member-access.m =================================================================== --- /dev/null +++ clang/test/CodeCompletion/objc-member-access.m @@ -0,0 +1,22 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@interface TypeWithPropertiesBackedByIvars { + int _bar; + int _foo; +} +@property(nonatomic) int foo; +@property(nonatomic) int bar; +@end + +int getFoo(id object) { + TypeWithPropertiesBackedByIvars *model = (TypeWithPropertiesBackedByIvars *)object; + int foo = model.; + return foo; +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1-NOT: [#int#]_bar +// CHECK-CC1-NOT: [#int#]_foo +// CHECK-CC1: [#int#]bar +// CHECK-CC1: [#int#]foo Index: clang/lib/Sema/SemaCodeComplete.cpp =================================================================== --- clang/lib/Sema/SemaCodeComplete.cpp +++ clang/lib/Sema/SemaCodeComplete.cpp @@ -5195,7 +5195,12 @@ Results.AddResult(std::move(Result)); } } else if (!IsArrow && BaseType->isObjCObjectPointerType()) { - // Objective-C property reference. + // Objective-C property reference. Bail if we're performing fix-it code + // completion since Objective-C properties are normally backed by ivars, + // most Objecive-C fix-its here would have little value. + if (AccessOpFixIt.hasValue()) { + return false; + } AddedPropertiesSet AddedProperties; if (const ObjCObjectPointerType *ObjCPtr = @@ -5215,7 +5220,12 @@ /*InOriginalClass*/ false); } else if ((IsArrow && BaseType->isObjCObjectPointerType()) || (!IsArrow && BaseType->isObjCObjectType())) { - // Objective-C instance variable access. + // Objective-C instance variable access. Bail if we're performing fix-it + // code completion since Objective-C properties are normally backed by + // ivars, most Objecive-C fix-its here would have little value. + if (AccessOpFixIt.hasValue()) { + return false; + } ObjCInterfaceDecl *Class = nullptr; if (const ObjCObjectPointerType *ObjCPtr = BaseType->getAs<ObjCObjectPointerType>())
Index: clang/test/CodeCompletion/objc-member-access.m =================================================================== --- /dev/null +++ clang/test/CodeCompletion/objc-member-access.m @@ -0,0 +1,22 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@interface TypeWithPropertiesBackedByIvars { + int _bar; + int _foo; +} +@property(nonatomic) int foo; +@property(nonatomic) int bar; +@end + +int getFoo(id object) { + TypeWithPropertiesBackedByIvars *model = (TypeWithPropertiesBackedByIvars *)object; + int foo = model.; + return foo; +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:14:19 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1-NOT: [#int#]_bar +// CHECK-CC1-NOT: [#int#]_foo +// CHECK-CC1: [#int#]bar +// CHECK-CC1: [#int#]foo Index: clang/lib/Sema/SemaCodeComplete.cpp =================================================================== --- clang/lib/Sema/SemaCodeComplete.cpp +++ clang/lib/Sema/SemaCodeComplete.cpp @@ -5195,7 +5195,12 @@ Results.AddResult(std::move(Result)); } } else if (!IsArrow && BaseType->isObjCObjectPointerType()) { - // Objective-C property reference. + // Objective-C property reference. Bail if we're performing fix-it code + // completion since Objective-C properties are normally backed by ivars, + // most Objecive-C fix-its here would have little value. + if (AccessOpFixIt.hasValue()) { + return false; + } AddedPropertiesSet AddedProperties; if (const ObjCObjectPointerType *ObjCPtr = @@ -5215,7 +5220,12 @@ /*InOriginalClass*/ false); } else if ((IsArrow && BaseType->isObjCObjectPointerType()) || (!IsArrow && BaseType->isObjCObjectType())) { - // Objective-C instance variable access. + // Objective-C instance variable access. Bail if we're performing fix-it + // code completion since Objective-C properties are normally backed by + // ivars, most Objecive-C fix-its here would have little value. + if (AccessOpFixIt.hasValue()) { + return false; + } ObjCInterfaceDecl *Class = nullptr; if (const ObjCObjectPointerType *ObjCPtr = BaseType->getAs<ObjCObjectPointerType>())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits