Skip to content

[ObjC] Fix AST serialization for pseudo-strong parameters #1320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions clang/lib/Serialization/ASTWriterDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,6 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
Record.AddStmt(D->getUninstantiatedDefaultArg());
Code = serialization::DECL_PARM_VAR;

assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl

// If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here
// we dynamically check for the properties that we optimize for, but don't
// know are true of all PARM_VAR_DECLs.
Expand Down Expand Up @@ -2096,7 +2094,7 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // SClass
Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
Abv->Add(BitCodeAbbrevOp(0)); // ARCPseudoStrong
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
Abv->Add(BitCodeAbbrevOp(0)); // Linkage
Abv->Add(BitCodeAbbrevOp(0)); // HasInit
Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
Expand Down
30 changes: 30 additions & 0 deletions clang/test/PCH/externally-retained.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Test for assertion failure due to objc_externally_retained on a function.

// Without PCH
// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-arc -include %s %s

// With PCH
// RUN: %clang_cc1 %s -emit-pch -fobjc-arc -o %t
// RUN: %clang_cc1 -emit-llvm-only -verify %s -fobjc-arc -include-pch %t -debug-info-kind=limited

// expected-no-diagnostics

#ifndef HEADER
#define HEADER
//===----------------------------------------------------------------------===//
// Header

__attribute__((objc_externally_retained)) void doSomething(id someObject);

id sharedObject = 0;

//===----------------------------------------------------------------------===//
#else
//===----------------------------------------------------------------------===//

void callDoSomething() {
doSomething(sharedObject);
}

//===----------------------------------------------------------------------===//
#endif