@@ -162,19 +162,13 @@ UnwrappedLineParser::UnwrappedLineParser(
162162 LangOpts(getFormattingLangOpts(Style)), Keywords(Keywords),
163163 CommentPragmasRegex(Style.CommentPragmas), Tokens(nullptr ),
164164 Callback(Callback), AllTokens(Tokens), PPBranchLevel(-1 ),
165- IncludeGuard(Style.IndentPPDirectives == FormatStyle::PPDIS_None ||
166- Style.IndentPPDirectives == FormatStyle::PPDIS_Leave
167- ? IG_Rejected
168- : IG_Inited),
165+ IncludeGuard(getIncludeGuardState(Style.IndentPPDirectives)),
169166 IncludeGuardToken(nullptr ), FirstStartColumn(FirstStartColumn),
170167 Macros(Style.Macros, SourceMgr, Style, Allocator, IdentTable) {}
171168
172169void UnwrappedLineParser::reset () {
173170 PPBranchLevel = -1 ;
174- IncludeGuard = Style.IndentPPDirectives == FormatStyle::PPDIS_None ||
175- Style.IndentPPDirectives == FormatStyle::PPDIS_Leave
176- ? IG_Rejected
177- : IG_Inited;
171+ IncludeGuard = getIncludeGuardState (Style.IndentPPDirectives );
178172 IncludeGuardToken = nullptr ;
179173 Line.reset (new UnwrappedLine);
180174 CommentsBeforeNextToken.clear ();
@@ -1142,8 +1136,7 @@ void UnwrappedLineParser::parsePPEndIf() {
11421136 // If the #endif of a potential include guard is the last thing in the file,
11431137 // then we found an include guard.
11441138 if (IncludeGuard == IG_Defined && PPBranchLevel == -1 && Tokens->isEOF () &&
1145- Style.IndentPPDirectives != FormatStyle::PPDIS_None &&
1146- Style.IndentPPDirectives != FormatStyle::PPDIS_Leave) {
1139+ getIncludeGuardState (Style.IndentPPDirectives ) == IG_Inited) {
11471140 IncludeGuard = IG_Found;
11481141 }
11491142}
0 commit comments