Skip to content

Commit 77b2ffc

Browse files
committed
Fix a reentrance bug with deserializing ObjC type parameters.
This is a longstanding bug that seems to have been hidden by a combination of (1) the normal flow being to deserialize the interface before deserializing its parameter and (2) a precise ordering of work that was apparently recently disturbed, perhaps by my abstract-serialization work or Bruno's ObjC module merging work. Fixes rdar://59153545.
1 parent 23f41f1 commit 77b2ffc

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void ASTDeclReader::Visit(Decl *D) {
555555

556556
void ASTDeclReader::VisitDecl(Decl *D) {
557557
if (D->isTemplateParameter() || D->isTemplateParameterPack() ||
558-
isa<ParmVarDecl>(D)) {
558+
isa<ParmVarDecl>(D) || isa<ObjCTypeParamDecl>(D)) {
559559
// We don't want to deserialize the DeclContext of a template
560560
// parameter or of a parameter of a function template immediately. These
561561
// entities might be used in the formulation of its DeclContext (for

clang/test/Modules/Inputs/module.map

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ module weird_objc {
193193
header "weird_objc.h"
194194
}
195195

196+
module objc_type_param {
197+
header "objc_type_param.h"
198+
}
199+
196200
module ignored_macros {
197201
header "ignored_macros.h"
198202
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__attribute__((objc_root_class))
2+
@interface Root {
3+
Class isa;
4+
}
5+
@end
6+
7+
@interface A<T,U> : Root
8+
@end
9+
10+
@interface B<T,U> : A<T,U>
11+
typedef void (*BCallback)(T, U);
12+
+ (id) newWithCallback: (BCallback) callback;
13+
@end

clang/test/Modules/objc-type-param.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=objc_type_param -emit-module %S/Inputs/module.map
2+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
3+
4+
@import objc_type_param;
5+
6+
id make(BCallback callback, id arg) {
7+
return callback(arg); // expected-error {{too few arguments to function call}}
8+
}

0 commit comments

Comments
 (0)