summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-07-18 22:13:40 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-07-18 22:13:40 +0000
commite657bbdcbc8e9ed27398068d0f6ae073470043bf (patch)
tree536f17d29f9966f1583f3cbad5bb3cc0e98168dd /clang/lib/Serialization/ASTWriter.cpp
parentad2e0352f07903de00c2a21b524f40ff3297b861 (diff)
downloadbcm5719-llvm-e657bbdcbc8e9ed27398068d0f6ae073470043bf.tar.gz
bcm5719-llvm-e657bbdcbc8e9ed27398068d0f6ae073470043bf.zip
Reinstate r213348, reverted in r213395, with an additional bug fix and more
thorough tests. Original commit message: [modules] Fix macro hiding bug exposed if: * A submodule of module A is imported into module B * Another submodule of module A that is not imported into B exports a macro * Some submodule of module B also exports a definition of the macro, and happens to be the first submodule of B that imports module A. In this case, we would incorrectly determine that A's macro redefines B's macro, and so we don't need to re-export B's macro at all. This happens with the 'assert' macro in an LLVM self-host. =( llvm-svn: 213416
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 97a5d0e9d28..9b44c54eb35 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1900,6 +1900,12 @@ static bool shouldIgnoreMacro(MacroDirective *MD, bool IsModule,
return true;
if (IsModule) {
+ // Re-export any imported directives.
+ // FIXME: Also ensure we re-export imported #undef directives.
+ if (auto *DMD = dyn_cast<DefMacroDirective>(MD))
+ if (DMD->isImported())
+ return false;
+
SourceLocation Loc = MD->getLocation();
if (Loc.isInvalid())
return true;
@@ -3089,7 +3095,17 @@ class ASTIdentifierTableTrait {
}
SubmoduleID getSubmoduleID(MacroDirective *MD) {
- return Writer.inferSubmoduleIDFromLocation(MD->getLocation());
+ if (MD->getLocation().isValid())
+ return Writer.inferSubmoduleIDFromLocation(MD->getLocation());
+
+ // If we have no directive location, this macro was installed when
+ // finalizing the ASTReader.
+ if (DefMacroDirective *DefMD = dyn_cast<DefMacroDirective>(MD))
+ return DefMD->getInfo()->getOwningModuleID();
+
+ // Skip imports that only produce #undefs for now.
+ // FIXME: We should still re-export them!
+ return 0;
}
public:
OpenPOWER on IntegriCloud