[cfe-commits] r164672 - in /cfe/trunk: include/clang/Lex/Token.h lib/Lex/PPMacroExpansion.cpp lib/Lex/TokenLexer.cpp test/Preprocessor/microsoft-ext.c

Nico Weber nicolasweber at gmx.de
Wed Sep 26 01:19:01 PDT 2012


Author: nico
Date: Wed Sep 26 03:19:01 2012
New Revision: 164672

URL: http://llvm.org/viewvc/llvm-project?rev=164672&view=rev
Log:
Revert r163022, it caused PR13924.

Add a test for PR13924. Do not revert the test added in r163022,
it surprisingly still passes even after reverting the code changes.


Modified:
    cfe/trunk/include/clang/Lex/Token.h
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp
    cfe/trunk/lib/Lex/TokenLexer.cpp
    cfe/trunk/test/Preprocessor/microsoft-ext.c

Modified: cfe/trunk/include/clang/Lex/Token.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=164672&r1=164671&r2=164672&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Token.h (original)
+++ cfe/trunk/include/clang/Lex/Token.h Wed Sep 26 03:19:01 2012
@@ -76,8 +76,7 @@
     DisableExpand = 0x04,  // This identifier may never be macro expanded.
     NeedsCleaning = 0x08,   // Contained an escaped newline or trigraph.
     LeadingEmptyMacro = 0x10, // Empty macro exists before this token.
-    HasUDSuffix = 0x20, // This string or character literal has a ud-suffix.
-    IgnoredComma = 0x40 // Flags ignored commas from nested macro expansions.
+    HasUDSuffix = 0x20     // This string or character literal has a ud-suffix.
   };
 
   tok::TokenKind getKind() const { return (tok::TokenKind)Kind; }

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=164672&r1=164671&r2=164672&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Sep 26 03:19:01 2012
@@ -419,11 +419,7 @@
         }
       } else if (Tok.is(tok::l_paren)) {
         ++NumParens;
-      // In Microsoft-compatibility mode, commas from nested macro expan-
-      // sions should not be considered as argument separators. We test
-      // for this with the IgnoredComma token flag.
-      } else if (Tok.is(tok::comma)
-          && !(Tok.getFlags() & Token::IgnoredComma) && NumParens == 0) {
+      } else if (Tok.is(tok::comma) && NumParens == 0) {
         // Comma ends this argument if there are more fixed arguments expected.
         // However, if this is a variadic macro, and this is part of the
         // variadic part, then the comma is just an argument token.

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=164672&r1=164671&r2=164672&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Wed Sep 26 03:19:01 2012
@@ -225,12 +225,6 @@
           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()) {

Modified: cfe/trunk/test/Preprocessor/microsoft-ext.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/microsoft-ext.c?rev=164672&r1=164671&r2=164672&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/microsoft-ext.c (original)
+++ cfe/trunk/test/Preprocessor/microsoft-ext.c Wed Sep 26 03:19:01 2012
@@ -1,6 +1,24 @@
-// RUN: %clang_cc1 -E -fms-compatibility %s | FileCheck %s
+// RUN: %clang_cc1 -E -fms-compatibility %s -o %t
+// RUN: FileCheck %s < %t
 
 # define M2(x, y) x + y
 # define P(x, y) {x, y}
 # define M(x, y) M2(x, P(x, y))
 M(a, b) // CHECK: a + {a, b}
+
+// Regression test for PR13924
+#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
+#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar
+
+#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2
+
+#define GMOCK_ACTION_CLASS_(name, value_params)\
+    GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
+
+#define ACTION_TEMPLATE(name, template_params, value_params)\
+class GMOCK_ACTION_CLASS_(name, value_params) {\
+}
+
+ACTION_TEMPLATE(InvokeArgument,
+                HAS_1_TEMPLATE_PARAMS(int, k),
+                AND_2_VALUE_PARAMS(p0, p1));





More information about the cfe-commits mailing list