summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-03 05:11:33 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-03 05:11:33 +0000
commit3e612b419a47dbbc6eff50334d3072b7b9cd3d8d (patch)
treefa10e1b4ce02bcc681f983d7dab36f641da3f85a
parentd9bbdfd3cc9584ae4c2fc1ba5f5699a7ad2d0cf7 (diff)
downloadbcm5719-llvm-3e612b419a47dbbc6eff50334d3072b7b9cd3d8d.tar.gz
bcm5719-llvm-3e612b419a47dbbc6eff50334d3072b7b9cd3d8d.zip
[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 llvm-svn: 178622
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp6
-rw-r--r--clang/test/Modules/Inputs/macros_top.h4
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 033d48c1471..6893b5003ff 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/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/clang/test/Modules/Inputs/macros_top.h b/clang/test/Modules/Inputs/macros_top.h
index 9c3f3c071fd..dd303ffee4e 100644
--- a/clang/test/Modules/Inputs/macros_top.h
+++ b/clang/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
OpenPOWER on IntegriCloud