diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-25 16:23:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-25 16:23:08 +0000 |
commit | 442a661a2b44e78e3c66e35bf842c3dc119dfe92 (patch) | |
tree | 9ead201b619a9406c126b540daf9f29a4173682e /lib/Lex/TokenLexer.cpp | |
parent | c5b7e8d1c0ebbdbb3e6c81616498b9acc612e157 (diff) |
improve comment, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72386 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r-- | lib/Lex/TokenLexer.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp index 65d083dffd..5675f3f7c0 100644 --- a/lib/Lex/TokenLexer.cpp +++ b/lib/Lex/TokenLexer.cpp @@ -220,16 +220,21 @@ void TokenLexer::ExpandFunctionArguments() { ResultToks.append(ArgToks, ArgToks+NumToks); - // If the next token was supposed to get leading whitespace, ensure it has - // it now. - if (CurTok.hasLeadingSpace() || NextTokGetsSpace) { - // Exception: the RHS of a paste doesn't get whitespace. This allows - // constructs like conacatenating a period and an identifer to work - // correctly in assembler-with-cpp. - if (!PasteBefore) - ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace); - NextTokGetsSpace = false; - } + // If this token (the macro argument) was supposed to get leading + // whitespace, transfer this information onto the first token of the + // expansion. + // + // Do not do this if the paste operator occurs before the macro argument, + // as in "A ## MACROARG". In valid code, the first token will get + // smooshed onto the preceding one anyway (forming AMACROARG). In + // assembler-with-cpp mode, invalid pastes are allowed through: in this + // case, we do not want the extra whitespace to be added. For example, + // we want ". ## foo" -> ".foo" not ". foo". + if ((CurTok.hasLeadingSpace() || NextTokGetsSpace) && + !PasteBefore) + ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace); + + NextTokGetsSpace = false; continue; } |