Skip to content

Commit 02a997c

Browse files
authored
[clang-format] Handle import when used as template function name (#169279)
Fixes #149960
1 parent f5cae7b commit 02a997c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5033,8 +5033,11 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
50335033
return true;
50345034
// Space between import <iostream>.
50355035
// or import .....;
5036-
if (Left.is(Keywords.kw_import) && Right.isOneOf(tok::less, tok::ellipsis))
5036+
if (Left.is(Keywords.kw_import) &&
5037+
Right.isOneOf(tok::less, tok::ellipsis) &&
5038+
(!BeforeLeft || BeforeLeft->is(tok::kw_export))) {
50375039
return true;
5040+
}
50385041
// Space between `module :` and `import :`.
50395042
if (Left.isOneOf(Keywords.kw_module, Keywords.kw_import) &&
50405043
Right.is(TT_ModulePartitionColon)) {

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27328,6 +27328,7 @@ TEST_F(FormatTest, Cpp20ModulesSupport) {
2732827328
verifyFormat("export", Style);
2732927329

2733027330
verifyFormat("import /* not keyword */ = val ? 2 : 1;");
27331+
verifyFormat("_world->import<engine_module>();");
2733127332
}
2733227333

2733327334
TEST_F(FormatTest, CoroutineForCoawait) {

0 commit comments

Comments
 (0)