[clang] [clang-format][NFC] Followup cleanup after #199459 (PR #202104)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 6 23:03:51 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: owenca (owenca)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/202104.diff
1 Files Affected:
- (modified) clang/lib/Format/TokenAnnotator.cpp (+5-8)
``````````diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 22b41fb337cda..c47a512454476 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2701,6 +2701,7 @@ class AnnotatingParser {
// int a or auto a.
if (PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto) &&
+ !PreviousNotConst->endsSequence(Keywords.kw_import, tok::kw_export) &&
PreviousNotConst->isNot(TT_StatementAttributeLikeMacro)) {
return true;
}
@@ -5227,23 +5228,19 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
(!BeforeLeft || BeforeLeft->is(tok::kw_export))) {
return true;
}
- // Space between `module :` and `import :`.
- if (Left.isOneOf(Keywords.kw_module, Keywords.kw_import) &&
- Right.is(TT_ModulePartitionColon)) {
+ // Space between `import :`.
+ if (Left.is(Keywords.kw_import) && Right.is(TT_ModulePartitionColon))
return true;
- }
if (Right.is(TT_AfterPPDirective))
return true;
- // No space between import foo:bar but keep a space between import :bar;
+ // No space between `module foo:bar`.
if (Left.is(tok::identifier) && Right.is(TT_ModulePartitionColon))
return false;
// No space between :bar;
- if (Left.is(TT_ModulePartitionColon) &&
- Right.isOneOf(tok::identifier, tok::kw_private)) {
+ if (Left.is(TT_ModulePartitionColon) && Right.is(tok::identifier))
return false;
- }
if (Left.is(tok::ellipsis) && Right.is(tok::identifier) &&
Line.First->is(Keywords.kw_import)) {
return false;
``````````
</details>
https://github.com/llvm/llvm-project/pull/202104
More information about the cfe-commits
mailing list