/// 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) {
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);
-
- BlockCommandComment *parseBlockCommandArgs(
- BlockCommandComment *BC,
- TextTokenRetokenizer &Retokenizer,
- unsigned NumArgs);
+ void parseTParamCommandArgs(TParamCommandComment *TPC,
+ TextTokenRetokenizer &Retokenizer);
+
+ void parseBlockCommandArgs(BlockCommandComment *BC,
+ TextTokenRetokenizer &Retokenizer,
+ unsigned NumArgs);
BlockCommandComment *parseBlockCommand();
InlineCommandComment *parseInlineCommand();
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,
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,
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,
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];
ParsedArgs++;
}
- return S.actOnBlockCommandArgs(BC, llvm::makeArrayRef(Args, ParsedArgs));
+ S.actOnBlockCommandArgs(BC, llvm::makeArrayRef(Args, ParsedArgs));
}
BlockCommandComment *Parser::parseBlockCommand() {
// 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) {
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();
}
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() {
}
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;
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(),
}
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;
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,
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),
<< 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);
if (!isFunctionDecl()) {
// We already warned that this \\param is not attached to a function decl.
- return Command;
+ return;
}
ArrayRef<const ParmVarDecl *> ParamVars = getParamVars();
<< PrevCommand->getParamNameRange();
}
ParamVarDocs[ResolvedParamIndex] = Command;
- return Command;
+ return;
}
SourceRange ArgRange(ArgLocBegin, ArgLocEnd);
// No parameters -- can't suggest a correction.
if (ParamVars.size() == 0)
- return Command;
+ return;
unsigned CorrectedParamIndex = ParamCommandComment::InvalidParamIndex;
if (ParamVars.size() == 1) {
<< 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,
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);
if (!isTemplateDecl()) {
// We already warned that this \\tparam is not attached to a template decl.
- return Command;
+ return;
}
const TemplateParameterList *TemplateParameters =
<< PrevCommand->getParamNameRange();
}
TemplateParameterDocs[Arg] = Command;
- return Command;
+ return;
}
SourceRange ArgRange(ArgLocBegin, ArgLocEnd);
<< Arg << ArgRange;
if (!TemplateParameters || TemplateParameters->size() == 0)
- return Command;
+ return;
StringRef CorrectedName;
if (TemplateParameters->size() == 1) {
<< 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,
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,
return new (Allocator) HTMLStartTagComment(LocBegin, TagName);
}
-HTMLStartTagComment *Sema::actOnHTMLStartTagFinish(
+void Sema::actOnHTMLStartTagFinish(
HTMLStartTagComment *Tag,
ArrayRef<HTMLStartTagComment::Attribute> Attrs,
SourceLocation GreaterLoc,
Tag->setSelfClosing();
else if (!isHTMLEndTagForbidden(Tag->getTagName()))
HTMLOpenTags.push_back(Tag);
- return Tag;
}
HTMLEndTagComment *Sema::actOnHTMLEndTag(SourceLocation LocBegin,