bool isFirst = true;
for (; ArgToks->getKind() != tok::eof; ++ArgToks) {
const LexerToken &Tok = *ArgToks;
- if (!isFirst && Tok.hasLeadingSpace())
+ if (!isFirst && (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()))
Result += ' ';
isFirst = false;
// If this is a function-like macro, read the arguments.
if (MI->isFunctionLike()) {
// C99 6.10.3p10: If the preprocessing token immediately after the the macro
- // name isn't a '(', this macro should not be expanded.
+ // name isn't a '(', this macro should not be expanded. Otherwise, consume
+ // it.
if (!isNextPPTokenLParen())
return true;
unsigned NumActuals = 0;
while (Tok.getKind() == tok::comma) {
- // C99 6.10.3p11: Keep track of the number of l_parens we have seen.
+ // C99 6.10.3p11: Keep track of the number of l_parens we have seen. Note
+ // that we already consumed the first one.
unsigned NumParens = 0;
while (1) {