diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-03 05:11:33 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-03 05:11:33 +0000 |
commit | b2dbfd8669282915c9466ba88c66f9791b946efa (patch) | |
tree | a449c381458f399c735c137e2aea30877f287f42 | |
parent | 670b2e6e9e75ca5d816899f6c1ac97137ba6f206 (diff) |
[modules] If a submodule has re-definitions of the same macro, only the last definition will be used as the "exported" one.
Fixes rdar://13562262
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178622 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 6 | ||||
-rw-r--r-- | test/Modules/Inputs/macros_top.h | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 033d48c147..6893b5003f 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -2937,6 +2937,7 @@ class ASTIdentifierTableTrait { if (!MD) return 0; + SubmoduleID OrigModID = ModID; bool isUndefined = false; Optional<bool> isPublic; for (; MD; MD = MD->getPrevious()) { @@ -2954,6 +2955,11 @@ class ASTIdentifierTableTrait { isUndefined = false; isPublic = Optional<bool>(); } + // We are looking for a definition in a different submodule than the one + // that we started with. If a submodule has re-definitions of the same + // macro, only the last definition will be used as the "exported" one. + if (ModID == OrigModID) + continue; if (DefMacroDirective *DefMD = dyn_cast<DefMacroDirective>(MD)) { if (!isUndefined && (!isPublic.hasValue() || isPublic.getValue())) diff --git a/test/Modules/Inputs/macros_top.h b/test/Modules/Inputs/macros_top.h index 9c3f3c071f..dd303ffee4 100644 --- a/test/Modules/Inputs/macros_top.h +++ b/test/Modules/Inputs/macros_top.h @@ -8,8 +8,8 @@ - - +#define TOP_RIGHT_REDEF float +// The last definition will be exported from the sub-module. #define TOP_RIGHT_REDEF int #define TOP_RIGHT_UNDEF int |