[PATCH] D52521: [Sema] DR727: Ensure we pick up enclosing template instantiation arguments for a class-scope explicit specialization.

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 4 12:50:44 PDT 2018


erik.pilkington added inline comments.


================
Comment at: clang/include/clang/AST/DeclTemplate.h:1771-1779
+  void setIsSpecializedMember(bool V = true) { IsSpecializedMember = V; }
+
+  /// If this class template specialization was declared at class scope (DR727).
+  /// For example, the specialization G<int> below:
+  ///   struct S {
+  ///     template <class> struct G {};
+  ///     template <> struct G<int> {};
----------------
rsmith wrote:
> I think this name is confusing, given that we also have `isMemberSpecialization`, which is an entirely different thing.
> 
> Maybe `isInstantiatedSpecialization` would capture the essence here? (That is, this is a partial or explicit specialization that we instantiated from its enclosing template context rather than one that was declared in a non-template context.)
> 
> That also makes me wonder if we need to store additional state for this at all, or if we can determine this by checking whether the (first) declaration `isOutOfLine()`.
> Maybe isInstantiatedSpecialization would capture the essence here? (That is, this is a partial or explicit specialization that we instantiated from its enclosing template context rather than one that was declared in a non-template context.)

But we should still probably return true for a specialization in a non-template class even though it wasn't instantiated (it doesn't really matter here, but for consistency). The new patch calls this `isClassScopeSpecialization`, what do you think of that name?

> That also makes me wonder if we need to store additional state for this at all, or if we can determine this by checking whether the (first) declaration isOutOfLine().

Oh, good point! I think that would work too.


Repository:
  rC Clang

https://reviews.llvm.org/D52521





More information about the cfe-commits mailing list