[llvm-branch-commits] [clang] e1b7335 - Fix a reentrance bug with deserializing ObjC type parameters.
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 13 00:39:12 PST 2020
Author: John McCall
Date: 2020-02-13T09:37:31+01:00
New Revision: e1b73356879b1d9a8095de27e33943ae84d8f495
URL: https://github.com/llvm/llvm-project/commit/e1b73356879b1d9a8095de27e33943ae84d8f495
DIFF: https://github.com/llvm/llvm-project/commit/e1b73356879b1d9a8095de27e33943ae84d8f495.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.
(cherry picked from commit 77b2ffc498e92cce7546d191f6712a3046300501)
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 093b69ab19d0..362b5a564ab9 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))
+ at interface Root {
+ Class isa;
+}
+ at end
+
+ at interface A<T,U> : Root
+ at end
+
+ at interface B<T,U> : A<T,U>
+typedef void (*BCallback)(T, U);
++ (id) newWithCallback: (BCallback) callback;
+ at 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
+
+ at import objc_type_param;
+
+id make(BCallback callback, id arg) {
+ return callback(arg); // expected-error {{too few arguments to function call}}
+}
More information about the llvm-branch-commits
mailing list