summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-09-14 01:05:35 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-09-14 01:05:35 +0000
commit1e75676d848ff2162d2b44d59f4b9d2ff61c5593 (patch)
tree55de45d1bf54adac97f54f6624c6bfd6f65a3d70 /include
parent0df4478deda6a49b5a5e09fb1e8bdce67971ee93 (diff)
downloadclang-1e75676d848ff2162d2b44d59f4b9d2ff61c5593.tar.gz
[modules] When merging one definition into another, propagate the list of
re-exporting modules from the discarded definition to the retained definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@281429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/AST/ASTContext.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 0a184bc2e3..0bc4aa4d80 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -308,10 +308,18 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// merged into.
llvm::DenseMap<Decl*, Decl*> MergedDecls;
+ /// The modules into which a definition has been merged, or a map from a
+ /// merged definition to its canonical definition. This is really a union of
+ /// a NamedDecl* and a vector of Module*.
+ struct MergedModulesOrCanonicalDef {
+ llvm::TinyPtrVector<Module*> MergedModules;
+ NamedDecl *CanonicalDef = nullptr;
+ };
+
/// \brief A mapping from a defining declaration to a list of modules (other
/// than the owning module of the declaration) that contain merged
/// definitions of that entity.
- llvm::DenseMap<NamedDecl*, llvm::TinyPtrVector<Module*>> MergedDefModules;
+ llvm::DenseMap<NamedDecl*, MergedModulesOrCanonicalDef> MergedDefModules;
/// \brief Initializers for a module, in order. Each Decl will be either
/// something that has a semantic effect on startup (such as a variable with
@@ -894,6 +902,7 @@ public:
/// and should be visible whenever \p M is visible.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M,
bool NotifyListeners = true);
+ void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other);
/// \brief Clean up the merged definition list. Call this if you might have
/// added duplicates into the list.
void deduplicateMergedDefinitonsFor(NamedDecl *ND);
@@ -904,7 +913,9 @@ public:
auto MergedIt = MergedDefModules.find(Def);
if (MergedIt == MergedDefModules.end())
return None;
- return MergedIt->second;
+ if (auto *CanonDef = MergedIt->second.CanonicalDef)
+ return getModulesWithMergedDefinition(CanonDef);
+ return MergedIt->second.MergedModules;
}
/// Add a declaration to the list of declarations that are initialized