]> granicus.if.org Git - clang/commitdiff
Simplify exclusion of nested classes from extern template instantiation, NFC
authorReid Kleckner <rnk@google.com>
Mon, 29 Apr 2019 21:32:05 +0000 (21:32 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 29 Apr 2019 21:32:05 +0000 (21:32 +0000)
Summary:
This simplifies three checks for MS ABI, Win Itanium, or Win GNU to just
"is Windows".

The question remains, however, if this is really the correct thing to
do. We could, for example, only not consider inner classes to be
externally available if the outer class has a dllexport annotation.
However, I will leave that as future work.

Reviewers: hans, mstorsjo

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61278

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359507 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiate.cpp

index a7be1ea7c89ee89cd005b1aca99574b7b45b57a0..03822e2c7824e61344074d425bb9415239e97374 100644 (file)
@@ -2684,15 +2684,14 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
                                                 == TSK_ExplicitSpecialization)
         continue;
 
-      if ((Context.getTargetInfo().getCXXABI().isMicrosoft() ||
-           Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment() ||
-           Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
+      if (Context.getTargetInfo().getTriple().isOSWindows() &&
           TSK == TSK_ExplicitInstantiationDeclaration) {
-        // In MSVC and Windows Itanium mode, explicit instantiation decl of the
-        // outer class doesn't affect the inner class.
-        // In GNU mode, inner classes aren't dllexported. Don't let the
-        // instantiation cover the inner class, to avoid undefined references
-        // to inner classes that weren't exported.
+        // On Windows, explicit instantiation decl of the outer class doesn't
+        // affect the inner class. Typically extern template declarations are
+        // used in combination with dll import/export annotations, but those
+        // are not propagated from the outer class templates to inner classes.
+        // Therefore, do not instantiate inner classes on this platform, so
+        // that users don't end up with undefined symbols during linking.
         continue;
       }