[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
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 033d48c..6893b50 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -2937,6 +2937,7 @@
if (!MD)
return 0;
+ SubmoduleID OrigModID = ModID;
bool isUndefined = false;
Optional<bool> isPublic;
for (; MD; MD = MD->getPrevious()) {
@@ -2954,6 +2955,11 @@
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()))