]> granicus.if.org Git - clang/commitdiff
[modules] Fix a corner case in the macro override rules: properly handle overridden...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 16 Sep 2015 00:55:50 +0000 (00:55 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 16 Sep 2015 00:55:50 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247765 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/Modules/macros.c

index 594365b45e171e0faba239c199fa261c34cbac4a..ba49437a060238efde8fe59c6a40a91466a82d3a 100644 (file)
@@ -145,8 +145,12 @@ void Preprocessor::updateModuleMacroInfo(const IdentifierInfo *II,
     NumHiddenOverrides[O] = -1;
 
   // Collect all macros that are not overridden by a visible macro.
-  llvm::SmallVector<ModuleMacro *, 16> Worklist(Leaf->second.begin(),
-                                                Leaf->second.end());
+  llvm::SmallVector<ModuleMacro *, 16> Worklist;
+  for (auto *LeafMM : Leaf->second) {
+    assert(LeafMM->getNumOverridingMacros() == 0 && "leaf macro overridden");
+    if (NumHiddenOverrides.lookup(LeafMM) == 0)
+      Worklist.push_back(LeafMM);
+  }
   while (!Worklist.empty()) {
     auto *MM = Worklist.pop_back_val();
     if (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {
index 4b08e6c5d31da25204a65577431fa3bdb831c497..032eea65918a3b4e77b1cacdd9ee895b4c2be9b8 100644 (file)
@@ -18,7 +18,6 @@
 // expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}}
 // expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}}
 // expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}}
-// expected-note@Inputs/macros_left.h:11{{other definition of 'LEFT_RIGHT_DIFFERENT2'}}
 
 @import macros;
 
@@ -72,9 +71,14 @@ void f() {
 #  error TOP should not be visible
 #endif
 
+#undef INTEGER
+#define INTEGER int
+
 // Import left module (which also imports top)
 @import macros_left;
 
+INTEGER my_integer = 0;
+
 #ifndef LEFT
 #  error LEFT should be visible
 #endif