Author: John McCall Date: 2020-02-12T18:44:19-05:00 New Revision: 77b2ffc498e92cce7546d191f6712a3046300501
URL: https://github.com/llvm/llvm-project/commit/77b2ffc498e92cce7546d191f6712a3046300501 DIFF: https://github.com/llvm/llvm-project/commit/77b2ffc498e92cce7546d191f6712a3046300501.diff LOG: 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. Added: clang/test/Modules/Inputs/objc_type_param.h clang/test/Modules/objc-type-param.m Modified: clang/lib/Serialization/ASTReaderDecl.cpp clang/test/Modules/Inputs/module.map Removed: ################################################################################ diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 3d47274079fa..20a4f78f16e9 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -555,7 +555,7 @@ void ASTDeclReader::Visit(Decl *D) { void ASTDeclReader::VisitDecl(Decl *D) { if (D->isTemplateParameter() || D->isTemplateParameterPack() || - isa<ParmVarDecl>(D)) { + isa<ParmVarDecl>(D) || isa<ObjCTypeParamDecl>(D)) { // We don't want to deserialize the DeclContext of a template // parameter or of a parameter of a function template immediately. These // entities might be used in the formulation of its DeclContext (for diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index 3f128c0bb0e0..ed220e667f05 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -193,6 +193,10 @@ module weird_objc { header "weird_objc.h" } +module objc_type_param { + header "objc_type_param.h" +} + module ignored_macros { header "ignored_macros.h" } diff --git a/clang/test/Modules/Inputs/objc_type_param.h b/clang/test/Modules/Inputs/objc_type_param.h new file mode 100644 index 000000000000..7728b68e28e9 --- /dev/null +++ b/clang/test/Modules/Inputs/objc_type_param.h @@ -0,0 +1,13 @@ +__attribute__((objc_root_class)) +@interface Root { + Class isa; +} +@end + +@interface A<T,U> : Root +@end + +@interface B<T,U> : A<T,U> +typedef void (*BCallback)(T, U); ++ (id) newWithCallback: (BCallback) callback; +@end diff --git a/clang/test/Modules/objc-type-param.m b/clang/test/Modules/objc-type-param.m new file mode 100644 index 000000000000..3417d62b25ff --- /dev/null +++ b/clang/test/Modules/objc-type-param.m @@ -0,0 +1,8 @@ +// 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 +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify + +@import objc_type_param; + +id make(BCallback callback, id arg) { + return callback(arg); // expected-error {{too few arguments to function call}} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits