[clang] f7e0aae - [ODRHash] Stop hashing `ObjCMethodDecl::isPropertyAccessor` as it doesn't capture inherent method quality.
Volodymyr Sapsai via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 5 18:10:21 PDT 2023
Author: Volodymyr Sapsai
Date: 2023-07-05T18:04:50-07:00
New Revision: f7e0aae7284b7ad0cf3cc277c5ef8731f564443d
URL: https://github.com/llvm/llvm-project/commit/f7e0aae7284b7ad0cf3cc277c5ef8731f564443d
DIFF: https://github.com/llvm/llvm-project/commit/f7e0aae7284b7ad0cf3cc277c5ef8731f564443d.diff
LOG: [ODRHash] Stop hashing `ObjCMethodDecl::isPropertyAccessor` as it doesn't capture inherent method quality.
`isPropertyAccessor` depends on the surrounding code and not on the method
itself. That's why it can be different in different modules. And
mismatches shouldn't be an error.
rdar://109481753
Differential Revision: https://reviews.llvm.org/D154460
Added:
Modified:
clang/lib/AST/ODRHash.cpp
clang/test/Modules/compare-objc-nonisolated-methods.m
Removed:
################################################################################
diff --git a/clang/lib/AST/ODRHash.cpp b/clang/lib/AST/ODRHash.cpp
index 3ea023d3cee66a..507fb0b49f8ad3 100644
--- a/clang/lib/AST/ODRHash.cpp
+++ b/clang/lib/AST/ODRHash.cpp
@@ -373,7 +373,6 @@ class ODRDeclVisitor : public ConstDeclVisitor<ODRDeclVisitor> {
void VisitObjCMethodDecl(const ObjCMethodDecl *Method) {
ID.AddInteger(Method->getDeclKind());
Hash.AddBoolean(Method->isInstanceMethod()); // false if class method
- Hash.AddBoolean(Method->isPropertyAccessor());
Hash.AddBoolean(Method->isVariadic());
Hash.AddBoolean(Method->isSynthesizedAccessorStub());
Hash.AddBoolean(Method->isDefined());
diff --git a/clang/test/Modules/compare-objc-nonisolated-methods.m b/clang/test/Modules/compare-objc-nonisolated-methods.m
index a60114148420bd..41e861547af420 100644
--- a/clang/test/Modules/compare-objc-nonisolated-methods.m
+++ b/clang/test/Modules/compare-objc-nonisolated-methods.m
@@ -5,12 +5,17 @@
// is not an error because it depends on the surrounding code and not on the method itself.
// RUN: %clang_cc1 -fsyntax-only -verify -I%t/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -fmodule-name=Override %t/test-overriding.m
+// Test that
diff erent values of `ObjCMethodDecl::isPropertyAccessor` in
diff erent modules
+// is not an error because it depends on the surrounding code and not on the method itself.
+// RUN: %clang_cc1 -fsyntax-only -verify -I%t/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -fmodule-name=PropertyAccessor %t/test-property_accessor.m
+
//--- include/Common.h
@interface NSObject
@end
//--- include/Indirection.h
#import <Override.h>
+#import <PropertyAccessor.h>
//--- include/module.modulemap
module Common {
@@ -25,6 +30,10 @@ @interface NSObject
header "Override.h"
export *
}
+module PropertyAccessor {
+ header "PropertyAccessor.h"
+ export *
+}
//--- include/Override.h
#import <Common.h>
@@ -52,3 +61,31 @@ - (void)potentialOverride;
void triggerOverrideCheck(SubClass *sc) {
[sc potentialOverride];
}
+
+//--- include/PropertyAccessor.h
+#import <Common.h>
+ at interface PropertySubClass: NSObject
+- (int)potentialProperty;
+- (void)setPotentialProperty:(int)p;
+ at end
+
+//--- PropertyAccessor_Internal.h
+#import <PropertyAccessor.h>
+ at interface PropertySubClass()
+ at property int potentialProperty;
+ at end
+
+//--- test-property_accessor.m
+//expected-no-diagnostics
+// Get a version of `PropertySubClass` where `-[PropertySubClass potentialProperty]`
+// is a property accessor.
+#import "PropertyAccessor_Internal.h"
+
+// Get a version of `PropertySubClass` where `-[PropertySubClass potentialProperty]`
+// is not a property accessor because module "PropertyAccessor" doesn't know about PropertyAccessor_Internal.h.
+#import <Indirection.h>
+
+void triggerPropertyAccessorCheck(PropertySubClass *x) {
+ int tmp = [x potentialProperty];
+ [x setPotentialProperty: tmp];
+}
More information about the cfe-commits
mailing list