summaryrefslogtreecommitdiffstats
path: root/clang/Lex/MacroExpander.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-07-28 05:07:04 +0000
committerChris Lattner <sabre@nondot.org>2006-07-28 05:07:04 +0000
commita9dc597fcae5f50937c8c0349379a93701763545 (patch)
treed0a3ed90fdcedad7ba4eef6f4abe2a9c32e743de /clang/Lex/MacroExpander.cpp
parent6e4bf523e61fd1aecc0cbd825a08eb821b858826 (diff)
downloadbcm5719-llvm-a9dc597fcae5f50937c8c0349379a93701763545.tar.gz
bcm5719-llvm-a9dc597fcae5f50937c8c0349379a93701763545.zip
Implement pasting of arguments that expand to no tokens. This handles the
C99 "placemarker" concept. llvm-svn: 38761
Diffstat (limited to 'clang/Lex/MacroExpander.cpp')
-rw-r--r--clang/Lex/MacroExpander.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/clang/Lex/MacroExpander.cpp b/clang/Lex/MacroExpander.cpp
index 3a2f9da90f3..dd99ae3f941 100644
--- a/clang/Lex/MacroExpander.cpp
+++ b/clang/Lex/MacroExpander.cpp
@@ -377,9 +377,23 @@ void MacroExpander::ExpandFunctionArguments() {
}
// 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;
}
}
OpenPOWER on IntegriCloud