summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-10-13 23:04:14 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-10-13 23:04:14 +0000
commitb50df911788541fb5e17fe7cf3ce25330101a53a (patch)
tree5dfbd3ed0b7015b114563b7e54ae820b75cbfd36 /clang/include
parent7705c4f1be36d8c3384f71b71fdd6751a49d7a70 (diff)
downloadbcm5719-llvm-b50df911788541fb5e17fe7cf3ce25330101a53a.tar.gz
bcm5719-llvm-b50df911788541fb5e17fe7cf3ce25330101a53a.zip
Reinstate r281429, reverted in r281452, with a fix for its mishandling of
compiles without -fmodules-local-submodule-visibility. Original commit message: [modules] When merging one definition into another, propagate the list of re-exporting modules from the discarded definition to the retained definition. llvm-svn: 284176
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/AST/ASTContext.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 3d777524b83..f5a9bd2da54 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/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
@@ -883,6 +891,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);
@@ -893,7 +902,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
OpenPOWER on IntegriCloud