diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-04 06:46:18 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-05-04 06:46:18 +0000 |
commit | cb1beee76f520857b985db2af6117ad97aa45c4e (patch) | |
tree | 3dd01f89ff7cd37c28716d6510143561ece28839 /clang/lib/Lex/MacroArgs.cpp | |
parent | 5ddd564e190f10b0b001c203fbfbfd521a22c0c4 (diff) | |
download | bcm5719-llvm-cb1beee76f520857b985db2af6117ad97aa45c4e.tar.gz bcm5719-llvm-cb1beee76f520857b985db2af6117ad97aa45c4e.zip |
[c++20] Implement tweaked __VA_OPT__ rules from P1042R1:
* __VA_OPT__ is expanded if the *expanded* __VA_ARGS__ is non-empty,
not if the original argument contained no tokens.
* Placemarkers at the start and end of __VA_OPT__ are retained just
long enough to paste them with adjacent ## operators. We never paste
"across" a discarded placemarker.
llvm-svn: 359964
Diffstat (limited to 'clang/lib/Lex/MacroArgs.cpp')
-rw-r--r-- | clang/lib/Lex/MacroArgs.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/clang/lib/Lex/MacroArgs.cpp b/clang/lib/Lex/MacroArgs.cpp index dd0b79cccc2..06e3add1548 100644 --- a/clang/lib/Lex/MacroArgs.cpp +++ b/clang/lib/Lex/MacroArgs.cpp @@ -135,15 +135,12 @@ const Token *MacroArgs::getUnexpArgument(unsigned Arg) const { return Result; } -// This function assumes that the variadic arguments are the tokens -// corresponding to the last parameter (ellipsis) - and since tokens are -// separated by the 'eof' token, if that is the only token corresponding to that -// last parameter, we know no variadic arguments were supplied. -bool MacroArgs::invokedWithVariadicArgument(const MacroInfo *const MI) const { +bool MacroArgs::invokedWithVariadicArgument(const MacroInfo *const MI, + Preprocessor &PP) { if (!MI->isVariadic()) return false; const int VariadicArgIndex = getNumMacroArguments() - 1; - return getUnexpArgument(VariadicArgIndex)->isNot(tok::eof); + return getPreExpArgument(VariadicArgIndex, PP).front().isNot(tok::eof); } /// ArgNeedsPreexpansion - If we can prove that the argument won't be affected |