aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorGedare Bloom <gedare@rtems.org>2025-09-14 14:47:06 -0600
committerGitHub <noreply@github.com>2025-09-14 13:47:06 -0700
commit7dd2f1cc10902e632c0c78c75a30432a53eb59dc (patch)
treef0fd3b24672aac4bce31b131b445e41e50d5cd0f /clang/lib/Format/UnwrappedLineParser.cpp
parent43384913b636854b92c7de9e326f879a1993f445 (diff)
downloadllvm-7dd2f1cc10902e632c0c78c75a30432a53eb59dc.zip
llvm-7dd2f1cc10902e632c0c78c75a30432a53eb59dc.tar.gz
llvm-7dd2f1cc10902e632c0c78c75a30432a53eb59dc.tar.bz2
[clang-format] Add IndentPPDirectives Leave option (#139750)
Allow an option to leave preprocessor directive indenting as-is. This simplifies handling mixed styles of CPP directive indentation. Fixes #38511
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index f4bbfcf..2c9766c9 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -162,17 +162,13 @@ UnwrappedLineParser::UnwrappedLineParser(
LangOpts(getFormattingLangOpts(Style)), Keywords(Keywords),
CommentPragmasRegex(Style.CommentPragmas), Tokens(nullptr),
Callback(Callback), AllTokens(Tokens), PPBranchLevel(-1),
- IncludeGuard(Style.IndentPPDirectives == FormatStyle::PPDIS_None
- ? IG_Rejected
- : IG_Inited),
+ IncludeGuard(getIncludeGuardState(Style.IndentPPDirectives)),
IncludeGuardToken(nullptr), FirstStartColumn(FirstStartColumn),
Macros(Style.Macros, SourceMgr, Style, Allocator, IdentTable) {}
void UnwrappedLineParser::reset() {
PPBranchLevel = -1;
- IncludeGuard = Style.IndentPPDirectives == FormatStyle::PPDIS_None
- ? IG_Rejected
- : IG_Inited;
+ IncludeGuard = getIncludeGuardState(Style.IndentPPDirectives);
IncludeGuardToken = nullptr;
Line.reset(new UnwrappedLine);
CommentsBeforeNextToken.clear();
@@ -1140,7 +1136,7 @@ void UnwrappedLineParser::parsePPEndIf() {
// If the #endif of a potential include guard is the last thing in the file,
// then we found an include guard.
if (IncludeGuard == IG_Defined && PPBranchLevel == -1 && Tokens->isEOF() &&
- Style.IndentPPDirectives != FormatStyle::PPDIS_None) {
+ getIncludeGuardState(Style.IndentPPDirectives) == IG_Inited) {
IncludeGuard = IG_Found;
}
}