Comment parsing: simplify code. As a side effect, this also silences GCC's
-Wunitnitialized warning.
Patch by Rui Ueyama.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179794 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/CommentParser.cpp b/lib/AST/CommentParser.cpp
index 09912c6..1224db6 100644
--- a/lib/AST/CommentParser.cpp
+++ b/lib/AST/CommentParser.cpp
@@ -302,22 +302,18 @@
BlockCommandComment *Parser::parseBlockCommand() {
assert(Tok.is(tok::backslash_command) || Tok.is(tok::at_command));
- ParamCommandComment *PC;
- TParamCommandComment *TPC;
- BlockCommandComment *BC;
- bool IsParam = false;
- bool IsTParam = false;
+ ParamCommandComment *PC = 0;
+ TParamCommandComment *TPC = 0;
+ BlockCommandComment *BC = 0;
const CommandInfo *Info = Traits.getCommandInfo(Tok.getCommandID());
CommandMarkerKind CommandMarker =
Tok.is(tok::backslash_command) ? CMK_Backslash : CMK_At;
if (Info->IsParamCommand) {
- IsParam = true;
PC = S.actOnParamCommandStart(Tok.getLocation(),
Tok.getEndLocation(),
Tok.getCommandID(),
CommandMarker);
} else if (Info->IsTParamCommand) {
- IsTParam = true;
TPC = S.actOnTParamCommandStart(Tok.getLocation(),
Tok.getEndLocation(),
Tok.getCommandID(),
@@ -335,10 +331,10 @@
// command has an empty argument.
ParagraphComment *Paragraph = S.actOnParagraphComment(
ArrayRef<InlineContentComment *>());
- if (IsParam) {
+ if (PC) {
S.actOnParamCommandFinish(PC, Paragraph);
return PC;
- } else if (IsTParam) {
+ } else if (TPC) {
S.actOnTParamCommandFinish(TPC, Paragraph);
return TPC;
} else {
@@ -347,14 +343,14 @@
}
}
- if (IsParam || IsTParam || Info->NumArgs > 0) {
+ if (PC || TPC || Info->NumArgs > 0) {
// In order to parse command arguments we need to retokenize a few
// following text tokens.
TextTokenRetokenizer Retokenizer(Allocator, *this);
- if (IsParam)
+ if (PC)
parseParamCommandArgs(PC, Retokenizer);
- else if (IsTParam)
+ else if (TPC)
parseTParamCommandArgs(TPC, Retokenizer);
else
parseBlockCommandArgs(BC, Retokenizer, Info->NumArgs);
@@ -384,10 +380,10 @@
Paragraph = cast<ParagraphComment>(Block);
}
- if (IsParam) {
+ if (PC) {
S.actOnParamCommandFinish(PC, Paragraph);
return PC;
- } else if (IsTParam) {
+ } else if (TPC) {
S.actOnTParamCommandFinish(TPC, Paragraph);
return TPC;
} else {