[llvm-branch-commits] [cfe-branch] r182150 - Merging r182072:

Bill Wendling isanbard at gmail.com
Fri May 17 11:52:50 PDT 2013


Author: void
Date: Fri May 17 13:52:50 2013
New Revision: 182150

URL: http://llvm.org/viewvc/llvm-project?rev=182150&view=rev
Log:
Merging r182072:
------------------------------------------------------------------------
r182072 | rsmith | 2013-05-16 19:19:35 -0700 (Thu, 16 May 2013) | 6 lines

PR15757: When we instantiate an inheriting constructor template, also
instantiate the inherited constructor template and mark that as the constructor
which the instantiated specialization is inheriting. This fixes a
crash-on-valid when trying to compute the exception specification of a
specialization of the inheriting constructor.

------------------------------------------------------------------------

Added:
    cfe/branches/release_33/test/SemaCXX/cxx11-inheriting-ctors.cpp
      - copied unchanged from r182072, cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
Modified:
    cfe/branches/release_33/   (props changed)
    cfe/branches/release_33/include/clang/Sema/Template.h
    cfe/branches/release_33/lib/Sema/SemaTemplateInstantiateDecl.cpp

Propchange: cfe/branches/release_33/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 17 13:52:50 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:181286,181299,181368,181465,181728,181750,181909
+/cfe/trunk:181286,181299,181368,181465,181728,181750,181909,182072
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_33/include/clang/Sema/Template.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_33/include/clang/Sema/Template.h?rev=182150&r1=182149&r2=182150&view=diff
==============================================================================
--- cfe/branches/release_33/include/clang/Sema/Template.h (original)
+++ cfe/branches/release_33/include/clang/Sema/Template.h Fri May 17 13:52:50 2013
@@ -94,17 +94,23 @@ namespace clang {
     /// \brief Add a new outermost level to the multi-level template argument 
     /// list.
     void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs) {
-      TemplateArgumentLists.push_back(ArgList(TemplateArgs->data(),
-                                              TemplateArgs->size()));
+      addOuterTemplateArguments(ArgList(TemplateArgs->data(),
+                                        TemplateArgs->size()));
     }
     
     /// \brief Add a new outmost level to the multi-level template argument
     /// list.
     void addOuterTemplateArguments(const TemplateArgument *Args, 
                                    unsigned NumArgs) {
-      TemplateArgumentLists.push_back(ArgList(Args, NumArgs));
+      addOuterTemplateArguments(ArgList(Args, NumArgs));
     }
-    
+
+    /// \brief Add a new outmost level to the multi-level template argument
+    /// list.
+    void addOuterTemplateArguments(ArgList Args) {
+      TemplateArgumentLists.push_back(Args);
+    }
+
     /// \brief Retrieve the innermost template argument list.
     const ArgList &getInnermost() const { 
       return TemplateArgumentLists.front(); 

Modified: cfe/branches/release_33/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_33/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=182150&r1=182149&r2=182150&view=diff
==============================================================================
--- cfe/branches/release_33/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/branches/release_33/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri May 17 13:52:50 2013
@@ -1558,10 +1558,36 @@ TemplateDeclInstantiator::VisitCXXMethod
                                         Constructor->isExplicit(),
                                         Constructor->isInlineSpecified(),
                                         false, Constructor->isConstexpr());
+
     // Claim that the instantiation of a constructor or constructor template
     // inherits the same constructor that the template does.
-    if (const CXXConstructorDecl *Inh = Constructor->getInheritedConstructor())
+    if (CXXConstructorDecl *Inh = const_cast<CXXConstructorDecl *>(
+            Constructor->getInheritedConstructor())) {
+      // If we're instantiating a specialization of a function template, our
+      // "inherited constructor" will actually itself be a function template.
+      // Instantiate a declaration of it, too.
+      if (FunctionTemplate) {
+        assert(!TemplateParams && Inh->getDescribedFunctionTemplate() &&
+               !Inh->getParent()->isDependentContext() &&
+               "inheriting constructor template in dependent context?");
+        Sema::InstantiatingTemplate Inst(SemaRef, Constructor->getLocation(),
+                                         Inh);
+        if (Inst)
+          return 0;
+        Sema::ContextRAII SavedContext(SemaRef, Inh->getDeclContext());
+        LocalInstantiationScope LocalScope(SemaRef);
+
+        // Use the same template arguments that we deduced for the inheriting
+        // constructor. There's no way they could be deduced differently.
+        MultiLevelTemplateArgumentList InheritedArgs;
+        InheritedArgs.addOuterTemplateArguments(TemplateArgs.getInnermost());
+        Inh = cast_or_null<CXXConstructorDecl>(
+            SemaRef.SubstDecl(Inh, Inh->getDeclContext(), InheritedArgs));
+        if (!Inh)
+          return 0;
+      }
       cast<CXXConstructorDecl>(Method)->setInheritedConstructor(Inh);
+    }
   } else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) {
     Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
                                        StartLoc, NameInfo, T, TInfo,





More information about the llvm-branch-commits mailing list