[cfe-commits] r104192 - in /cfe/trunk: include/clang/AST/DeclTemplate.h lib/AST/DeclTemplate.cpp lib/Sema/SemaTemplate.cpp
Chris Lattner
sabre at nondot.org
Wed May 19 17:19:09 PDT 2010
Author: lattner
Date: Wed May 19 19:19:09 2010
New Revision: 104192
URL: http://llvm.org/viewvc/llvm-project?rev=104192&view=rev
Log:
fix the TemplateArgumentList copy constructor to not
be a copy constructor (since it isn't one semantically)
and fix the ownership bits it sets to be correct!
Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=104192&r1=104191&r2=104192&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Wed May 19 19:19:09 2010
@@ -173,6 +173,8 @@
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 @@
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();
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=104192&r1=104191&r2=104192&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Wed May 19 19:19:09 2010
@@ -386,11 +386,15 @@
}
}
-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())
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=104192&r1=104191&r2=104192&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed May 19 19:19:09 2010
@@ -4349,7 +4349,7 @@
// specialization.
FD->setFunctionTemplateSpecialization(Specialization->getPrimaryTemplate(),
new (Context) TemplateArgumentList(
- *Specialization->getTemplateSpecializationArgs()),
+ Specialization->getTemplateSpecializationArgs()),
/*InsertPos=*/0,
SpecInfo->getTemplateSpecializationKind());
More information about the cfe-commits
mailing list