forked from OSchip/llvm-project
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:
parent
b4acc033cf
commit
24dbee71ab
|
@ -153,7 +153,7 @@ static LexerToken StringifyArgument(const LexerToken *ArgToks,
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
for (; ArgToks->getKind() != tok::eof; ++ArgToks) {
|
for (; ArgToks->getKind() != tok::eof; ++ArgToks) {
|
||||||
const LexerToken &Tok = *ArgToks;
|
const LexerToken &Tok = *ArgToks;
|
||||||
if (!isFirst && Tok.hasLeadingSpace())
|
if (!isFirst && (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()))
|
||||||
Result += ' ';
|
Result += ' ';
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,8 @@ bool Preprocessor::HandleMacroExpandedIdentifier(LexerToken &Identifier,
|
||||||
// If this is a function-like macro, read the arguments.
|
// If this is a function-like macro, read the arguments.
|
||||||
if (MI->isFunctionLike()) {
|
if (MI->isFunctionLike()) {
|
||||||
// C99 6.10.3p10: If the preprocessing token immediately after the the macro
|
// 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())
|
if (!isNextPPTokenLParen())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -731,7 +732,8 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(LexerToken &MacroName,
|
||||||
|
|
||||||
unsigned NumActuals = 0;
|
unsigned NumActuals = 0;
|
||||||
while (Tok.getKind() == tok::comma) {
|
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;
|
unsigned NumParens = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
/* RUN: clang -E %s | grep 'a c'
|
||||||
|
*/
|
||||||
|
#define t(x) #x
|
||||||
|
t(a
|
||||||
|
c)
|
||||||
|
|
Loading…
Reference in New Issue