r178622 - [modules] If a submodule has re-definitions of the same macro, only the last definition will be used as the "exported" one.

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Apr 2 22:11:34 PDT 2013


Author: akirtzidis
Date: Wed Apr  3 00:11:33 2013
New Revision: 178622

URL: http://llvm.org/viewvc/llvm-project?rev=178622&view=rev
Log:
[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

Modified:
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/test/Modules/Inputs/macros_top.h

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=178622&r1=178621&r2=178622&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Apr  3 00:11:33 2013
@@ -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()))

Modified: cfe/trunk/test/Modules/Inputs/macros_top.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/macros_top.h?rev=178622&r1=178621&r2=178622&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/macros_top.h (original)
+++ cfe/trunk/test/Modules/Inputs/macros_top.h Wed Apr  3 00:11:33 2013
@@ -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





More information about the cfe-commits mailing list