[clang] c593126 - [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.
Volodymyr Sapsai via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 20 18:48:55 PDT 2021
Author: Volodymyr Sapsai
Date: 2021-10-20T18:48:29-07:00
New Revision: c5931267db26d71351c634df06006d9c818ff158
URL: https://github.com/llvm/llvm-project/commit/c5931267db26d71351c634df06006d9c818ff158
DIFF: https://github.com/llvm/llvm-project/commit/c5931267db26d71351c634df06006d9c818ff158.diff
LOG: [modules] While merging ObjCInterfaceDecl definitions, merge them as decl contexts too.
While working on https://reviews.llvm.org/D110280 I've tried to merge
decl contexts as it seems to be correct and matching our handling of
decl contexts from different modules. It's not required for the fix in
https://reviews.llvm.org/D110280 but it revealed a missing diagnostic,
so separating this change into a separate commit.
Renamed some variables to distinguish diagnostic like "declaration of
'x' does not match" for different cases.
Differential Revision: https://reviews.llvm.org/D110287
Added:
Modified:
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/Modules/odr_hash.mm
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index f2c2023cbf233..7aab708d00e4a 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1177,6 +1177,12 @@ void ASTDeclReader::ReadObjCDefinitionData(
void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
+ struct ObjCInterfaceDecl::DefinitionData &DD = D->data();
+ if (DD.Definition != NewDD.Definition) {
+ Reader.MergedDeclContexts.insert(
+ std::make_pair(NewDD.Definition, DD.Definition));
+ }
+
// FIXME: odr checking?
}
diff --git a/clang/test/Modules/odr_hash.mm b/clang/test/Modules/odr_hash.mm
index 86ddd16b94fb7..276bd58624eca 100644
--- a/clang/test/Modules/odr_hash.mm
+++ b/clang/test/Modules/odr_hash.mm
@@ -241,12 +241,12 @@ @interface Interface4 <T : I1 *> {
@end
@interface Interface5 <T : I1 *> {
@public
- T<P1> x;
+ T<P1> y;
}
@end
@interface Interface6 <T1 : I1 *, T2 : I2 *> {
@public
- T1 x;
+ T1 z;
}
@end
#elif defined(SECOND)
@@ -257,14 +257,21 @@ @interface Interface4 <T : I1 *> {
@end
@interface Interface5 <T : I1 *> {
@public
- T<P1, P2> x;
+ T<P1, P2> y;
}
@end
@interface Interface6 <T1 : I1 *, T2 : I2 *> {
@public
- T2 x;
+ T2 z;
}
@end
+#else
+// expected-error at first.h:* {{'Interface4::x' from module 'FirstModule' is not present in definition of 'Interface4' in module 'SecondModule'}}
+// expected-note at second.h:* {{declaration of 'x' does not match}}
+// expected-error at first.h:* {{'Interface5::y' from module 'FirstModule' is not present in definition of 'Interface5' in module 'SecondModule'}}
+// expected-note at second.h:* {{declaration of 'y' does not match}}
+// expected-error at first.h:* {{'Interface6::z' from module 'FirstModule' is not present in definition of 'Interface6' in module 'SecondModule'}}
+// expected-note at second.h:* {{declaration of 'z' does not match}}
#endif
namespace Types {
@@ -276,22 +283,22 @@ @interface Interface6 <T1 : I1 *, T2 : I2 *> {
};
struct Invalid2 {
Interface5 *I;
- decltype(I->x) x;
+ decltype(I->y) y;
};
struct Invalid3 {
Interface6 *I;
- decltype(I->x) x;
+ decltype(I->z) z;
};
#else
Invalid1 i1;
// expected-error at first.h:* {{'Types::ObjCTypeParam::Invalid1::x' from module 'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid1' in module 'SecondModule'}}
// expected-note at second.h:* {{declaration of 'x' does not match}}
Invalid2 i2;
-// expected-error at first.h:* {{'Types::ObjCTypeParam::Invalid2::x' from module 'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid2' in module 'SecondModule'}}
-// expected-note at second.h:* {{declaration of 'x' does not match}}
+// expected-error at first.h:* {{'Types::ObjCTypeParam::Invalid2::y' from module 'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid2' in module 'SecondModule'}}
+// expected-note at second.h:* {{declaration of 'y' does not match}}
Invalid3 i3;
-// expected-error at first.h:* {{'Types::ObjCTypeParam::Invalid3::x' from module 'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid3' in module 'SecondModule'}}
-// expected-note at second.h:* {{declaration of 'x' does not match}}
+// expected-error at first.h:* {{'Types::ObjCTypeParam::Invalid3::z' from module 'FirstModule' is not present in definition of 'Types::ObjCTypeParam::Invalid3' in module 'SecondModule'}}
+// expected-note at second.h:* {{declaration of 'z' does not match}}
#endif
} // namespace ObjCTypeParam
More information about the cfe-commits
mailing list