Fix a stringizing bug that Neil noticed. We should preprocess this:

#define t(x) #x
t(a
c)

to "a c", not "ac".

llvm-svn: 40060
This commit is contained in:
Chris Lattner 2007-07-19 16:11:58 +00:00
parent b4acc033cf
commit 24dbee71ab
3 changed files with 11 additions and 3 deletions

View File

@ -153,7 +153,7 @@ static LexerToken StringifyArgument(const LexerToken *ArgToks,
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;

View File

@ -613,7 +613,8 @@ bool Preprocessor::HandleMacroExpandedIdentifier(LexerToken &Identifier,
// 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;
@ -731,7 +732,8 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName,
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) {

View File

@ -0,0 +1,6 @@
/* RUN: clang -E %s | grep 'a c'
*/
#define t(x) #x
t(a
c)