Commit e1b73356 authored by John McCall's avatar John McCall Committed by Hans Wennborg
Browse files

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.

(cherry picked from commit 77b2ffc4)
parent 808f8a63
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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"
}
+13 −0
Original line number Diff line number Diff line
__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
+8 −0
Original line number Diff line number Diff line
// 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}}
}