Skip to content

Commit 9e1a9e4

Browse files
committed
[BoundsSafety] Reland #93121 Allow 'counted_by' attribute on pointers in structs in C (#93121)
Fixes #92687. Previously the attribute was only allowed on flexible array members. This patch patch changes this to also allow the attribute on pointer fields in structs and also allows late parsing of the attribute in some contexts. For example this previously wasn't allowed: ``` struct BufferTypeDeclAttributePosition { size_t count; char* buffer __counted_by(count); // Now allowed } ``` Note the attribute is prevented on pointee types where the size isn't known at compile time. In particular pointee types that are: * Incomplete (e.g. `void`) and sizeless types * Function types (e.g. the pointee of a function pointer) * Struct types with a flexible array member This patch also introduces late parsing of the attribute when used in the declaration attribute position. For example ``` struct BufferTypeDeclAttributePosition { char* buffer __counted_by(count); // Now allowed size_t count; } ``` is now allowed but **only** when passing `-fexperimental-late-parse-attributes`. The motivation for using late parsing here is to avoid breaking the data layout of structs in existing code that want to use the `counted_by` attribute. This patch is the first use of `LateAttrParseExperimentalExt` in `Attr.td` that was introduced in a previous patch. Note by allowing the attribute on struct member pointers this now allows the possiblity of writing the attribute in the type attribute position. For example: ``` struct BufferTypeAttributePosition { size_t count; char *__counted_by(count) buffer; // Now allowed } ``` However, the attribute in this position is still currently parsed immediately rather than late parsed. So this will not parse currently: ``` struct BufferTypeAttributePosition { char *__counted_by(count) buffer; // Fails to parse size_t count; } ``` The intention is to lift this restriction in future patches. It has not been done in this patch to keep this size of this commit small. There are also several other follow up changes that will need to be addressed in future patches: * Make late parsing working with anonymous structs (see `on_pointer_anon_buf` in `attr-counted-by-late-parsed-struct-ptrs.c`). * Allow `counted_by` on more subjects (e.g. parameters, returns types) when `-fbounds-safety` is enabled. * Make use of the attribute on pointer types in code gen (e.g. for `_builtin_dynamic_object_size` and UBSan's array-bounds checks). This work is heavily based on a patch originally written by Yeoul Na. ** Differences between #93121 and this patch ** * The memory leak that caused #93121 to be reverted (see #92687) should now be fixed. See "The Memory Leak". * The fix to `pragma-attribute-supported-attributes-list.test` (originally in cef6387) has been incorporated into this patch. * A relaxation of counted_by semantics (originally in 112eadd) has been incorporated into this patch. * The assert in `Parser::DistributeCLateParsedAttrs` has been removed because that broke downstream code. * The switch statement in `Parser::ParseLexedCAttribute` has been removed in favor of using `Parser::ParseGNUAttributeArgs` which does the same thing but is more feature complete. * The `EnterScope` parameter has been plumbed through `Parser::ParseLexedCAttribute` and `Parser::ParseLexedCAttributeList`. It currently doesn't do anything but it will be needed in future commits. ** The Memory Leak ** The problem was that these lines parsed the attributes but then did nothing to free the memory ``` assert(!getLangOpts().CPlusPlus); for (auto *LateAttr : LateFieldAttrs) ParseLexedCAttribute(*LateAttr); ``` To fix this this a new `Parser::ParseLexedCAttributeList` method has been added (based on `Parser::ParseLexedAttributeList`) which does the necessary memory management. The intention is to merge these two methods together so there is just one implementation in a future patch. A more principled fixed here would be to fix the ownership of the `LateParsedAttribute` objects. In principle `LateParsedAttrList` should own its pointers exclusively and be responsible for deallocating them. Unfortunately this is complicated by `LateParsedAttribute` objects also being stored in another data structure (`LateParsedDeclarations`) as can be seen below (`LA` gets stored in two places). ``` // Handle attributes with arguments that require late parsing. LateParsedAttribute *LA = new LateParsedAttribute(this, *AttrName, AttrNameLoc); LateAttrs->push_back(LA); // Attributes in a class are parsed at the end of the class, along // with other late-parsed declarations. if (!ClassStack.empty() && !LateAttrs->parseSoon()) getCurrentClass().LateParsedDeclarations.push_back(LA); ``` this means the ownership of LateParsedAttribute objects isn't very clear. rdar://125400257
1 parent e6b14b6 commit 9e1a9e4

23 files changed

+1147
-149
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ New Compiler Flags
317317

318318
- ``-fexperimental-late-parse-attributes`` enables an experimental feature to
319319
allow late parsing certain attributes in specific contexts where they would
320-
not normally be late parsed.
320+
not normally be late parsed. Currently this allows late parsing the
321+
`counted_by` attribute in C. See `Attribute Changes in Clang`_.
321322

322323
- ``-fseparate-named-sections`` uses separate unique sections for global
323324
symbols in named special sections (i.e. symbols annotated with
@@ -406,6 +407,24 @@ Attribute Changes in Clang
406407
- The ``clspv_libclc_builtin`` attribute has been added to allow clspv
407408
(`OpenCL-C to Vulkan SPIR-V compiler <https://github.com/google/clspv>`_) to identify functions coming from libclc
408409
(`OpenCL-C builtin library <https://libclc.llvm.org>`_).
410+
- The ``counted_by`` attribute is now allowed on pointers that are members of a
411+
struct in C.
412+
413+
- The ``counted_by`` attribute can now be late parsed in C when
414+
``-fexperimental-late-parse-attributes`` is passed but only when attribute is
415+
used in the declaration attribute position. This allows using the
416+
attribute on existing code where it previously impossible to do so without
417+
re-ordering struct field declarations would break ABI as shown below.
418+
419+
.. code-block:: c
420+
421+
struct BufferTy {
422+
/* Refering to `count` requires late parsing */
423+
char* buffer __counted_by(count);
424+
/* Swapping `buffer` and `count` to avoid late parsing would break ABI */
425+
size_t count;
426+
};
427+
409428
410429
Improvements to Clang's diagnostics
411430
-----------------------------------

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25152515
bool isRecordType() const;
25162516
bool isClassType() const;
25172517
bool isStructureType() const;
2518+
bool isStructureTypeWithFlexibleArrayMember() const;
25182519
bool isObjCBoxableRecordType() const;
25192520
bool isInterfaceType() const;
25202521
bool isStructureOrClassType() const;

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,8 @@ def TypeNullUnspecified : TypeAttr {
22562256
def CountedBy : DeclOrTypeAttr {
22572257
let Spellings = [Clang<"counted_by">];
22582258
let Subjects = SubjectList<[Field], ErrorDiag>;
2259-
let Args = [ExprArgument<"Count">, IntArgument<"NestedLevel">];
2259+
let Args = [ExprArgument<"Count">, IntArgument<"NestedLevel", 1>];
2260+
let LateParsed = LateAttrParseExperimentalExt;
22602261
let ParseArgumentsAsUnevaluated = 1;
22612262
let Documentation = [CountedByDocs];
22622263
let LangOpts = [COnly];

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,10 @@ def FunctionMultiVersioning
14471447

14481448
def NoDeref : DiagGroup<"noderef">;
14491449

1450+
// -fbounds-safety and bounds annotation related warnings
1451+
def BoundsSafetyCountedByEltTyUnknownSize :
1452+
DiagGroup<"bounds-safety-counted-by-elt-type-unknown-size">;
1453+
14501454
// A group for cross translation unit static analysis related warnings.
14511455
def CrossTU : DiagGroup<"ctu">;
14521456

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6544,8 +6544,10 @@ def warn_superclass_variable_sized_type_not_at_end : Warning<
65446544

65456545
def err_flexible_array_count_not_in_same_struct : Error<
65466546
"'counted_by' field %0 isn't within the same struct as the flexible array">;
6547-
def err_counted_by_attr_not_on_flexible_array_member : Error<
6548-
"'counted_by' only applies to C99 flexible array members">;
6547+
def err_counted_by_attr_not_on_ptr_or_flexible_array_member : Error<
6548+
"'counted_by' only applies to pointers or C99 flexible array members">;
6549+
def err_counted_by_attr_on_array_not_flexible_array_member : Error<
6550+
"'counted_by' on arrays only applies to C99 flexible array members">;
65496551
def err_counted_by_attr_refer_to_itself : Error<
65506552
"'counted_by' cannot refer to the flexible array member %0">;
65516553
def err_counted_by_must_be_in_structure : Error<
@@ -6560,6 +6562,23 @@ def err_counted_by_attr_refer_to_union : Error<
65606562
"'counted_by' argument cannot refer to a union member">;
65616563
def note_flexible_array_counted_by_attr_field : Note<
65626564
"field %0 declared here">;
6565+
def err_counted_by_attr_pointee_unknown_size : Error<
6566+
"'counted_by' %select{cannot|should not}3 be applied to %select{"
6567+
"a pointer with pointee|" // pointer
6568+
"an array with element}0" // array
6569+
" of unknown size because %1 is %select{"
6570+
"an incomplete type|" // CountedByInvalidPointeeTypeKind::INCOMPLETE
6571+
"a sizeless type|" // CountedByInvalidPointeeTypeKind::SIZELESS
6572+
"a function type|" // CountedByInvalidPointeeTypeKind::FUNCTION
6573+
// CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER
6574+
"a struct type with a flexible array member"
6575+
"%select{|. This will be an error in a future compiler version}3"
6576+
""
6577+
"}2">;
6578+
6579+
def warn_counted_by_attr_elt_type_unknown_size :
6580+
Warning<err_counted_by_attr_pointee_unknown_size.Summary>,
6581+
InGroup<BoundsSafetyCountedByEltTyUnknownSize>;
65636582

65646583
let CategoryName = "ARC Semantic Issue" in {
65656584

clang/include/clang/Parse/Parser.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,8 +1646,12 @@ class Parser : public CodeCompletionHandler {
16461646
void ParseLexedAttributes(ParsingClass &Class);
16471647
void ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
16481648
bool EnterScope, bool OnDefinition);
1649+
void ParseLexedCAttributeList(LateParsedAttrList &LA, bool EnterScope,
1650+
ParsedAttributes *OutAttrs = nullptr);
16491651
void ParseLexedAttribute(LateParsedAttribute &LA,
16501652
bool EnterScope, bool OnDefinition);
1653+
void ParseLexedCAttribute(LateParsedAttribute &LA, bool EnterScope,
1654+
ParsedAttributes *OutAttrs = nullptr);
16511655
void ParseLexedMethodDeclarations(ParsingClass &Class);
16521656
void ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM);
16531657
void ParseLexedMethodDefs(ParsingClass &Class);
@@ -2534,7 +2538,8 @@ class Parser : public CodeCompletionHandler {
25342538

25352539
void ParseStructDeclaration(
25362540
ParsingDeclSpec &DS,
2537-
llvm::function_ref<void(ParsingFieldDeclarator &)> FieldsCallback);
2541+
llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
2542+
LateParsedAttrList *LateFieldAttrs = nullptr);
25382543

25392544
DeclGroupPtrTy ParseTopLevelStmtDecl();
25402545

@@ -3112,6 +3117,8 @@ class Parser : public CodeCompletionHandler {
31123117
SourceLocation ScopeLoc,
31133118
ParsedAttr::Form Form);
31143119

3120+
void DistributeCLateParsedAttrs(Decl *Dcl, LateParsedAttrList *LateAttrs);
3121+
31153122
void ParseBoundsAttribute(IdentifierInfo &AttrName,
31163123
SourceLocation AttrNameLoc, ParsedAttributes &Attrs,
31173124
IdentifierInfo *ScopeName, SourceLocation ScopeLoc,

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11381,7 +11381,8 @@ class Sema final : public SemaBase {
1138111381
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns,
1138211382
SourceLocation AttrLoc);
1138311383

11384-
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr);
11384+
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy,
11385+
Expr *CountExpr);
1138511386

1138611387
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace,
1138711388
SourceLocation AttrLoc);

clang/lib/AST/Type.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,16 @@ bool Type::isStructureType() const {
632632
return false;
633633
}
634634

635+
bool Type::isStructureTypeWithFlexibleArrayMember() const {
636+
const auto *RT = getAs<RecordType>();
637+
if (!RT)
638+
return false;
639+
const auto *Decl = RT->getDecl();
640+
if (!Decl->isStruct())
641+
return false;
642+
return Decl->hasFlexibleArrayMember();
643+
}
644+
635645
bool Type::isObjCBoxableRecordType() const {
636646
if (const auto *RT = getAs<RecordType>())
637647
return RT->getDecl()->hasAttr<ObjCBoxableAttr>();

clang/lib/Parse/ParseDecl.cpp

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,6 +3306,19 @@ void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs,
33063306
}
33073307
}
33083308

3309+
void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
3310+
LateParsedAttrList *LateAttrs) {
3311+
if (!LateAttrs)
3312+
return;
3313+
3314+
if (Dcl) {
3315+
for (auto *LateAttr : *LateAttrs) {
3316+
if (LateAttr->Decls.empty())
3317+
LateAttr->addDecl(Dcl);
3318+
}
3319+
}
3320+
}
3321+
33093322
/// Bounds attributes (e.g., counted_by):
33103323
/// AttrName '(' expression ')'
33113324
void Parser::ParseBoundsAttribute(IdentifierInfo &AttrName,
@@ -4843,13 +4856,14 @@ static void DiagnoseCountAttributedTypeInUnnamedAnon(ParsingDeclSpec &DS,
48434856
///
48444857
void Parser::ParseStructDeclaration(
48454858
ParsingDeclSpec &DS,
4846-
llvm::function_ref<void(ParsingFieldDeclarator &)> FieldsCallback) {
4859+
llvm::function_ref<Decl *(ParsingFieldDeclarator &)> FieldsCallback,
4860+
LateParsedAttrList *LateFieldAttrs) {
48474861

48484862
if (Tok.is(tok::kw___extension__)) {
48494863
// __extension__ silences extension warnings in the subexpression.
48504864
ExtensionRAIIObject O(Diags); // Use RAII to do this.
48514865
ConsumeToken();
4852-
return ParseStructDeclaration(DS, FieldsCallback);
4866+
return ParseStructDeclaration(DS, FieldsCallback, LateFieldAttrs);
48534867
}
48544868

48554869
// Parse leading attributes.
@@ -4914,10 +4928,12 @@ void Parser::ParseStructDeclaration(
49144928
}
49154929

49164930
// If attributes exist after the declarator, parse them.
4917-
MaybeParseGNUAttributes(DeclaratorInfo.D);
4931+
MaybeParseGNUAttributes(DeclaratorInfo.D, LateFieldAttrs);
49184932

49194933
// We're done with this declarator; invoke the callback.
4920-
FieldsCallback(DeclaratorInfo);
4934+
Decl *Field = FieldsCallback(DeclaratorInfo);
4935+
if (Field)
4936+
DistributeCLateParsedAttrs(Field, LateFieldAttrs);
49214937

49224938
// If we don't have a comma, it is either the end of the list (a ';')
49234939
// or an error, bail out.
@@ -4928,6 +4944,73 @@ void Parser::ParseStructDeclaration(
49284944
}
49294945
}
49304946

4947+
// TODO: All callers of this function should be moved to
4948+
// `Parser::ParseLexedAttributeList`.
4949+
void Parser::ParseLexedCAttributeList(LateParsedAttrList &LAs, bool EnterScope,
4950+
ParsedAttributes *OutAttrs) {
4951+
assert(LAs.parseSoon() &&
4952+
"Attribute list should be marked for immediate parsing.");
4953+
for (auto *LA : LAs) {
4954+
ParseLexedCAttribute(*LA, EnterScope, OutAttrs);
4955+
delete LA;
4956+
}
4957+
LAs.clear();
4958+
}
4959+
4960+
/// Finish parsing an attribute for which parsing was delayed.
4961+
/// This will be called at the end of parsing a class declaration
4962+
/// for each LateParsedAttribute. We consume the saved tokens and
4963+
/// create an attribute with the arguments filled in. We add this
4964+
/// to the Attribute list for the decl.
4965+
void Parser::ParseLexedCAttribute(LateParsedAttribute &LA, bool EnterScope,
4966+
ParsedAttributes *OutAttrs) {
4967+
// Create a fake EOF so that attribute parsing won't go off the end of the
4968+
// attribute.
4969+
Token AttrEnd;
4970+
AttrEnd.startToken();
4971+
AttrEnd.setKind(tok::eof);
4972+
AttrEnd.setLocation(Tok.getLocation());
4973+
AttrEnd.setEofData(LA.Toks.data());
4974+
LA.Toks.push_back(AttrEnd);
4975+
4976+
// Append the current token at the end of the new token stream so that it
4977+
// doesn't get lost.
4978+
LA.Toks.push_back(Tok);
4979+
PP.EnterTokenStream(LA.Toks, /*DisableMacroExpansion=*/true,
4980+
/*IsReinject=*/true);
4981+
// Drop the current token and bring the first cached one. It's the same token
4982+
// as when we entered this function.
4983+
ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true);
4984+
4985+
// TODO: Use `EnterScope`
4986+
(void)EnterScope;
4987+
4988+
ParsedAttributes Attrs(AttrFactory);
4989+
4990+
assert(LA.Decls.size() <= 1 &&
4991+
"late field attribute expects to have at most one declaration.");
4992+
4993+
// Dispatch based on the attribute and parse it
4994+
ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, nullptr, nullptr,
4995+
SourceLocation(), ParsedAttr::Form::GNU(), nullptr);
4996+
4997+
for (auto *D : LA.Decls)
4998+
Actions.ActOnFinishDelayedAttribute(getCurScope(), D, Attrs);
4999+
5000+
// Due to a parsing error, we either went over the cached tokens or
5001+
// there are still cached tokens left, so we skip the leftover tokens.
5002+
while (Tok.isNot(tok::eof))
5003+
ConsumeAnyToken();
5004+
5005+
// Consume the fake EOF token if it's there
5006+
if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
5007+
ConsumeAnyToken();
5008+
5009+
if (OutAttrs) {
5010+
OutAttrs->takeAllFrom(Attrs);
5011+
}
5012+
}
5013+
49315014
/// ParseStructUnionBody
49325015
/// struct-contents:
49335016
/// struct-declaration-list
@@ -4951,6 +5034,11 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
49515034
ParseScope StructScope(this, Scope::ClassScope|Scope::DeclScope);
49525035
Actions.ActOnTagStartDefinition(getCurScope(), TagDecl);
49535036

5037+
// `LateAttrParseExperimentalExtOnly=true` requests that only attributes
5038+
// marked with `LateAttrParseExperimentalExt` are late parsed.
5039+
LateParsedAttrList LateFieldAttrs(/*PSoon=*/true,
5040+
/*LateAttrParseExperimentalExtOnly=*/true);
5041+
49545042
// While we still have something to read, read the declarations in the struct.
49555043
while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
49565044
Tok.isNot(tok::eof)) {
@@ -5001,18 +5089,19 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
50015089
}
50025090

50035091
if (!Tok.is(tok::at)) {
5004-
auto CFieldCallback = [&](ParsingFieldDeclarator &FD) {
5092+
auto CFieldCallback = [&](ParsingFieldDeclarator &FD) -> Decl * {
50055093
// Install the declarator into the current TagDecl.
50065094
Decl *Field =
50075095
Actions.ActOnField(getCurScope(), TagDecl,
50085096
FD.D.getDeclSpec().getSourceRange().getBegin(),
50095097
FD.D, FD.BitfieldSize);
50105098
FD.complete(Field);
5099+
return Field;
50115100
};
50125101

50135102
// Parse all the comma separated declarators.
50145103
ParsingDeclSpec DS(*this);
5015-
ParseStructDeclaration(DS, CFieldCallback);
5104+
ParseStructDeclaration(DS, CFieldCallback, &LateFieldAttrs);
50165105
} else { // Handle @defs
50175106
ConsumeToken();
50185107
if (!Tok.isObjCAtKeyword(tok::objc_defs)) {
@@ -5053,7 +5142,10 @@ void Parser::ParseStructUnionBody(SourceLocation RecordLoc,
50535142

50545143
ParsedAttributes attrs(AttrFactory);
50555144
// If attributes exist after struct contents, parse them.
5056-
MaybeParseGNUAttributes(attrs);
5145+
MaybeParseGNUAttributes(attrs, &LateFieldAttrs);
5146+
5147+
// Late parse field attributes if necessary.
5148+
ParseLexedCAttributeList(LateFieldAttrs, /*EnterScope=*/false);
50575149

50585150
SmallVector<Decl *, 32> FieldDecls(TagDecl->fields());
50595151

clang/lib/Parse/ParseObjc.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,16 +780,16 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
780780
}
781781

782782
bool addedToDeclSpec = false;
783-
auto ObjCPropertyCallback = [&](ParsingFieldDeclarator &FD) {
783+
auto ObjCPropertyCallback = [&](ParsingFieldDeclarator &FD) -> Decl * {
784784
if (FD.D.getIdentifier() == nullptr) {
785785
Diag(AtLoc, diag::err_objc_property_requires_field_name)
786786
<< FD.D.getSourceRange();
787-
return;
787+
return nullptr;
788788
}
789789
if (FD.BitfieldSize) {
790790
Diag(AtLoc, diag::err_objc_property_bitfield)
791791
<< FD.D.getSourceRange();
792-
return;
792+
return nullptr;
793793
}
794794

795795
// Map a nullability property attribute to a context-sensitive keyword
@@ -818,6 +818,7 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
818818
MethodImplKind);
819819

820820
FD.complete(Property);
821+
return Property;
821822
};
822823

823824
// Parse all the comma separated declarators.
@@ -2013,7 +2014,7 @@ void Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
20132014
continue;
20142015
}
20152016

2016-
auto ObjCIvarCallback = [&](ParsingFieldDeclarator &FD) {
2017+
auto ObjCIvarCallback = [&](ParsingFieldDeclarator &FD) -> Decl * {
20172018
assert(getObjCDeclContext() == interfaceDecl &&
20182019
"Ivar should have interfaceDecl as its decl context");
20192020
// Install the declarator into the interface decl.
@@ -2024,6 +2025,7 @@ void Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
20242025
if (Field)
20252026
AllIvarDecls.push_back(Field);
20262027
FD.complete(Field);
2028+
return Field;
20272029
};
20282030

20292031
// Parse all the comma separated declarators.

0 commit comments

Comments
 (0)