[cfe-commits] r38761 - /cfe/cfe/trunk/Lex/MacroExpander.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:24:24 PDT 2007
Author: sabre
Date: Wed Jul 11 11:24:24 2007
New Revision: 38761
URL: http://llvm.org/viewvc/llvm-project?rev=38761&view=rev
Log:
Implement pasting of arguments that expand to no tokens. This handles the
C99 "placemarker" concept.
Modified:
cfe/cfe/trunk/Lex/MacroExpander.cpp
Modified: cfe/cfe/trunk/Lex/MacroExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/MacroExpander.cpp?rev=38761&r1=38760&r2=38761&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/MacroExpander.cpp (original)
+++ cfe/cfe/trunk/Lex/MacroExpander.cpp Wed Jul 11 11:24:24 2007
@@ -377,9 +377,23 @@
}
// FIXME: Handle comma swallowing GNU extension.
- // FIXME: Handle 'placemarker' stuff.
- assert(0 && "FIXME: handle empty arguments!");
- //ResultToks.push_back(CurTok);
+
+ // If an empty argument is on the LHS or RHS of a paste, the standard (C99
+ // 6.10.3.3p2,3) calls for a bunch of placemarker stuff to occur. We
+ // implement this by eating ## operators when a LHS or RHS expands to
+ // empty.
+ if (PasteAfter) {
+ // Discard the argument token and skip (don't copy to the expansion
+ // buffer) the paste operator after it.
+ ++i;
+ continue;
+ }
+
+ // If this is on the RHS of a paste operator, we've already copied the
+ // paste operator to the ResultToks list. Remove it.
+ assert(PasteBefore && ResultToks.back().getKind() == tok::hashhash);
+ ResultToks.pop_back();
+ continue;
}
}
More information about the cfe-commits
mailing list