[cfe-commits] r72386 - /cfe/trunk/lib/Lex/TokenLexer.cpp
Chris Lattner
sabre at nondot.org
Mon May 25 09:23:16 PDT 2009
Author: lattner
Date: Mon May 25 11:23:08 2009
New Revision: 72386
URL: http://llvm.org/viewvc/llvm-project?rev=72386&view=rev
Log:
improve comment, no functionality change.
Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=72386&r1=72385&r2=72386&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Mon May 25 11:23:08 2009
@@ -220,16 +220,21 @@
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;
}
More information about the cfe-commits
mailing list