diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2013-03-04 23:06:15 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2013-03-04 23:06:15 +0000 |
commit | 808383d2d6d58a7c7db85f8c7618fb74d821309f (patch) | |
tree | 4e52656cdb9cfaeb29e9f0f2d55c2527e674ec47 /lib/AST/CommentSema.cpp | |
parent | 2503ebd2cf9b4d28319551debaacff8b38765698 (diff) |
Comment parsing: refactor handling of command markers in AST
* Use the term 'command marker', because the semantics of 'backslash' and 'at'
commands are the same. (Talking about 'at commands' makes them look like a
special entity.)
* Sink the flag down into bitfields, reducing the size of AST nodes.
* Change the flag into an enum for clarity. Boolean function parameters are
not very clear.
* Add unittests for new tok::at_command tokens.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/CommentSema.cpp')
-rw-r--r-- | lib/AST/CommentSema.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index dab48e05df..d959d19b91 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -47,11 +47,13 @@ ParagraphComment *Sema::actOnParagraphComment( return new (Allocator) ParagraphComment(Content); } -BlockCommandComment *Sema::actOnBlockCommandStart(SourceLocation LocBegin, - SourceLocation LocEnd, - unsigned CommandID, - bool AtCommand) { - return new (Allocator) BlockCommandComment(LocBegin, LocEnd, CommandID, AtCommand); +BlockCommandComment *Sema::actOnBlockCommandStart( + SourceLocation LocBegin, + SourceLocation LocEnd, + unsigned CommandID, + CommandMarkerKind CommandMarker) { + return new (Allocator) BlockCommandComment(LocBegin, LocEnd, CommandID, + CommandMarker); } void Sema::actOnBlockCommandArgs(BlockCommandComment *Command, @@ -68,17 +70,19 @@ void Sema::actOnBlockCommandFinish(BlockCommandComment *Command, checkDeprecatedCommand(Command); } -ParamCommandComment *Sema::actOnParamCommandStart(SourceLocation LocBegin, - SourceLocation LocEnd, - unsigned CommandID, - bool AtCommand) { +ParamCommandComment *Sema::actOnParamCommandStart( + SourceLocation LocBegin, + SourceLocation LocEnd, + unsigned CommandID, + CommandMarkerKind CommandMarker) { ParamCommandComment *Command = - new (Allocator) ParamCommandComment(LocBegin, LocEnd, CommandID, AtCommand); + new (Allocator) ParamCommandComment(LocBegin, LocEnd, CommandID, + CommandMarker); if (!isFunctionDecl()) Diag(Command->getLocation(), diag::warn_doc_param_not_attached_to_a_function_decl) - << AtCommand + << CommandMarker << Command->getCommandNameRange(Traits); return Command; @@ -163,17 +167,19 @@ void Sema::actOnParamCommandFinish(ParamCommandComment *Command, checkBlockCommandEmptyParagraph(Command); } -TParamCommandComment *Sema::actOnTParamCommandStart(SourceLocation LocBegin, - SourceLocation LocEnd, - unsigned CommandID, - bool AtCommand) { +TParamCommandComment *Sema::actOnTParamCommandStart( + SourceLocation LocBegin, + SourceLocation LocEnd, + unsigned CommandID, + CommandMarkerKind CommandMarker) { TParamCommandComment *Command = - new (Allocator) TParamCommandComment(LocBegin, LocEnd, CommandID, AtCommand); + new (Allocator) TParamCommandComment(LocBegin, LocEnd, CommandID, + CommandMarker); if (!isTemplateOrSpecialization()) Diag(Command->getLocation(), diag::warn_doc_tparam_not_attached_to_a_template_decl) - << AtCommand + << CommandMarker << Command->getCommandNameRange(Traits); return Command; @@ -437,7 +443,7 @@ void Sema::checkBlockCommandEmptyParagraph(BlockCommandComment *Command) { if (!DiagLoc.isValid()) DiagLoc = Command->getCommandNameRange(Traits).getEnd(); Diag(DiagLoc, diag::warn_doc_block_command_empty_paragraph) - << Command->getAtCommand() + << Command->getCommandMarker() << Command->getCommandName(Traits) << Command->getSourceRange(); } @@ -465,7 +471,7 @@ void Sema::checkReturnsCommand(const BlockCommandComment *Command) { } Diag(Command->getLocation(), diag::warn_doc_returns_attached_to_a_void_function) - << Command->getAtCommand() + << Command->getCommandMarker() << Command->getCommandName(Traits) << DiagKind << Command->getSourceRange(); @@ -477,7 +483,7 @@ void Sema::checkReturnsCommand(const BlockCommandComment *Command) { Diag(Command->getLocation(), diag::warn_doc_returns_not_attached_to_a_function_decl) - << Command->getAtCommand() + << Command->getCommandMarker() << Command->getCommandName(Traits) << Command->getSourceRange(); } @@ -510,18 +516,18 @@ void Sema::checkBlockCommandDuplicate(const BlockCommandComment *Command) { StringRef CommandName = Command->getCommandName(Traits); StringRef PrevCommandName = PrevCommand->getCommandName(Traits); Diag(Command->getLocation(), diag::warn_doc_block_command_duplicate) - << Command->getAtCommand() + << Command->getCommandMarker() << CommandName << Command->getSourceRange(); if (CommandName == PrevCommandName) Diag(PrevCommand->getLocation(), diag::note_doc_block_command_previous) - << PrevCommand->getAtCommand() + << PrevCommand->getCommandMarker() << PrevCommandName << PrevCommand->getSourceRange(); else Diag(PrevCommand->getLocation(), diag::note_doc_block_command_previous_alias) - << PrevCommand->getAtCommand() + << PrevCommand->getCommandMarker() << PrevCommandName << CommandName; } |