[PATCH] Parse: Template specializations which aren't dependent needn't have their parsing be delayed

David Majnemer david.majnemer at gmail.com
Fri Aug 30 00:57:48 PDT 2013


Hi rsmith,

We should treat a non-dependent template specialization like it wasn't
templated at all.

http://llvm-reviews.chandlerc.com/D1554

Files:
  lib/Parse/ParseCXXInlineMethods.cpp
  test/CodeGenCXX/delayed-template-parsing.cpp

Index: lib/Parse/ParseCXXInlineMethods.cpp
===================================================================
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -113,11 +113,12 @@
   // In delayed template parsing mode, if we are within a class template
   // or if we are about to parse function member template then consume
   // the tokens and store them for parsing at the end of the translation unit.
-  if (getLangOpts().DelayedTemplateParsing && 
-      DefinitionKind == FDK_Definition && 
+  if (getLangOpts().DelayedTemplateParsing &&
+      DefinitionKind == FDK_Definition &&
       ((Actions.CurContext->isDependentContext() ||
-        TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) && 
-        !Actions.IsInsideALocalClassWithinATemplateFunction())) {
+        (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
+         TemplateInfo.Kind != ParsedTemplateInfo::ExplicitSpecialization)) &&
+       !Actions.IsInsideALocalClassWithinATemplateFunction())) {
 
     CachedTokens Toks;
     LexTemplateFunctionForLateParsing(Toks);
Index: test/CodeGenCXX/delayed-template-parsing.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/delayed-template-parsing.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=i386-pc-win32 | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -cxx-abi microsoft -fms-extensions -fdelayed-template-parsing -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s
+
+namespace ClassScopeSpecialization {
+  struct Type {
+    template <int i>
+    void Foo() {}
+    template <>
+    void Foo<0>() {}
+  };
+
+  void call() {
+    Type T;
+// CHECK: call {{.*}} @"\01??$Foo@$0A@@Type at ClassScopeSpecialization@@QAEXXZ"
+// X64: call {{.*}} @"\01??$Foo@$0A@@Type at ClassScopeSpecialization@@QEAAXXZ"
+    T.Foo<0>();
+  }
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1554.1.patch
Type: text/x-patch
Size: 1966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130830/e4730389/attachment.bin>


More information about the cfe-commits mailing list