Comment parser and sema: remove useless return values


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161331 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/CommentParser.h b/include/clang/AST/CommentParser.h
index 53ea2fc..9539c9f 100644
--- a/include/clang/AST/CommentParser.h
+++ b/include/clang/AST/CommentParser.h
@@ -55,15 +55,13 @@
   /// A stack of additional lookahead tokens.
   SmallVector<Token, 8> MoreLATokens;
 
-  SourceLocation consumeToken() {
-    SourceLocation Loc = Tok.getLocation();
+  void consumeToken() {
     if (MoreLATokens.empty())
       L.lex(Tok);
     else {
       Tok = MoreLATokens.back();
       MoreLATokens.pop_back();
     }
-    return Loc;
   }
 
   void putBack(const Token &OldTok) {
@@ -90,19 +88,16 @@
          const SourceManager &SourceMgr, DiagnosticsEngine &Diags);
 
   /// Parse arguments for \\param command.
-  ParamCommandComment *parseParamCommandArgs(
-                                    ParamCommandComment *PC,
-                                    TextTokenRetokenizer &Retokenizer);
+  void parseParamCommandArgs(ParamCommandComment *PC,
+                             TextTokenRetokenizer &Retokenizer);
 
   /// Parse arguments for \\tparam command.
-  TParamCommandComment *parseTParamCommandArgs(
-                                    TParamCommandComment *TPC,
-                                    TextTokenRetokenizer &Retokenizer);
+  void parseTParamCommandArgs(TParamCommandComment *TPC,
+                              TextTokenRetokenizer &Retokenizer);
 
-  BlockCommandComment *parseBlockCommandArgs(
-                                    BlockCommandComment *BC,
-                                    TextTokenRetokenizer &Retokenizer,
-                                    unsigned NumArgs);
+  void parseBlockCommandArgs(BlockCommandComment *BC,
+                             TextTokenRetokenizer &Retokenizer,
+                             unsigned NumArgs);
 
   BlockCommandComment *parseBlockCommand();
   InlineCommandComment *parseInlineCommand();
diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h
index 114cfc5..bbb7c94 100644
--- a/include/clang/AST/CommentSema.h
+++ b/include/clang/AST/CommentSema.h
@@ -95,44 +95,40 @@
                                               SourceLocation LocEnd,
                                               StringRef Name);
 
-  BlockCommandComment *actOnBlockCommandArgs(
-                              BlockCommandComment *Command,
-                              ArrayRef<BlockCommandComment::Argument> Args);
+  void actOnBlockCommandArgs(BlockCommandComment *Command,
+                             ArrayRef<BlockCommandComment::Argument> Args);
 
-  BlockCommandComment *actOnBlockCommandFinish(BlockCommandComment *Command,
-                                               ParagraphComment *Paragraph);
+  void actOnBlockCommandFinish(BlockCommandComment *Command,
+                               ParagraphComment *Paragraph);
 
   ParamCommandComment *actOnParamCommandStart(SourceLocation LocBegin,
                                               SourceLocation LocEnd,
                                               StringRef Name);
 
-  ParamCommandComment *actOnParamCommandDirectionArg(
-                                            ParamCommandComment *Command,
-                                            SourceLocation ArgLocBegin,
-                                            SourceLocation ArgLocEnd,
-                                            StringRef Arg);
+  void actOnParamCommandDirectionArg(ParamCommandComment *Command,
+                                     SourceLocation ArgLocBegin,
+                                     SourceLocation ArgLocEnd,
+                                     StringRef Arg);
 
-  ParamCommandComment *actOnParamCommandParamNameArg(
-                                            ParamCommandComment *Command,
-                                            SourceLocation ArgLocBegin,
-                                            SourceLocation ArgLocEnd,
-                                            StringRef Arg);
+  void actOnParamCommandParamNameArg(ParamCommandComment *Command,
+                                     SourceLocation ArgLocBegin,
+                                     SourceLocation ArgLocEnd,
+                                     StringRef Arg);
 
-  ParamCommandComment *actOnParamCommandFinish(ParamCommandComment *Command,
-                                               ParagraphComment *Paragraph);
+  void actOnParamCommandFinish(ParamCommandComment *Command,
+                               ParagraphComment *Paragraph);
 
   TParamCommandComment *actOnTParamCommandStart(SourceLocation LocBegin,
                                                 SourceLocation LocEnd,
                                                 StringRef Name);
 
-  TParamCommandComment *actOnTParamCommandParamNameArg(
-                                            TParamCommandComment *Command,
-                                            SourceLocation ArgLocBegin,
-                                            SourceLocation ArgLocEnd,
-                                            StringRef Arg);
+  void actOnTParamCommandParamNameArg(TParamCommandComment *Command,
+                                      SourceLocation ArgLocBegin,
+                                      SourceLocation ArgLocEnd,
+                                      StringRef Arg);
 
-  TParamCommandComment *actOnTParamCommandFinish(TParamCommandComment *Command,
-                                                 ParagraphComment *Paragraph);
+  void actOnTParamCommandFinish(TParamCommandComment *Command,
+                                ParagraphComment *Paragraph);
 
   InlineCommandComment *actOnInlineCommand(SourceLocation CommandLocBegin,
                                            SourceLocation CommandLocEnd,
@@ -159,11 +155,10 @@
   VerbatimBlockLineComment *actOnVerbatimBlockLine(SourceLocation Loc,
                                                    StringRef Text);
 
-  VerbatimBlockComment *actOnVerbatimBlockFinish(
-                              VerbatimBlockComment *Block,
-                              SourceLocation CloseNameLocBegin,
-                              StringRef CloseName,
-                              ArrayRef<VerbatimBlockLineComment *> Lines);
+  void actOnVerbatimBlockFinish(VerbatimBlockComment *Block,
+                                SourceLocation CloseNameLocBegin,
+                                StringRef CloseName,
+                                ArrayRef<VerbatimBlockLineComment *> Lines);
 
   VerbatimLineComment *actOnVerbatimLine(SourceLocation LocBegin,
                                          StringRef Name,
@@ -173,11 +168,10 @@
   HTMLStartTagComment *actOnHTMLStartTagStart(SourceLocation LocBegin,
                                               StringRef TagName);
 
-  HTMLStartTagComment *actOnHTMLStartTagFinish(
-                              HTMLStartTagComment *Tag,
-                              ArrayRef<HTMLStartTagComment::Attribute> Attrs,
-                              SourceLocation GreaterLoc,
-                              bool IsSelfClosing);
+  void actOnHTMLStartTagFinish(HTMLStartTagComment *Tag,
+                               ArrayRef<HTMLStartTagComment::Attribute> Attrs,
+                               SourceLocation GreaterLoc,
+                               bool IsSelfClosing);
 
   HTMLEndTagComment *actOnHTMLEndTag(SourceLocation LocBegin,
                                      SourceLocation LocEnd,
diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp
index 63560e1..8d7716a 100644
--- a/lib/AST/CommentParser.cpp
+++ b/lib/AST/CommentParser.cpp
@@ -255,44 +255,37 @@
   consumeToken();
 }
 
-ParamCommandComment *Parser::parseParamCommandArgs(
-    ParamCommandComment *PC,
-    TextTokenRetokenizer &Retokenizer) {
+void Parser::parseParamCommandArgs(ParamCommandComment *PC,
+                                   TextTokenRetokenizer &Retokenizer) {
   Token Arg;
   // Check if argument looks like direction specification: [dir]
   // e.g., [in], [out], [in,out]
   if (Retokenizer.lexDelimitedSeq(Arg, '[', ']'))
-    PC = S.actOnParamCommandDirectionArg(PC,
-                                         Arg.getLocation(),
-                                         Arg.getEndLocation(),
-                                         Arg.getText());
+    S.actOnParamCommandDirectionArg(PC,
+                                    Arg.getLocation(),
+                                    Arg.getEndLocation(),
+                                    Arg.getText());
 
   if (Retokenizer.lexWord(Arg))
-    PC = S.actOnParamCommandParamNameArg(PC,
-                                         Arg.getLocation(),
-                                         Arg.getEndLocation(),
-                                         Arg.getText());
-
-  return PC;
+    S.actOnParamCommandParamNameArg(PC,
+                                    Arg.getLocation(),
+                                    Arg.getEndLocation(),
+                                    Arg.getText());
 }
 
-TParamCommandComment *Parser::parseTParamCommandArgs(
-                                  TParamCommandComment *TPC,
-                                  TextTokenRetokenizer &Retokenizer) {
+void Parser::parseTParamCommandArgs(TParamCommandComment *TPC,
+                                    TextTokenRetokenizer &Retokenizer) {
   Token Arg;
   if (Retokenizer.lexWord(Arg))
-    TPC = S.actOnTParamCommandParamNameArg(TPC,
-                                           Arg.getLocation(),
-                                           Arg.getEndLocation(),
-                                           Arg.getText());
-
-  return TPC;
+    S.actOnTParamCommandParamNameArg(TPC,
+                                     Arg.getLocation(),
+                                     Arg.getEndLocation(),
+                                     Arg.getText());
 }
 
-BlockCommandComment *Parser::parseBlockCommandArgs(
-    BlockCommandComment *BC,
-    TextTokenRetokenizer &Retokenizer,
-    unsigned NumArgs) {
+void Parser::parseBlockCommandArgs(BlockCommandComment *BC,
+                                   TextTokenRetokenizer &Retokenizer,
+                                   unsigned NumArgs) {
   typedef BlockCommandComment::Argument Argument;
   Argument *Args =
       new (Allocator.Allocate<Argument>(NumArgs)) Argument[NumArgs];
@@ -305,7 +298,7 @@
     ParsedArgs++;
   }
 
-  return S.actOnBlockCommandArgs(BC, llvm::makeArrayRef(Args, ParsedArgs));
+  S.actOnBlockCommandArgs(BC, llvm::makeArrayRef(Args, ParsedArgs));
 }
 
 BlockCommandComment *Parser::parseBlockCommand() {
@@ -340,7 +333,13 @@
     // command has an empty argument.
     ParagraphComment *Paragraph = S.actOnParagraphComment(
                                 ArrayRef<InlineContentComment *>());
-    return S.actOnBlockCommandFinish(IsParam ? PC : BC, Paragraph);
+    if (IsParam) {
+      S.actOnBlockCommandFinish(PC, Paragraph);
+      return PC;
+    } else {
+      S.actOnBlockCommandFinish(BC, Paragraph);
+      return BC;
+    }
   }
 
   if (IsParam || IsTParam || NumArgs > 0) {
@@ -349,11 +348,11 @@
     TextTokenRetokenizer Retokenizer(Allocator, *this);
 
     if (IsParam)
-      PC = parseParamCommandArgs(PC, Retokenizer);
+      parseParamCommandArgs(PC, Retokenizer);
     else if (IsTParam)
-      TPC = parseTParamCommandArgs(TPC, Retokenizer);
+      parseTParamCommandArgs(TPC, Retokenizer);
     else
-      BC = parseBlockCommandArgs(BC, Retokenizer, NumArgs);
+      parseBlockCommandArgs(BC, Retokenizer, NumArgs);
 
     Retokenizer.putBackLeftoverTokens();
   }
@@ -361,12 +360,17 @@
   BlockContentComment *Block = parseParagraphOrBlockCommand();
   // Since we have checked for a block command, we should have parsed a
   // paragraph.
-  if (IsParam)
-    return S.actOnParamCommandFinish(PC, cast<ParagraphComment>(Block));
-  else if (IsTParam)
-    return S.actOnTParamCommandFinish(TPC, cast<ParagraphComment>(Block));
-  else
-    return S.actOnBlockCommandFinish(BC, cast<ParagraphComment>(Block));
+  ParagraphComment *Paragraph = cast<ParagraphComment>(Block);
+  if (IsParam) {
+    S.actOnParamCommandFinish(PC, Paragraph);
+    return PC;
+  } else if (IsTParam) {
+    S.actOnTParamCommandFinish(TPC, Paragraph);
+    return TPC;
+  } else {
+    S.actOnBlockCommandFinish(BC, Paragraph);
+    return BC;
+  }
 }
 
 InlineCommandComment *Parser::parseInlineCommand() {
@@ -442,18 +446,18 @@
     }
 
     case tok::html_greater:
-      HST = S.actOnHTMLStartTagFinish(HST,
-                                      S.copyArray(llvm::makeArrayRef(Attrs)),
-                                      Tok.getLocation(),
-                                      /* IsSelfClosing = */ false);
+      S.actOnHTMLStartTagFinish(HST,
+                                S.copyArray(llvm::makeArrayRef(Attrs)),
+                                Tok.getLocation(),
+                                /* IsSelfClosing = */ false);
       consumeToken();
       return HST;
 
     case tok::html_slash_greater:
-      HST = S.actOnHTMLStartTagFinish(HST,
-                                      S.copyArray(llvm::makeArrayRef(Attrs)),
-                                      Tok.getLocation(),
-                                      /* IsSelfClosing = */ true);
+      S.actOnHTMLStartTagFinish(HST,
+                                S.copyArray(llvm::makeArrayRef(Attrs)),
+                                Tok.getLocation(),
+                                /* IsSelfClosing = */ true);
       consumeToken();
       return HST;
 
@@ -469,17 +473,18 @@
           Tok.is(tok::html_slash_greater))
         continue;
 
-      return S.actOnHTMLStartTagFinish(HST,
-                                       S.copyArray(llvm::makeArrayRef(Attrs)),
-                                       SourceLocation(),
-                                       /* IsSelfClosing = */ false);
+      S.actOnHTMLStartTagFinish(HST,
+                                S.copyArray(llvm::makeArrayRef(Attrs)),
+                                SourceLocation(),
+                                /* IsSelfClosing = */ false);
+      return HST;
 
     default:
       // Not a token from an HTML start tag.  Thus HTML tag prematurely ended.
-      HST = S.actOnHTMLStartTagFinish(HST,
-                                      S.copyArray(llvm::makeArrayRef(Attrs)),
-                                      SourceLocation(),
-                                      /* IsSelfClosing = */ false);
+      S.actOnHTMLStartTagFinish(HST,
+                                S.copyArray(llvm::makeArrayRef(Attrs)),
+                                SourceLocation(),
+                                /* IsSelfClosing = */ false);
       bool StartLineInvalid;
       const unsigned StartLine = SourceMgr.getPresumedLineNumber(
                                                   HST->getLocation(),
@@ -623,14 +628,14 @@
   }
 
   if (Tok.is(tok::verbatim_block_end)) {
-    VB = S.actOnVerbatimBlockFinish(VB, Tok.getLocation(),
-                                    Tok.getVerbatimBlockName(),
-                                    S.copyArray(llvm::makeArrayRef(Lines)));
+    S.actOnVerbatimBlockFinish(VB, Tok.getLocation(),
+                               Tok.getVerbatimBlockName(),
+                               S.copyArray(llvm::makeArrayRef(Lines)));
     consumeToken();
   } else {
     // Unterminated \\verbatim block
-    VB = S.actOnVerbatimBlockFinish(VB, SourceLocation(), "",
-                                    S.copyArray(llvm::makeArrayRef(Lines)));
+    S.actOnVerbatimBlockFinish(VB, SourceLocation(), "",
+                               S.copyArray(llvm::makeArrayRef(Lines)));
   }
 
   return VB;
diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp
index 57f8fda..42dd320 100644
--- a/lib/AST/CommentSema.cpp
+++ b/lib/AST/CommentSema.cpp
@@ -43,21 +43,17 @@
   return new (Allocator) BlockCommandComment(LocBegin, LocEnd, Name);
 }
 
-BlockCommandComment *Sema::actOnBlockCommandArgs(
-                              BlockCommandComment *Command,
-                              ArrayRef<BlockCommandComment::Argument> Args) {
+void Sema::actOnBlockCommandArgs(BlockCommandComment *Command,
+                                 ArrayRef<BlockCommandComment::Argument> Args) {
   Command->setArgs(Args);
-  return Command;
 }
 
-BlockCommandComment *Sema::actOnBlockCommandFinish(
-                              BlockCommandComment *Command,
-                              ParagraphComment *Paragraph) {
+void Sema::actOnBlockCommandFinish(BlockCommandComment *Command,
+                                   ParagraphComment *Paragraph) {
   Command->setParagraph(Paragraph);
   checkBlockCommandEmptyParagraph(Command);
   checkBlockCommandDuplicate(Command);
   checkReturnsCommand(Command);
-  return Command;
 }
 
 ParamCommandComment *Sema::actOnParamCommandStart(SourceLocation LocBegin,
@@ -74,11 +70,10 @@
   return Command;
 }
 
-ParamCommandComment *Sema::actOnParamCommandDirectionArg(
-                                                ParamCommandComment *Command,
-                                                SourceLocation ArgLocBegin,
-                                                SourceLocation ArgLocEnd,
-                                                StringRef Arg) {
+void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,
+                                         SourceLocation ArgLocBegin,
+                                         SourceLocation ArgLocEnd,
+                                         StringRef Arg) {
   ParamCommandComment::PassDirection Direction;
   std::string ArgLower = Arg.lower();
   // TODO: optimize: lower Name first (need an API in SmallString for that),
@@ -128,14 +123,12 @@
         << ArgRange;
   }
   Command->setDirection(Direction, /* Explicit = */ true);
-  return Command;
 }
 
-ParamCommandComment *Sema::actOnParamCommandParamNameArg(
-                                                ParamCommandComment *Command,
-                                                SourceLocation ArgLocBegin,
-                                                SourceLocation ArgLocEnd,
-                                                StringRef Arg) {
+void Sema::actOnParamCommandParamNameArg(ParamCommandComment *Command,
+                                         SourceLocation ArgLocBegin,
+                                         SourceLocation ArgLocEnd,
+                                         StringRef Arg) {
   // Parser will not feed us more arguments than needed.
   assert(Command->getNumArgs() == 0);
 
@@ -151,7 +144,7 @@
 
   if (!isFunctionDecl()) {
     // We already warned that this \\param is not attached to a function decl.
-    return Command;
+    return;
   }
 
   ArrayRef<const ParmVarDecl *> ParamVars = getParamVars();
@@ -169,7 +162,7 @@
         << PrevCommand->getParamNameRange();
     }
     ParamVarDocs[ResolvedParamIndex] = Command;
-    return Command;
+    return;
   }
 
   SourceRange ArgRange(ArgLocBegin, ArgLocEnd);
@@ -178,7 +171,7 @@
 
   // No parameters -- can't suggest a correction.
   if (ParamVars.size() == 0)
-    return Command;
+    return;
 
   unsigned CorrectedParamIndex = ParamCommandComment::InvalidParamIndex;
   if (ParamVars.size() == 1) {
@@ -197,14 +190,13 @@
         << FixItHint::CreateReplacement(ArgRange, CorrectedII->getName());
   }
 
-  return Command;
+  return;
 }
 
-ParamCommandComment *Sema::actOnParamCommandFinish(ParamCommandComment *Command,
-                                                   ParagraphComment *Paragraph) {
+void Sema::actOnParamCommandFinish(ParamCommandComment *Command,
+                                   ParagraphComment *Paragraph) {
   Command->setParagraph(Paragraph);
   checkBlockCommandEmptyParagraph(Command);
-  return Command;
 }
 
 TParamCommandComment *Sema::actOnTParamCommandStart(SourceLocation LocBegin,
@@ -221,11 +213,10 @@
   return Command;
 }
 
-TParamCommandComment *Sema::actOnTParamCommandParamNameArg(
-                                            TParamCommandComment *Command,
-                                            SourceLocation ArgLocBegin,
-                                            SourceLocation ArgLocEnd,
-                                            StringRef Arg) {
+void Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command,
+                                          SourceLocation ArgLocBegin,
+                                          SourceLocation ArgLocEnd,
+                                          StringRef Arg) {
   // Parser will not feed us more arguments than needed.
   assert(Command->getNumArgs() == 0);
 
@@ -237,7 +228,7 @@
 
   if (!isTemplateDecl()) {
     // We already warned that this \\tparam is not attached to a template decl.
-    return Command;
+    return;
   }
 
   const TemplateParameterList *TemplateParameters =
@@ -256,7 +247,7 @@
         << PrevCommand->getParamNameRange();
     }
     TemplateParameterDocs[Arg] = Command;
-    return Command;
+    return;
   }
 
   SourceRange ArgRange(ArgLocBegin, ArgLocEnd);
@@ -264,7 +255,7 @@
     << Arg << ArgRange;
 
   if (!TemplateParameters || TemplateParameters->size() == 0)
-    return Command;
+    return;
 
   StringRef CorrectedName;
   if (TemplateParameters->size() == 1) {
@@ -282,15 +273,13 @@
       << FixItHint::CreateReplacement(ArgRange, CorrectedName);
   }
 
-  return Command;
+  return;
 }
 
-TParamCommandComment *Sema::actOnTParamCommandFinish(
-                                            TParamCommandComment *Command,
-                                            ParagraphComment *Paragraph) {
+void Sema::actOnTParamCommandFinish(TParamCommandComment *Command,
+                                    ParagraphComment *Paragraph) {
   Command->setParagraph(Paragraph);
   checkBlockCommandEmptyParagraph(Command);
-  return Command;
 }
 
 InlineCommandComment *Sema::actOnInlineCommand(SourceLocation CommandLocBegin,
@@ -353,14 +342,13 @@
   return new (Allocator) VerbatimBlockLineComment(Loc, Text);
 }
 
-VerbatimBlockComment *Sema::actOnVerbatimBlockFinish(
+void Sema::actOnVerbatimBlockFinish(
                             VerbatimBlockComment *Block,
                             SourceLocation CloseNameLocBegin,
                             StringRef CloseName,
                             ArrayRef<VerbatimBlockLineComment *> Lines) {
   Block->setCloseName(CloseName, CloseNameLocBegin);
   Block->setLines(Lines);
-  return Block;
 }
 
 VerbatimLineComment *Sema::actOnVerbatimLine(SourceLocation LocBegin,
@@ -380,7 +368,7 @@
   return new (Allocator) HTMLStartTagComment(LocBegin, TagName);
 }
 
-HTMLStartTagComment *Sema::actOnHTMLStartTagFinish(
+void Sema::actOnHTMLStartTagFinish(
                               HTMLStartTagComment *Tag,
                               ArrayRef<HTMLStartTagComment::Attribute> Attrs,
                               SourceLocation GreaterLoc,
@@ -391,7 +379,6 @@
     Tag->setSelfClosing();
   else if (!isHTMLEndTagForbidden(Tag->getTagName()))
     HTMLOpenTags.push_back(Tag);
-  return Tag;
 }
 
 HTMLEndTagComment *Sema::actOnHTMLEndTag(SourceLocation LocBegin,