diff options
| author | Reid Kleckner <reid@kleckner.net> | 2013-06-26 17:16:08 +0000 |
|---|---|---|
| committer | Reid Kleckner <reid@kleckner.net> | 2013-06-26 17:16:08 +0000 |
| commit | 596b85cc234d8f5c2fcdb23ade14535a33789c5c (patch) | |
| tree | 2cd0adbca30804d2a66e33e822f6338103503fd1 /clang/lib/Lex/TokenLexer.cpp | |
| parent | b3f550e8cd5ff1d2304582e95dd494bf955f27d3 (diff) | |
| download | bcm5719-llvm-596b85cc234d8f5c2fcdb23ade14535a33789c5c.tar.gz bcm5719-llvm-596b85cc234d8f5c2fcdb23ade14535a33789c5c.zip | |
Match MSVC's handling of commas during macro argument expansion
This allows clang to parse the type_traits header in Visual Studio 2012,
which is included widely in practice.
This is a rework of r163022 by João Matos. The original patch broke
preprocessing of gtest headers, which this patch addresses.
Patch by Will Wilson!
llvm-svn: 184968
Diffstat (limited to 'clang/lib/Lex/TokenLexer.cpp')
| -rw-r--r-- | clang/lib/Lex/TokenLexer.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Lex/TokenLexer.cpp b/clang/lib/Lex/TokenLexer.cpp index 4251f0ebf28..4f21995391c 100644 --- a/clang/lib/Lex/TokenLexer.cpp +++ b/clang/lib/Lex/TokenLexer.cpp @@ -278,6 +278,14 @@ void TokenLexer::ExpandFunctionArguments() { unsigned NumToks = MacroArgs::getArgLength(ResultArgToks); ResultToks.append(ResultArgToks, ResultArgToks+NumToks); + // In Microsoft-compatibility mode, we follow MSVC's preprocessing + // behavior by not considering single commas from nested macro + // expansions as argument separators. Set a flag on the token so we can + // test for this later when the macro expansion is processed. + if (PP.getLangOpts().MicrosoftMode && NumToks == 1 && + ResultToks.back().is(tok::comma)) + ResultToks.back().setFlag(Token::IgnoredComma); + // If the '##' came from expanding an argument, turn it into 'unknown' // to avoid pasting. for (unsigned i = FirstResult, e = ResultToks.size(); i != e; ++i) { |

