r342020 - Revert r342019, "Track definition merging on the canonical declaration
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 11 19:28:14 PDT 2018
Author: rsmith
Date: Tue Sep 11 19:28:14 2018
New Revision: 342020
URL: http://llvm.org/viewvc/llvm-project?rev=342020&view=rev
Log:
Revert r342019, "Track definition merging on the canonical declaration
even when [...]"
Further testing has revealed that this causes build breaks during
explicit module compilations.
Removed:
cfe/trunk/test/Modules/merge-template-pattern-visibility-3.cpp
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=342020&r1=342019&r2=342020&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Sep 11 19:28:14 2018
@@ -932,7 +932,10 @@ void ASTContext::mergeDefinitionIntoModu
if (auto *Listener = getASTMutationListener())
Listener->RedefinedHiddenDefinition(ND, M);
- MergedDefModules[cast<NamedDecl>(ND->getCanonicalDecl())].push_back(M);
+ if (getLangOpts().ModulesLocalVisibility)
+ MergedDefModules[cast<NamedDecl>(ND->getCanonicalDecl())].push_back(M);
+ else
+ ND->setVisibleDespiteOwningModule();
}
void ASTContext::deduplicateMergedDefinitonsFor(NamedDecl *ND) {
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=342020&r1=342019&r2=342020&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Sep 11 19:28:14 2018
@@ -7623,15 +7623,8 @@ bool Sema::hasVisibleDefinition(NamedDec
// A visible module might have a merged definition instead.
if (D->isModulePrivate() ? hasMergedDefinitionInCurrentModule(D)
- : hasVisibleMergedDefinition(D)) {
- if (CodeSynthesisContexts.empty() &&
- !getLangOpts().ModulesLocalVisibility) {
- // Cache the fact that this definition is implicitly visible because
- // there is a visible merged definition.
- D->setVisibleDespiteOwningModule();
- }
+ : hasVisibleMergedDefinition(D))
return true;
- }
return false;
};
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=342020&r1=342019&r2=342020&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Sep 11 19:28:14 2018
@@ -3780,15 +3780,22 @@ void ASTReader::makeModuleVisible(Module
/// visible.
void ASTReader::mergeDefinitionVisibility(NamedDecl *Def,
NamedDecl *MergedDef) {
+ // FIXME: This doesn't correctly handle the case where MergedDef is visible
+ // in modules other than its owning module. We should instead give the
+ // ASTContext a list of merged definitions for Def.
if (Def->isHidden()) {
// If MergedDef is visible or becomes visible, make the definition visible.
if (!MergedDef->isHidden())
Def->setVisibleDespiteOwningModule();
- else {
+ else if (getContext().getLangOpts().ModulesLocalVisibility) {
getContext().mergeDefinitionIntoModule(
Def, MergedDef->getImportedOwningModule(),
/*NotifyListeners*/ false);
PendingMergedDefinitionsToDeduplicate.insert(Def);
+ } else {
+ auto SubmoduleID = MergedDef->getOwningModuleID();
+ assert(SubmoduleID && "hidden definition in no module");
+ HiddenNamesMap[getSubmodule(SubmoduleID)].push_back(Def);
}
}
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=342020&r1=342019&r2=342020&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Sep 11 19:28:14 2018
@@ -4419,9 +4419,22 @@ void ASTDeclReader::UpdateDecl(Decl *D,
case UPD_DECL_EXPORTED: {
unsigned SubmoduleID = readSubmoduleID();
auto *Exported = cast<NamedDecl>(D);
+ if (auto *TD = dyn_cast<TagDecl>(Exported))
+ Exported = TD->getDefinition();
Module *Owner = SubmoduleID ? Reader.getSubmodule(SubmoduleID) : nullptr;
- Reader.getContext().mergeDefinitionIntoModule(Exported, Owner);
- Reader.PendingMergedDefinitionsToDeduplicate.insert(Exported);
+ if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
+ Reader.getContext().mergeDefinitionIntoModule(cast<NamedDecl>(Exported),
+ Owner);
+ Reader.PendingMergedDefinitionsToDeduplicate.insert(
+ cast<NamedDecl>(Exported));
+ } else if (Owner && Owner->NameVisibility != Module::AllVisible) {
+ // If Owner is made visible at some later point, make this declaration
+ // visible too.
+ Reader.HiddenNamesMap[Owner].push_back(Exported);
+ } else {
+ // The declaration is now visible.
+ Exported->setVisibleDespiteOwningModule();
+ }
break;
}
Removed: cfe/trunk/test/Modules/merge-template-pattern-visibility-3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-template-pattern-visibility-3.cpp?rev=342019&view=auto
==============================================================================
--- cfe/trunk/test/Modules/merge-template-pattern-visibility-3.cpp (original)
+++ cfe/trunk/test/Modules/merge-template-pattern-visibility-3.cpp (removed)
@@ -1,34 +0,0 @@
-// RUN: %clang_cc1 -fmodules -emit-llvm-only %s -verify
-
-#pragma clang module build A
-module A {}
-#pragma clang module contents
-#pragma clang module begin A
-template<typename T> void f(const T&) { T::error; }
-#pragma clang module end
-#pragma clang module endbuild
-
-#pragma clang module build B
-module B {}
-#pragma clang module contents
-#pragma clang module begin B
-template<typename T> void f(const T&) { T::error; }
-#pragma clang module end
-#pragma clang module endbuild
-
-#pragma clang module build C
-module C {}
-#pragma clang module contents
-#pragma clang module begin C
-#pragma clang module load B
-template<typename T> void f(const T&) { T::error; }
-#pragma clang module end
-#pragma clang module endbuild
-
-#pragma clang module load A
-inline void f() {}
-void x() { f(); }
-
-#pragma clang module import C
-// expected-error@* {{cannot be used prior to}}
-void y(int n) { f(n); } // expected-note {{instantiation of}}
More information about the cfe-commits
mailing list