@@ -65,7 +65,9 @@ class Expansion {
65
65
}
66
66
Unexpanded[ID] = std::move (UnexpandedLine);
67
67
68
- auto Expanded = uneof (Macros.expand (ID, Args));
68
+ auto Expanded = Macros.expand (ID, Args);
69
+ if (Expanded.size () > 1 )
70
+ Expanded = uneof (Expanded);
69
71
Tokens.append (Expanded.begin (), Expanded.end ());
70
72
71
73
TokenList UnexpandedTokens;
@@ -217,6 +219,31 @@ TEST_F(MacroCallReconstructorTest, Identifier) {
217
219
EXPECT_THAT (std::move (Unexp).takeResult (), matchesLine (line (U.consume (" X" ))));
218
220
}
219
221
222
+ TEST_F (MacroCallReconstructorTest, EmptyDefinition) {
223
+ auto Macros = createExpander ({" X" });
224
+ Expansion Exp (Lex, *Macros);
225
+ TokenList Call = Exp.expand (" X" );
226
+
227
+ MacroCallReconstructor Unexp (0 , Exp.getUnexpanded ());
228
+ Unexp.addLine (line (Exp.getTokens ()));
229
+ EXPECT_TRUE (Unexp.finished ());
230
+ Matcher U (Call, Lex);
231
+ EXPECT_THAT (std::move (Unexp).takeResult (), matchesLine (line (U.consume (" X" ))));
232
+ }
233
+
234
+ TEST_F (MacroCallReconstructorTest, EmptyExpansion) {
235
+ auto Macros = createExpander ({" A(x)=x" });
236
+ Expansion Exp (Lex, *Macros);
237
+ TokenList Call = Exp.expand (" A" , {" " });
238
+
239
+ MacroCallReconstructor Unexp (0 , Exp.getUnexpanded ());
240
+ Unexp.addLine (line (Exp.getTokens ()));
241
+ EXPECT_TRUE (Unexp.finished ());
242
+ Matcher U (Call, Lex);
243
+ EXPECT_THAT (std::move (Unexp).takeResult (),
244
+ matchesLine (line (U.consume (" A()" ))));
245
+ }
246
+
220
247
TEST_F (MacroCallReconstructorTest, NestedLineWithinCall) {
221
248
auto Macros = createExpander ({" C(a)=class X { a; };" });
222
249
Expansion Exp (Lex, *Macros);
0 commit comments