brunodf updated this revision to Diff 381639.
brunodf marked 3 inline comments as done.
brunodf added a comment.
I'm adding a new patch to (partially) address the comments from @rnk.
An ObjC test case was included in the commit from @akyrtzi, I've updated it to
also cover the case of a unary operator (and the increment/decrement), and the
case of a type dependent on a template parameter. I moved my changes to the
original position of the code for ObjC properties in RebuildCXXOperatorCallExpr.
With regard to OO_Subscript, OO_Arrow and OO_Amp, I have tried a number of
things, but I have not succeeded in triggering that an CXXOperatorCallExpr is
created for these operators (they end up as an ArraySubscriptExpr,
CXXDependentScopeMemberExpr and UnaryOperator respectively). At the moment, I
don't know how to test the code paths for these operators in
RebuildCXXOperatorCallExpr.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111639/new/
https://reviews.llvm.org/D111639
Files:
clang/lib/Sema/TreeTransform.h
clang/test/SemaCXX/PR51855.cpp
clang/test/SemaObjCXX/instantiate-property-access.mm
Index: clang/test/SemaObjCXX/instantiate-property-access.mm
===================================================================
--- clang/test/SemaObjCXX/instantiate-property-access.mm
+++ clang/test/SemaObjCXX/instantiate-property-access.mm
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DDEPENDENT -verify %s
// expected-no-diagnostics
class C {};
@@ -9,6 +10,10 @@
C operator += (C c1, C c2);
+C operator++(C c1);
+
+bool operator!(C c1);
+
enum TextureType { TextureType3D };
@interface Texture
@@ -16,9 +21,13 @@
@property C c;
@end
-template <typename> class Framebuffer {
+template <typename T> class Framebuffer {
public:
- Texture **color_attachment;
+#ifdef DEPENDENT
+ T **color_attachment;
+#else
+ Texture **color_attachment;
+#endif
Framebuffer();
};
@@ -28,8 +37,15 @@
(void)(color_attachment[0].c == color_attachment[0].c);
(void)(color_attachment[0].c == 1);
(void)(1 == color_attachment[0].c);
+ (void)(!color_attachment[0].textureType);
+ ++color_attachment[0].textureType;
+ (void)(!color_attachment[0].c);
}
void foo() {
+#ifdef DEPENDENT
+ Framebuffer<Texture>();
+#else
Framebuffer<int>();
+#endif
}
Index: clang/test/SemaCXX/PR51855.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/PR51855.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -S -triple %itanium_abi_triple -fms-extensions -emit-llvm %s -o - | FileCheck %s
+
+struct F {};
+
+F operator*=(F &lhs, int rhs);
+
+F operator++(F &lhs);
+
+struct S {
+ short _m;
+ S(short _m) : _m(_m) {}
+
+ void putM(short rhs) { _m = rhs; }
+ short getM() { return _m; }
+
+ __declspec(property(get = getM, put = putM)) short theData;
+};
+
+int test1a(int i) {
+ S tmp(i);
+ tmp.theData *= 2;
+ return tmp.theData;
+}
+
+// CHECK-LABEL: define {{.*}} @_Z6test1ai(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+template <typename T>
+int test1b(int i) {
+ T tmp(i);
+ tmp.theData *= 2;
+ return tmp.theData;
+}
+
+template int test1b<S>(int);
+
+// CHECK-LABEL: define {{.*}} @_Z6test1bI1SEii(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+int test2a(int i) {
+ S tmp(i);
+ ++tmp.theData;
+ return tmp.theData;
+}
+
+// CHECK-LABEL: define {{.*}} i32 @_Z6test2ai(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+template <typename T>
+int test2b(int i) {
+ T tmp(i);
+ ++tmp.theData;
+ return tmp.theData;
+}
+
+template int test2b<S>(int);
+
+// CHECK-LABEL: define {{.*}} i32 @_Z6test2bI1SEii(
+// CHECK: call void @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -14569,18 +14569,28 @@
Expr *Callee = OrigCallee->IgnoreParenCasts();
bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
- if (First->getObjectKind() == OK_ObjCProperty) {
- BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
- if (BinaryOperator::isAssignmentOp(Opc))
- return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
- First, Second);
+ if (const BuiltinType *pty = First->getType()->getAsPlaceholderType()) {
+ if (Second && !isPostIncDec) {
+ BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
+ if (pty->getKind() == BuiltinType::PseudoObject &&
+ BinaryOperator::isAssignmentOp(Opc))
+ return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc,
+ Opc, First, Second);
+ } else {
+ UnaryOperatorKind Opc =
+ UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
+ if (pty->getKind() == BuiltinType::PseudoObject &&
+ UnaryOperator::isIncrementDecrementOp(Opc))
+ return SemaRef.checkPseudoObjectIncDec(/*Scope=*/nullptr, OpLoc, Opc,
+ First);
+ }
ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
if (Result.isInvalid())
return ExprError();
First = Result.get();
}
- if (Second && Second->getObjectKind() == OK_ObjCProperty) {
+ if (Second && Second->getType()->isPlaceholderType()) {
ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
if (Result.isInvalid())
return ExprError();
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits