mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SyntaxParse] Fix ASAN issue
rdar://problem/55711699 rdar://problem/55711787 rdar://problem/55711952
This commit is contained in:
@@ -574,8 +574,11 @@ GenericParamList *ASTGen::generate(const GenericParameterClauseSyntax &clause,
|
|||||||
|
|
||||||
DeclAttributes attrs;
|
DeclAttributes attrs;
|
||||||
if (auto attrsSyntax = elem.getAttributes()) {
|
if (auto attrsSyntax = elem.getAttributes()) {
|
||||||
auto attrsLoc = advanceLocBegin(Loc, *attrsSyntax->getFirstToken());
|
if (auto firstTok = attrsSyntax->getFirstToken()) {
|
||||||
attrs = getDeclAttributes(attrsLoc);
|
auto attrsLoc = advanceLocBegin(Loc, *firstTok);
|
||||||
|
if (hasDeclAttributes(attrsLoc))
|
||||||
|
attrs = getDeclAttributes(attrsLoc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Identifier name = Context.getIdentifier(elem.getName().getIdentifierText());
|
Identifier name = Context.getIdentifier(elem.getName().getIdentifierText());
|
||||||
SourceLoc nameLoc = advanceLocBegin(Loc, elem.getName());
|
SourceLoc nameLoc = advanceLocBegin(Loc, elem.getName());
|
||||||
|
|||||||
@@ -73,12 +73,17 @@ Parser::parseGenericParameterClauseSyntax() {
|
|||||||
|
|
||||||
// Parse attributes.
|
// Parse attributes.
|
||||||
// TODO: Implement syntax attribute parsing.
|
// TODO: Implement syntax attribute parsing.
|
||||||
DeclAttributes attrsAST;
|
if (Tok.is(tok::at_sign)) {
|
||||||
parseDeclAttributeList(attrsAST);
|
SyntaxParsingContext TmpCtxt(SyntaxContext);
|
||||||
auto attrs = SyntaxContext->popIf<ParsedAttributeListSyntax>();
|
TmpCtxt.setTransparent();
|
||||||
if (attrs) {
|
|
||||||
paramBuilder.useAttributes(std::move(*attrs));
|
DeclAttributes attrsAST;
|
||||||
Generator.addDeclAttributes(attrsAST, attrsAST.getStartLoc());
|
parseDeclAttributeList(attrsAST);
|
||||||
|
if (!attrsAST.isEmpty())
|
||||||
|
Generator.addDeclAttributes(attrsAST, attrsAST.getStartLoc());
|
||||||
|
auto attrs = SyntaxContext->popIf<ParsedAttributeListSyntax>();
|
||||||
|
if (attrs)
|
||||||
|
paramBuilder.useAttributes(std::move(*attrs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the name of the parameter.
|
// Parse the name of the parameter.
|
||||||
|
|||||||
Reference in New Issue
Block a user