[cfe-commits] r172018 - in /cfe/trunk: lib/Lex/PreprocessingRecord.cpp test/Preprocessor/pp-record.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Jan 9 15:22:20 PST 2013


Author: akirtzidis
Date: Wed Jan  9 17:22:20 2013
New Revision: 172018

URL: http://llvm.org/viewvc/llvm-project?rev=172018&view=rev
Log:
[PreprocessingRecord] A macro expansion can be reported out-of-order in cases when
there are macro expansions inside macro arguments where the arguments are
not expanded in the same order as listed; don't assert that all macro expansions
are in source order.

rdar://12397063

Modified:
    cfe/trunk/lib/Lex/PreprocessingRecord.cpp
    cfe/trunk/test/Preprocessor/pp-record.c

Modified: cfe/trunk/lib/Lex/PreprocessingRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PreprocessingRecord.cpp?rev=172018&r1=172017&r2=172018&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PreprocessingRecord.cpp (original)
+++ cfe/trunk/lib/Lex/PreprocessingRecord.cpp Wed Jan  9 17:22:20 2013
@@ -244,11 +244,11 @@
   assert(Entity);
   SourceLocation BeginLoc = Entity->getSourceRange().getBegin();
 
-  if (!isa<class InclusionDirective>(Entity)) {
+  if (isa<MacroDefinition>(Entity)) {
     assert((PreprocessedEntities.empty() ||
             !SourceMgr.isBeforeInTranslationUnit(BeginLoc,
                    PreprocessedEntities.back()->getSourceRange().getBegin())) &&
-           "a macro directive was encountered out-of-order");
+           "a macro definition was encountered out-of-order");
     PreprocessedEntities.push_back(Entity);
     return getPPEntityID(PreprocessedEntities.size()-1, /*isLoaded=*/false);
   }
@@ -263,7 +263,15 @@
 
   // The entity's location is not after the previous one; this can happen with
   // include directives that form the filename using macros, e.g:
-  // "#include MACRO(STUFF)".
+  // "#include MACRO(STUFF)"
+  // or with macro expansions inside macro arguments where the arguments are
+  // not expanded in the same order as listed, e.g:
+  // \code
+  //  #define M1 1
+  //  #define M2 2
+  //  #define FM(x,y) y x
+  //  FM(M1, M2)
+  // \endcode
 
   typedef std::vector<PreprocessedEntity *>::iterator pp_iter;
 

Modified: cfe/trunk/test/Preprocessor/pp-record.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pp-record.c?rev=172018&r1=172017&r2=172018&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/pp-record.c (original)
+++ cfe/trunk/test/Preprocessor/pp-record.c Wed Jan  9 17:22:20 2013
@@ -21,3 +21,8 @@
     int b;
 #endif
 )
+
+#define M1 c
+#define M2 int
+#define FM2(x,y) y x
+FM2(M1, M2);





More information about the cfe-commits mailing list