diff options
author | Owen Pan <owenpiano@gmail.com> | 2025-01-04 16:22:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-04 16:22:54 -0800 |
commit | 44b83e81b5a48d543bf718907f00a21179ec03a4 (patch) | |
tree | 3e48eabff52616ea3ce37151d3eeb40dc79aa0e7 /clang/lib/Format/UnwrappedLineParser.cpp | |
parent | 04610b901f41c4abec169b9a38f1b0a2fde976c1 (diff) | |
download | llvm-44b83e81b5a48d543bf718907f00a21179ec03a4.zip llvm-44b83e81b5a48d543bf718907f00a21179ec03a4.tar.gz llvm-44b83e81b5a48d543bf718907f00a21179ec03a4.tar.bz2 |
[clang-format] Add TT_AfterPPDirective for better annotation (#121622)
For now, we only need to annotate the token after #error or #warning.
Fixes #117706.
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 5375eef..46fd566 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1030,6 +1030,12 @@ void UnwrappedLineParser::parsePPDirective() { case tok::pp_pragma: parsePPPragma(); break; + case tok::pp_error: + case tok::pp_warning: + nextToken(); + if (!eof() && Style.isCpp()) + FormatTok->setFinalizedType(TT_AfterPPDirective); + [[fallthrough]]; default: parsePPUnknown(); break; @@ -1209,9 +1215,8 @@ void UnwrappedLineParser::parsePPPragma() { } void UnwrappedLineParser::parsePPUnknown() { - do { + while (!eof()) nextToken(); - } while (!eof()); if (Style.IndentPPDirectives != FormatStyle::PPDIS_None) Line->Level += PPBranchLevel + 1; addUnwrappedLine(); |