r342017 - Fix tracking of merged definitions when the merge target is also merged
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 11 19:13:46 PDT 2018
Author: rsmith
Date: Tue Sep 11 19:13:46 2018
New Revision: 342017
URL: http://llvm.org/viewvc/llvm-project?rev=342017&view=rev
Log:
Fix tracking of merged definitions when the merge target is also merged
into something else.
Added:
cfe/trunk/test/Modules/merge-template-pattern-visibility-2.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=342017&r1=342016&r2=342017&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Sep 11 19:13:46 2018
@@ -997,7 +997,8 @@ public:
/// Get the additional modules in which the definition \p Def has
/// been merged.
ArrayRef<Module*> getModulesWithMergedDefinition(const NamedDecl *Def) {
- auto MergedIt = MergedDefModules.find(Def);
+ auto MergedIt =
+ MergedDefModules.find(cast<NamedDecl>(Def->getCanonicalDecl()));
if (MergedIt == MergedDefModules.end())
return None;
return MergedIt->second;
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=342017&r1=342016&r2=342017&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Sep 11 19:13:46 2018
@@ -933,13 +933,13 @@ void ASTContext::mergeDefinitionIntoModu
Listener->RedefinedHiddenDefinition(ND, M);
if (getLangOpts().ModulesLocalVisibility)
- MergedDefModules[ND].push_back(M);
+ MergedDefModules[cast<NamedDecl>(ND->getCanonicalDecl())].push_back(M);
else
ND->setVisibleDespiteOwningModule();
}
void ASTContext::deduplicateMergedDefinitonsFor(NamedDecl *ND) {
- auto It = MergedDefModules.find(ND);
+ auto It = MergedDefModules.find(cast<NamedDecl>(ND->getCanonicalDecl()));
if (It == MergedDefModules.end())
return;
Added: cfe/trunk/test/Modules/merge-template-pattern-visibility-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-template-pattern-visibility-2.cpp?rev=342017&view=auto
==============================================================================
--- cfe/trunk/test/Modules/merge-template-pattern-visibility-2.cpp (added)
+++ cfe/trunk/test/Modules/merge-template-pattern-visibility-2.cpp Tue Sep 11 19:13:46 2018
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility %s -verify -Werror=undefined-inline
+
+#pragma clang module build A1
+module A1 { export * }
+#pragma clang module contents
+#pragma clang module begin A1
+template<typename T> class A {};
+template<typename T> inline bool f(const A<T>&) { return T::error; }
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build A2
+module A2 { export * }
+#pragma clang module contents
+#pragma clang module begin A2
+#pragma clang module load A1
+template<typename T> class A {};
+template<typename T> inline bool f(const A<T>&) { return T::error; }
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build A3
+module A3 { export * }
+#pragma clang module contents
+#pragma clang module begin A3
+template<typename T> class A {};
+template<typename T> inline bool f(const A<T>&) { return T::error; }
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module load A3
+#pragma clang module import A2
+// expected-error@* {{cannot be used prior to}}
+bool y(A<int> o) { return f(o); } // expected-note {{instantiation of}}
More information about the cfe-commits
mailing list