diff options
author | Aaron Puchert <aaron.puchert@sap.com> | 2022-05-13 13:37:30 +0200 |
---|---|---|
committer | Aaron Puchert <aaron.puchert@sap.com> | 2022-05-13 13:48:46 +0200 |
commit | d3a4033d6ee1d017e216ff7caeeeb5ca2e18a783 (patch) | |
tree | 5a211b469371a8244f060c2a79adee62ab9f3db8 /clang/lib/AST/CommentSema.cpp | |
parent | 99d35826a043916b259a0e440a2aa5cabbad2773 (diff) | |
download | llvm-d3a4033d6ee1d017e216ff7caeeeb5ca2e18a783.zip llvm-d3a4033d6ee1d017e216ff7caeeeb5ca2e18a783.tar.gz llvm-d3a4033d6ee1d017e216ff7caeeeb5ca2e18a783.tar.bz2 |
Comment parsing: Allow inline commands to have 0 or more than 1 argument
That's required to support `\n`, but can also be used for other commands.
We already had the infrastructure in place to parse a varying number of
arguments, we simply needed to generalize it so that it would work not
only for block commands.
This should fix #55319.
Reviewed By: gribozavr2
Differential Revision: https://reviews.llvm.org/D125429
Diffstat (limited to 'clang/lib/AST/CommentSema.cpp')
-rw-r--r-- | clang/lib/AST/CommentSema.cpp | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index 087f103..9b0f034 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -265,10 +265,8 @@ void Sema::actOnParamCommandParamNameArg(ParamCommandComment *Command, // User didn't provide a direction argument. Command->setDirection(ParamCommandComment::In, /* Explicit = */ false); } - typedef BlockCommandComment::Argument Argument; - Argument *A = new (Allocator) Argument(SourceRange(ArgLocBegin, - ArgLocEnd), - Arg); + auto *A = new (Allocator) + Comment::Argument{SourceRange(ArgLocBegin, ArgLocEnd), Arg}; Command->setArgs(llvm::makeArrayRef(A, 1)); } @@ -303,10 +301,8 @@ void Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command, // Parser will not feed us more arguments than needed. assert(Command->getNumArgs() == 0); - typedef BlockCommandComment::Argument Argument; - Argument *A = new (Allocator) Argument(SourceRange(ArgLocBegin, - ArgLocEnd), - Arg); + auto *A = new (Allocator) + Comment::Argument{SourceRange(ArgLocBegin, ArgLocEnd), Arg}; Command->setArgs(llvm::makeArrayRef(A, 1)); if (!isTemplateOrSpecialization()) { @@ -361,37 +357,15 @@ void Sema::actOnTParamCommandFinish(TParamCommandComment *Command, checkBlockCommandEmptyParagraph(Command); } -InlineCommandComment *Sema::actOnInlineCommand(SourceLocation CommandLocBegin, - SourceLocation CommandLocEnd, - unsigned CommandID) { - ArrayRef<InlineCommandComment::Argument> Args; +InlineCommandComment * +Sema::actOnInlineCommand(SourceLocation CommandLocBegin, + SourceLocation CommandLocEnd, unsigned CommandID, + ArrayRef<Comment::Argument> Args) { StringRef CommandName = Traits.getCommandInfo(CommandID)->Name; - return new (Allocator) InlineCommandComment( - CommandLocBegin, - CommandLocEnd, - CommandID, - getInlineCommandRenderKind(CommandName), - Args); -} -InlineCommandComment *Sema::actOnInlineCommand(SourceLocation CommandLocBegin, - SourceLocation CommandLocEnd, - unsigned CommandID, - SourceLocation ArgLocBegin, - SourceLocation ArgLocEnd, - StringRef Arg) { - typedef InlineCommandComment::Argument Argument; - Argument *A = new (Allocator) Argument(SourceRange(ArgLocBegin, - ArgLocEnd), - Arg); - StringRef CommandName = Traits.getCommandInfo(CommandID)->Name; - - return new (Allocator) InlineCommandComment( - CommandLocBegin, - CommandLocEnd, - CommandID, - getInlineCommandRenderKind(CommandName), - llvm::makeArrayRef(A, 1)); + return new (Allocator) + InlineCommandComment(CommandLocBegin, CommandLocEnd, CommandID, + getInlineCommandRenderKind(CommandName), Args); } InlineContentComment *Sema::actOnUnknownCommand(SourceLocation LocBegin, |