Skip to content

Commit e46f0e0

Browse files
committed
[clang-format] Fix about Tokens in MacroCallReconstructorTest
When the macro expansion is empty, the tok::eof Token should be preserved. The reason is we have marked the start point and end point on this token in MacroExpander::expand.
1 parent 37a5b1b commit e46f0e0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/unittests/Format/MacroCallReconstructorTest.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class Expansion {
6565
}
6666
Unexpanded[ID] = std::move(UnexpandedLine);
6767

68-
auto Expanded = uneof(Macros.expand(ID, Args));
68+
auto Expanded = Macros.expand(ID, Args);
69+
if (Expanded.size() > 1)
70+
Expanded = uneof(Expanded);
6971
Tokens.append(Expanded.begin(), Expanded.end());
7072

7173
TokenList UnexpandedTokens;
@@ -218,7 +220,7 @@ TEST_F(MacroCallReconstructorTest, Identifier) {
218220
}
219221

220222
TEST_F(MacroCallReconstructorTest, EmptyExpansion) {
221-
auto Macros = createExpander({"A(x)=y"});
223+
auto Macros = createExpander({"A(x)=x"});
222224
Expansion Exp(Lex, *Macros);
223225
TokenList Call = Exp.expand("A", {""});
224226

0 commit comments

Comments
 (0)