[SyntaxParse] Fix ASAN issue

rdar://problem/55711699
rdar://problem/55711787
rdar://problem/55711952
This commit is contained in:
Rintaro Ishizaki
2019-09-25 21:27:44 -07:00
parent 7189c09720
commit d9eba19b74
2 changed files with 16 additions and 8 deletions

View File

@@ -574,9 +574,12 @@ GenericParamList *ASTGen::generate(const GenericParameterClauseSyntax &clause,
DeclAttributes attrs;
if (auto attrsSyntax = elem.getAttributes()) {
auto attrsLoc = advanceLocBegin(Loc, *attrsSyntax->getFirstToken());
if (auto firstTok = attrsSyntax->getFirstToken()) {
auto attrsLoc = advanceLocBegin(Loc, *firstTok);
if (hasDeclAttributes(attrsLoc))
attrs = getDeclAttributes(attrsLoc);
}
}
Identifier name = Context.getIdentifier(elem.getName().getIdentifierText());
SourceLoc nameLoc = advanceLocBegin(Loc, elem.getName());

View File

@@ -73,12 +73,17 @@ Parser::parseGenericParameterClauseSyntax() {
// Parse attributes.
// TODO: Implement syntax attribute parsing.
if (Tok.is(tok::at_sign)) {
SyntaxParsingContext TmpCtxt(SyntaxContext);
TmpCtxt.setTransparent();
DeclAttributes attrsAST;
parseDeclAttributeList(attrsAST);
auto attrs = SyntaxContext->popIf<ParsedAttributeListSyntax>();
if (attrs) {
paramBuilder.useAttributes(std::move(*attrs));
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.