<div dir="ltr"><div dir="ltr">Hello Louis,<br><br>This commit broke build step on one of our builders:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/13042">http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/13042</a></div><div dir="ltr"><br></div><div dir="ltr">. . .<br>FAILED: tools/clang/lib/Sema/CMakeFiles/clangSema.dir/SemaExprCXX.cpp.obj <br>C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\clang\lib\Sema -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include -Itools\clang\include -Iinclude -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1    /EHs-c- /GR- /showIncludes /Fotools\clang\lib\Sema\CMakeFiles\clangSema.dir\SemaExprCXX.cpp.obj /Fdtools\clang\lib\Sema\CMakeFiles\clangSema.dir\clangSema.pdb /FS -c C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp<br>C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Sema\SemaExprCXX.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj<br><br><br>Please have a look?<br>The builder was already red and did not send notifications on this.<br><br>Thanks<br><br>Galina<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 4, 2018 at 8:51 AM Louis Dionne via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ldionne<br>
Date: Thu Oct  4 08:49:42 2018<br>
New Revision: 343790<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=343790&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=343790&view=rev</a><br>
Log:<br>
[clang] Add the exclude_from_explicit_instantiation attribute<br>
<br>
Summary:<br>
This attribute allows excluding a member of a class template from being part<br>
of an explicit template instantiation of that class template. This also makes<br>
sure that code using such a member will not take for granted that an external<br>
instantiation exists in another translation unit. The attribute was discussed<br>
on cfe-dev at [1] and is primarily motivated by the removal of always_inline<br>
in libc++ to control what's part of the ABI (see links in [1]).<br>
<br>
[1]: <a href="http://lists.llvm.org/pipermail/cfe-dev/2018-August/059024.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/cfe-dev/2018-August/059024.html</a><br>
<br>
rdar://problem/43428125<br>
<br>
Reviewers: rsmith<br>
<br>
Subscribers: dexonsmith, cfe-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D51789" rel="noreferrer" target="_blank">https://reviews.llvm.org/D51789</a><br>
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp<br>
    cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp<br>
    cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp<br>
    cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp<br>
    cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/Attr.td<br>
    cfe/trunk/include/clang/Basic/AttrDocs.td<br>
    cfe/trunk/lib/Sema/Sema.cpp<br>
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp<br>
    cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Attr.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=343790&r1=343789&r2=343790&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=343790&r1=343789&r2=343790&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Oct  4 08:49:42 2018<br>
@@ -3042,6 +3042,13 @@ def InternalLinkage : InheritableAttr {<br>
   let Documentation = [InternalLinkageDocs];<br>
 }<br>
<br>
+def ExcludeFromExplicitInstantiation : InheritableAttr {<br>
+  let Spellings = [Clang<"exclude_from_explicit_instantiation">];<br>
+  let Subjects = SubjectList<[Var, Function, CXXRecord]>;<br>
+  let Documentation = [ExcludeFromExplicitInstantiationDocs];<br>
+  let MeaningfulToClassTemplateDefinition = 1;<br>
+}<br>
+<br>
 def Reinitializes : InheritableAttr {<br>
   let Spellings = [Clang<"reinitializes", 0>];<br>
   let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;<br>
<br>
Modified: cfe/trunk/include/clang/Basic/AttrDocs.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=343790&r1=343789&r2=343790&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=343790&r1=343789&r2=343790&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)<br>
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Oct  4 08:49:42 2018<br>
@@ -2975,6 +2975,68 @@ This can be used to contain the ABI of a<br>
   }];<br>
 }<br>
<br>
+def ExcludeFromExplicitInstantiationDocs : Documentation {<br>
+  let Category = DocCatFunction;<br>
+  let Content = [{<br>
+The ``exclude_from_explicit_instantiation`` attribute opts-out a member of a<br>
+class template from being part of explicit template instantiations of that<br>
+class template. This means that an explicit instantiation will not instantiate<br>
+members of the class template marked with the attribute, but also that code<br>
+where an extern template declaration of the enclosing class template is visible<br>
+will not take for granted that an external instantiation of the class template<br>
+would provide those members (which would otherwise be a link error, since the<br>
+explicit instantiation won't provide those members). For example, let's say we<br>
+don't want the ``data()`` method to be part of libc++'s ABI. To make sure it<br>
+is not exported from the dylib, we give it hidden visibility:<br>
+<br>
+  .. code-block:: c++<br>
+<br>
+    // in <string><br>
+    template <class CharT><br>
+    class basic_string {<br>
+    public:<br>
+      __attribute__((__visibility__("hidden")))<br>
+      const value_type* data() const noexcept { ... }<br>
+    };<br>
+<br>
+    template class basic_string<char>;<br>
+<br>
+Since an explicit template instantiation declaration for ``basic_string<char>``<br>
+is provided, the compiler is free to assume that ``basic_string<char>::data()``<br>
+will be provided by another translation unit, and it is free to produce an<br>
+external call to this function. However, since ``data()`` has hidden visibility<br>
+and the explicit template instantiation is provided in a shared library (as<br>
+opposed to simply another translation unit), ``basic_string<char>::data()``<br>
+won't be found and a link error will ensue. This happens because the compiler<br>
+assumes that ``basic_string<char>::data()`` is part of the explicit template<br>
+instantiation declaration, when it really isn't. To tell the compiler that<br>
+``data()`` is not part of the explicit template instantiation declaration, the<br>
+``exclude_from_explicit_instantiation`` attribute can be used:<br>
+<br>
+  .. code-block:: c++<br>
+<br>
+    // in <string><br>
+    template <class CharT><br>
+    class basic_string {<br>
+    public:<br>
+      __attribute__((__visibility__("hidden")))<br>
+      __attribute__((exclude_from_explicit_instantiation))<br>
+      const value_type* data() const noexcept { ... }<br>
+    };<br>
+<br>
+    template class basic_string<char>;<br>
+<br>
+Now, the compiler won't assume that ``basic_string<char>::data()`` is provided<br>
+externally despite there being an explicit template instantiation declaration:<br>
+the compiler will implicitly instantiate ``basic_string<char>::data()`` in the<br>
+TUs where it is used.<br>
+<br>
+This attribute can be used on static and non-static member functions of class<br>
+templates, static data members of class templates and member classes of class<br>
+templates.<br>
+  }];<br>
+}<br>
+<br>
 def DisableTailCallsDocs : Documentation {<br>
   let Category = DocCatFunction;<br>
   let Content = [{<br>
<br>
Modified: cfe/trunk/lib/Sema/Sema.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=343790&r1=343789&r2=343790&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=343790&r1=343789&r2=343790&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/Sema.cpp (original)<br>
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Oct  4 08:49:42 2018<br>
@@ -644,7 +644,8 @@ void Sema::getUndefinedButUsed(<br>
         continue;<br>
       if (FD->isExternallyVisible() &&<br>
           !isExternalWithNoLinkageType(FD) &&<br>
-          !FD->getMostRecentDecl()->isInlined())<br>
+          !FD->getMostRecentDecl()->isInlined() &&<br>
+          !FD->hasAttr<ExcludeFromExplicitInstantiationAttr>())<br>
         continue;<br>
       if (FD->getBuiltinID())<br>
         continue;<br>
@@ -654,7 +655,8 @@ void Sema::getUndefinedButUsed(<br>
         continue;<br>
       if (VD->isExternallyVisible() &&<br>
           !isExternalWithNoLinkageType(VD) &&<br>
-          !VD->getMostRecentDecl()->isInline())<br>
+          !VD->getMostRecentDecl()->isInline() &&<br>
+          !VD->hasAttr<ExcludeFromExplicitInstantiationAttr>())<br>
         continue;<br>
<br>
       // Skip VarDecls that lack formal definitions but which we know are in<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=343790&r1=343789&r2=343790&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=343790&r1=343789&r2=343790&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct  4 08:49:42 2018<br>
@@ -6512,6 +6512,9 @@ static void ProcessDeclAttribute(Sema &S<br>
   case ParsedAttr::AT_InternalLinkage:<br>
     handleInternalLinkageAttr(S, D, AL);<br>
     break;<br>
+  case ParsedAttr::AT_ExcludeFromExplicitInstantiation:<br>
+    handleSimpleAttribute<ExcludeFromExplicitInstantiationAttr>(S, D, AL);<br>
+    break;<br>
   case ParsedAttr::AT_LTOVisibilityPublic:<br>
     handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, AL);<br>
     break;<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=343790&r1=343789&r2=343790&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=343790&r1=343789&r2=343790&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Oct  4 08:49:42 2018<br>
@@ -2574,10 +2574,14 @@ Sema::InstantiateClassMembers(SourceLoca<br>
   for (auto *D : Instantiation->decls()) {<br>
     bool SuppressNew = false;<br>
     if (auto *Function = dyn_cast<FunctionDecl>(D)) {<br>
-      if (FunctionDecl *Pattern<br>
-            = Function->getInstantiatedFromMemberFunction()) {<br>
-        MemberSpecializationInfo *MSInfo<br>
-          = Function->getMemberSpecializationInfo();<br>
+      if (FunctionDecl *Pattern =<br>
+              Function->getInstantiatedFromMemberFunction()) {<br>
+<br>
+        if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>())<br>
+          continue;<br>
+<br>
+        MemberSpecializationInfo *MSInfo =<br>
+            Function->getMemberSpecializationInfo();<br>
         assert(MSInfo && "No member specialization information?");<br>
         if (MSInfo->getTemplateSpecializationKind()<br>
                                                  == TSK_ExplicitSpecialization)<br>
@@ -2618,6 +2622,9 @@ Sema::InstantiateClassMembers(SourceLoca<br>
         continue;<br>
<br>
       if (Var->isStaticDataMember()) {<br>
+        if (Var->hasAttr<ExcludeFromExplicitInstantiationAttr>())<br>
+          continue;<br>
+<br>
         MemberSpecializationInfo *MSInfo = Var->getMemberSpecializationInfo();<br>
         assert(MSInfo && "No member specialization information?");<br>
         if (MSInfo->getTemplateSpecializationKind()<br>
@@ -2649,6 +2656,9 @@ Sema::InstantiateClassMembers(SourceLoca<br>
         }<br>
       }<br>
     } else if (auto *Record = dyn_cast<CXXRecordDecl>(D)) {<br>
+      if (Record->hasAttr<ExcludeFromExplicitInstantiationAttr>())<br>
+        continue;<br>
+<br>
       // Always skip the injected-class-name, along with any<br>
       // redeclarations of nested classes, since both would cause us<br>
       // to try to instantiate the members of a class twice.<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp?rev=343790&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp?rev=343790&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dont_assume_extern_instantiation.cpp Thu Oct  4 08:49:42 2018<br>
@@ -0,0 +1,84 @@<br>
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -O0 -o - %s | FileCheck %s<br>
+<br>
+// Test that we do not assume that entities marked with the<br>
+// exclude_from_explicit_instantiation attribute are instantiated<br>
+// in another TU when an extern template instantiation declaration<br>
+// is present. We test that by making sure that definitions are<br>
+// generated in this TU despite there being an extern template<br>
+// instantiation declaration, which is normally not the case.<br>
+<br>
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))<br>
+<br>
+template <class T><br>
+struct Foo {<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION        inline void non_static_member_function1();<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION               void non_static_member_function2();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static inline void static_member_function1();<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static        void static_member_function2();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static        int static_data_member;<br>
+<br>
+  struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION member_class1 {<br>
+    static void static_member_function() { }<br>
+  };<br>
+<br>
+  struct member_class2 {<br>
+    EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function() { }<br>
+  };<br>
+};<br>
+<br>
+template <class T> inline void Foo<T>::non_static_member_function1() { }<br>
+template <class T>        void Foo<T>::non_static_member_function2() { }<br>
+<br>
+template <class T> inline void Foo<T>::static_member_function1() { }<br>
+template <class T>        void Foo<T>::static_member_function2() { }<br>
+<br>
+template <class T>        int Foo<T>::static_data_member = 0;<br>
+<br>
+extern template struct Foo<int>;<br>
+<br>
+void use() {<br>
+  Foo<int> f;<br>
+<br>
+  // An inline non-static member function marked with the attribute is not<br>
+  // part of the extern template declaration, so a definition must be emitted<br>
+  // in this TU.<br>
+  // CHECK-DAG: define linkonce_odr void @_ZN3FooIiE27non_static_member_function1Ev<br>
+  f.non_static_member_function1();<br>
+<br>
+  // A non-inline non-static member function marked with the attribute is<br>
+  // not part of the extern template declaration, so a definition must be<br>
+  // emitted in this TU.<br>
+  // CHECK-DAG: define linkonce_odr void @_ZN3FooIiE27non_static_member_function2Ev<br>
+  f.non_static_member_function2();<br>
+<br>
+  // An inline static member function marked with the attribute is not<br>
+  // part of the extern template declaration, so a definition must be<br>
+  // emitted in this TU.<br>
+  // CHECK-DAG: define linkonce_odr void @_ZN3FooIiE23static_member_function1Ev<br>
+  Foo<int>::static_member_function1();<br>
+<br>
+  // A non-inline static member function marked with the attribute is not<br>
+  // part of the extern template declaration, so a definition must be<br>
+  // emitted in this TU.<br>
+  // CHECK-DAG: define linkonce_odr void @_ZN3FooIiE23static_member_function2Ev<br>
+  Foo<int>::static_member_function2();<br>
+<br>
+  // A static data member marked with the attribute is not part of the<br>
+  // extern template declaration, so a definition must be emitted in this TU.<br>
+  // CHECK-DAG: @_ZN3FooIiE18static_data_memberE = linkonce_odr global<br>
+  int& odr_use = Foo<int>::static_data_member;<br>
+<br>
+  // A member class marked with the attribute is not part of the extern<br>
+  // template declaration (it is not recursively instantiated), so its member<br>
+  // functions must be emitted in this TU.<br>
+  // CHECK-DAG: define linkonce_odr void @_ZN3FooIiE13member_class122static_member_functionEv<br>
+  Foo<int>::member_class1::static_member_function();<br>
+<br>
+  // A member function marked with the attribute in a member class is not<br>
+  // part of the extern template declaration of the parent class template, so<br>
+  // it must be emitted in this TU.<br>
+  // CHECK-DAG: define linkonce_odr void @_ZN3FooIiE13member_class222static_member_functionEv<br>
+  Foo<int>::member_class2::static_member_function();<br>
+}<br>
<br>
Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=343790&r1=343789&r2=343790&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=343790&r1=343789&r2=343790&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test (original)<br>
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Thu Oct  4 08:49:42 2018<br>
@@ -2,7 +2,7 @@<br>
<br>
 // The number of supported attributes should never go down!<br>
<br>
-// CHECK: #pragma clang attribute supports 128 attributes:<br>
+// CHECK: #pragma clang attribute supports 129 attributes:<br>
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)<br>
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)<br>
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)<br>
@@ -47,6 +47,7 @@<br>
 // CHECK-NEXT: DisableTailCalls (SubjectMatchRule_function, SubjectMatchRule_objc_method)<br>
 // CHECK-NEXT: EnableIf (SubjectMatchRule_function)<br>
 // CHECK-NEXT: EnumExtensibility (SubjectMatchRule_enum)<br>
+// CHECK-NEXT: ExcludeFromExplicitInstantiation (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)<br>
 // CHECK-NEXT: ExternalSourceSymbol ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))<br>
 // CHECK-NEXT: FlagEnum (SubjectMatchRule_enum)<br>
 // CHECK-NEXT: Flatten (SubjectMatchRule_function)<br>
<br>
Added: cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp?rev=343790&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp?rev=343790&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.diagnose_on_undefined_entity.cpp Thu Oct  4 08:49:42 2018<br>
@@ -0,0 +1,36 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -Wundefined-func-template -Wundefined-var-template -verify %s<br>
+<br>
+// Test that a diagnostic is emitted when an entity marked with the<br>
+// exclude_from_explicit_instantiation attribute is not defined in<br>
+// the current TU but it is used (and it is hence implicitly<br>
+// instantiated).<br>
+<br>
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))<br>
+<br>
+template <class T><br>
+struct Foo {<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function(); // expected-note{{forward declaration of template entity is here}}<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function(); // expected-note{{forward declaration of template entity is here}}<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member; // expected-note{{forward declaration of template entity is here}}<br>
+  struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION nested {<br>
+    static int static_member_function(); // expected-note{{forward declaration of template entity is here}}<br>
+  };<br>
+};<br>
+<br>
+extern template struct Foo<int>;<br>
+<br>
+void use() {<br>
+  Foo<int> foo;<br>
+<br>
+  foo.non_static_member_function(); // expected-warning{{instantiation of function 'Foo<int>::non_static_member_function' required here, but no definition is available}}<br>
+  // expected-note@-1 {{add an explicit instantiation}}<br>
+<br>
+  Foo<int>::static_member_function(); // expected-warning{{instantiation of function 'Foo<int>::static_member_function' required here, but no definition is available}}<br>
+  // expected-note@-1 {{add an explicit instantiation}}<br>
+<br>
+  (void)Foo<int>::static_data_member; // expected-warning{{instantiation of variable 'Foo<int>::static_data_member' required here, but no definition is available}}<br>
+  // expected-note@-1 {{add an explicit instantiation}}<br>
+<br>
+  Foo<int>::nested::static_member_function(); // expected-warning{{instantiation of function 'Foo<int>::nested::static_member_function' required here, but no definition is available}}<br>
+  // expected-note@-1 {{add an explicit instantiation}}<br>
+}<br>
<br>
Added: cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp?rev=343790&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp?rev=343790&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.explicit_instantiation.cpp Thu Oct  4 08:49:42 2018<br>
@@ -0,0 +1,45 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+<br>
+// Test that explicit instantiations do not instantiate entities<br>
+// marked with the exclude_from_explicit_instantiation attribute.<br>
+<br>
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))<br>
+<br>
+template <class T><br>
+struct Foo {<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void non_static_member_function1();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function2();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static inline void static_member_function1();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function2();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member;<br>
+<br>
+  struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION member_class1 {<br>
+    static void non_static_member_function() { using Fail = typename T::fail; }<br>
+  };<br>
+<br>
+  struct member_class2 {<br>
+    EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void non_static_member_function() { using Fail = typename T::fail; }<br>
+  };<br>
+};<br>
+<br>
+template <class T><br>
+inline void Foo<T>::non_static_member_function1() { using Fail = typename T::fail; }<br>
+<br>
+template <class T><br>
+void Foo<T>::non_static_member_function2() { using Fail = typename T::fail; }<br>
+<br>
+template <class T><br>
+inline void Foo<T>::static_member_function1() { using Fail = typename T::fail; }<br>
+<br>
+template <class T><br>
+void Foo<T>::static_member_function2() { using Fail = typename T::fail; }<br>
+<br>
+template <class T><br>
+int Foo<T>::static_data_member = T::fail;<br>
+<br>
+// expected-no-diagnostics<br>
+template struct Foo<int>;<br>
<br>
Added: cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp?rev=343790&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp?rev=343790&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.extern_declaration.cpp Thu Oct  4 08:49:42 2018<br>
@@ -0,0 +1,69 @@<br>
+// RUN: %clang_cc1 -Wno-unused-local-typedef -fsyntax-only -verify %s<br>
+<br>
+// Test that extern instantiation declarations cause members marked with<br>
+// the exclude_from_explicit_instantiation attribute to be instantiated in<br>
+// the current TU.<br>
+<br>
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))<br>
+<br>
+template <class T><br>
+struct Foo {<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void non_static_member_function1();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void non_static_member_function2();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static inline void static_member_function1();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function2();<br>
+<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION static int static_data_member;<br>
+<br>
+  struct EXCLUDE_FROM_EXPLICIT_INSTANTIATION member_class1 {<br>
+    static void static_member_function() {<br>
+      using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+    }<br>
+  };<br>
+<br>
+  struct member_class2 {<br>
+    EXCLUDE_FROM_EXPLICIT_INSTANTIATION static void static_member_function() {<br>
+      using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+    }<br>
+  };<br>
+};<br>
+<br>
+template <class T><br>
+inline void Foo<T>::non_static_member_function1() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+template <class T><br>
+void Foo<T>::non_static_member_function2() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+template <class T><br>
+inline void Foo<T>::static_member_function1() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+template <class T><br>
+void Foo<T>::static_member_function2() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+template <class T><br>
+int Foo<T>::static_data_member = T::invalid; // expected-error{{no member named 'invalid' in 'Empty'}}<br>
+<br>
+struct Empty { };<br>
+extern template struct Foo<Empty>;<br>
+<br>
+int main() {<br>
+  Foo<Empty> foo;<br>
+  foo.non_static_member_function1();                   // expected-note{{in instantiation of}}<br>
+  foo.non_static_member_function2();                   // expected-note{{in instantiation of}}<br>
+  Foo<Empty>::static_member_function1();               // expected-note{{in instantiation of}}<br>
+  Foo<Empty>::static_member_function2();               // expected-note{{in instantiation of}}<br>
+  (void)foo.static_data_member;                        // expected-note{{in instantiation of}}<br>
+  Foo<Empty>::member_class1::static_member_function(); // expected-note{{in instantiation of}}<br>
+  Foo<Empty>::member_class2::static_member_function(); // expected-note{{in instantiation of}}<br>
+}<br>
<br>
Added: cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp?rev=343790&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp?rev=343790&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp (added)<br>
+++ cfe/trunk/test/SemaCXX/attr-exclude_from_explicit_instantiation.merge_redeclarations.cpp Thu Oct  4 08:49:42 2018<br>
@@ -0,0 +1,43 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+<br>
+// Test that we properly merge the exclude_from_explicit_instantiation<br>
+// attribute on redeclarations.<br>
+<br>
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))<br>
+<br>
+template <class T><br>
+struct Foo {<br>
+  // Declaration without the attribute, definition with the attribute.<br>
+  void func1();<br>
+<br>
+  // Declaration with the attribute, definition without the attribute.<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void func2();<br>
+<br>
+  // Declaration with the attribute, definition with the attribute.<br>
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void func3();<br>
+};<br>
+<br>
+template <class T><br>
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION void Foo<T>::func1() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+template <class T><br>
+void Foo<T>::func2() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+template <class T><br>
+EXCLUDE_FROM_EXPLICIT_INSTANTIATION void Foo<T>::func3() {<br>
+  using Fail = typename T::invalid; // expected-error{{no type named 'invalid' in 'Empty'}}<br>
+}<br>
+<br>
+struct Empty { };<br>
+extern template struct Foo<Empty>;<br>
+<br>
+int main() {<br>
+  Foo<Empty> foo;<br>
+  foo.func1(); // expected-note{{in instantiation of}}<br>
+  foo.func2(); // expected-note{{in instantiation of}}<br>
+  foo.func3(); // expected-note{{in instantiation of}}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>