[PATCH] D51789: [clang] Add the exclude_from_explicit_instantiation attribute

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 14 17:44:53 PDT 2018


rsmith added a comment.

Looks good other than the warning, which I don't yet understand.



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4683-4686
+  "Member '%0' marked with 'exclude_from_explicit_instantiation' attribute is "
+  "not defined but an explicit template instantiation declaration exists. "
+  "Reliance on this member being defined by an explicit template instantiation "
+  "will lead to link errors.">;
----------------
Diagnostics should start with a lowercase letter and not end with a period.

That said, I'm not sure I see why this diagnostic is correct / useful. If the entity is never used, then there's no link error. And if it is ever used, then you should get an implicit instantiation like normal, and we already have a diagnostic for the case where an entity is implicitly instantiated and no definition is available.


================
Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2581-2582
+        if (Function->hasAttr<ExcludeFromExplicitInstantiationAttr>()) {
+          if (TSK == TSK_ExplicitInstantiationDeclaration &&
+                                                      !Pattern->isDefined()) {
+            Diag(Function->getLocation(),
----------------
Nit: we prefer to left-align continuation lines (clang-format will do that for you).


Repository:
  rC Clang

https://reviews.llvm.org/D51789





More information about the cfe-commits mailing list