]> granicus.if.org Git - clang/commitdiff
fix the TemplateArgumentList copy constructor to not
authorChris Lattner <sabre@nondot.org>
Thu, 20 May 2010 00:19:09 +0000 (00:19 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 20 May 2010 00:19:09 +0000 (00:19 +0000)
be a copy constructor (since it isn't one semantically)
and fix the ownership bits it sets to be correct!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104192 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclTemplate.h
lib/AST/DeclTemplate.cpp
lib/Sema/SemaTemplate.cpp

index 89eb152e857f6bc57d1d2c01e588f01e17501a83..2a3e8add145ff630970c41901b3e6a511d0c4689 100644 (file)
@@ -173,6 +173,8 @@ class TemplateArgumentList {
   llvm::PointerIntPair<const TemplateArgument *, 1> StructuredArguments;
   unsigned NumStructuredArguments;
 
+  TemplateArgumentList(const TemplateArgumentList &Other); // DO NOT IMPL
+  void operator=(const TemplateArgumentList &Other); // DO NOT IMPL
 public:
   /// TemplateArgumentList - If this constructor is passed "true" for 'TakeArgs'
   /// it copies them into a locally new[]'d array.  If passed "false", then it
@@ -182,8 +184,11 @@ public:
                        TemplateArgumentListBuilder &Builder,
                        bool TakeArgs);
 
-  /// \brief Produces a shallow copy of the given template argument list
-  TemplateArgumentList(const TemplateArgumentList &Other);
+  /// Produces a shallow copy of the given template argument list.  This
+  /// assumes that the input argument list outlives it.  This takes the list as
+  /// a pointer to avoid looking like a copy constructor, since this really
+  /// really isn't safe to use that way.
+  explicit TemplateArgumentList(const TemplateArgumentList *Other);
   
   ~TemplateArgumentList();
 
index fe173991559c542eb5aabece4bd7c97a5609ec6b..5317c7bff6ef9506dae22d8c8fdcc4b4ab7c14be 100644 (file)
@@ -386,11 +386,15 @@ TemplateArgumentList::TemplateArgumentList(ASTContext &Context,
   }
 }
 
-TemplateArgumentList::TemplateArgumentList(const TemplateArgumentList &Other)
-  : FlatArguments(Other.FlatArguments.getPointer(), 1),
-    NumFlatArguments(Other.flat_size()),
-    StructuredArguments(Other.StructuredArguments.getPointer(), 1),
-    NumStructuredArguments(Other.NumStructuredArguments) { }
+/// Produces a shallow copy of the given template argument list.  This
+/// assumes that the input argument list outlives it.  This takes the list as
+/// a pointer to avoid looking like a copy constructor, since this really
+/// really isn't safe to use that way.
+TemplateArgumentList::TemplateArgumentList(const TemplateArgumentList *Other)
+  : FlatArguments(Other->FlatArguments.getPointer(), false),
+    NumFlatArguments(Other->flat_size()),
+    StructuredArguments(Other->StructuredArguments.getPointer(), false),
+    NumStructuredArguments(Other->NumStructuredArguments) { }
 
 TemplateArgumentList::~TemplateArgumentList() {
   if (FlatArguments.getInt())
index 5c908a00f681b35d6065b73b2e64fa508e63dd48..91ef67e1c9a1e00893e37a9a8ee08149cc55135b 100644 (file)
@@ -4349,7 +4349,7 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD,
   // specialization.
   FD->setFunctionTemplateSpecialization(Specialization->getPrimaryTemplate(),
                          new (Context) TemplateArgumentList(
-                             *Specialization->getTemplateSpecializationArgs()), 
+                             Specialization->getTemplateSpecializationArgs()), 
                                         /*InsertPos=*/0, 
                                     SpecInfo->getTemplateSpecializationKind());