aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/DeclTemplate.h9
-rw-r--r--lib/AST/DeclTemplate.cpp14
-rw-r--r--lib/Sema/SemaTemplate.cpp2
3 files changed, 17 insertions, 8 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 89eb152e85..2a3e8add14 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -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();
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index fe17399155..5317c7bff6 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -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())
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 5c908a00f6..91ef67e1c9 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -4349,7 +4349,7 @@ Sema::CheckFunctionTemplateSpecialization(FunctionDecl *FD,
// specialization.
FD->setFunctionTemplateSpecialization(Specialization->getPrimaryTemplate(),
new (Context) TemplateArgumentList(
- *Specialization->getTemplateSpecializationArgs()),
+ Specialization->getTemplateSpecializationArgs()),
/*InsertPos=*/0,
SpecInfo->getTemplateSpecializationKind());