aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/TokenLexer.cpp
diff options
context:
space:
mode:
authorJoao Matos <ripzonetriton@gmail.com>2012-08-31 21:10:54 +0000
committerJoao Matos <ripzonetriton@gmail.com>2012-08-31 21:10:54 +0000
commit181cd5bdebf0b88e8194c3f58da60f7f5b918b33 (patch)
treedd6b6f1ec36350a172493d8f59a079796e79b39e /lib/Lex/TokenLexer.cpp
parent7e2e4c33cdd347d0f3faac3e391245d06fa42811 (diff)
Emulate MSVC's preprocessor macro argument separator behavior by not considering commas from nested macro expansions as argument separators. Fixes parsing of VS 2012 headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/TokenLexer.cpp')
-rw-r--r--lib/Lex/TokenLexer.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Lex/TokenLexer.cpp b/lib/Lex/TokenLexer.cpp
index 819bb3f43e..de704ee3d7 100644
--- a/lib/Lex/TokenLexer.cpp
+++ b/lib/Lex/TokenLexer.cpp
@@ -225,6 +225,12 @@ void TokenLexer::ExpandFunctionArguments() {
Token &Tok = ResultToks[i];
if (Tok.is(tok::hashhash))
Tok.setKind(tok::unknown);
+ // In Microsoft-compatibility mode, we follow MSVC's preprocessing
+ // behaviour by not considering 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 (Tok.is(tok::comma) && PP.getLangOpts().MicrosoftMode)
+ Tok.setFlag(Token::IgnoredComma);
}
if(ExpandLocStart.isValid()) {