From: Argyrios Kyrtzidis Date: Wed, 3 Apr 2013 05:11:33 +0000 (+0000) Subject: [modules] If a submodule has re-definitions of the same macro, only the last definiti... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2dbfd8669282915c9466ba88c66f9791b946efa;p=clang [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 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 isPublic; for (; MD; MD = MD->getPrevious()) { @@ -2954,6 +2955,11 @@ class ASTIdentifierTableTrait { isUndefined = false; isPublic = Optional(); } + // 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(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