summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-01-09 23:22:20 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-01-09 23:22:20 +0000
commiteb994f4064175f39c44badf6b41419bc4890455e (patch)
tree83919c58c45bb681b4aaa668c1bb26ea0b92ce97 /clang
parent9f89bffc2543ce9da4aea8508bc15a746d3c6656 (diff)
downloadbcm5719-llvm-eb994f4064175f39c44badf6b41419bc4890455e.tar.gz
bcm5719-llvm-eb994f4064175f39c44badf6b41419bc4890455e.zip
[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 llvm-svn: 172018
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PreprocessingRecord.cpp14
-rw-r--r--clang/test/Preprocessor/pp-record.c5
2 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp
index 497af0b3dad..8e8afeb4b76 100644
--- a/clang/lib/Lex/PreprocessingRecord.cpp
+++ b/clang/lib/Lex/PreprocessingRecord.cpp
@@ -244,11 +244,11 @@ PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) {
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 @@ PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) {
// 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;
diff --git a/clang/test/Preprocessor/pp-record.c b/clang/test/Preprocessor/pp-record.c
index dd958d0e56d..92ca366e37f 100644
--- a/clang/test/Preprocessor/pp-record.c
+++ b/clang/test/Preprocessor/pp-record.c
@@ -21,3 +21,8 @@ FNM(
int b;
#endif
)
+
+#define M1 c
+#define M2 int
+#define FM2(x,y) y x
+FM2(M1, M2);
OpenPOWER on IntegriCloud