diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-06-29 20:59:39 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-06-29 20:59:39 +0000 |
commit | 127102b5196ffe04bdb70fd553fe62c265ab10a9 (patch) | |
tree | 04e917cd6dba09eebeafa02b274519f444ac5ab8 /lib/Sema/SemaTemplateDeduction.cpp | |
parent | f7b8eec37c8c8012fa525c71fb29a58c9f29beef (diff) |
Keep track of function template specializations, to eliminate
redundant, implicit instantiations of function templates and provide a
place where we can hang function template specializations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index 3d909bb26a..5300385540 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -1036,14 +1036,22 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, InstantiateDecl(FunctionTemplate->getTemplatedDecl(), FunctionTemplate->getDeclContext(), *DeducedArgumentList)); + if (!Specialization) + return TDK_SubstitutionFailure; - if (!Specialization || Trap.hasErrorOccurred()) + // If the template argument list is owned by the function template + // specialization, release it. + if (Specialization->getTemplateSpecializationArgs() == DeducedArgumentList) + Info.take(); + + // There may have been an error that did not prevent us from constructing a + // declaration. Mark the declaration invalid and return with a substitution + // failure. + if (Trap.hasErrorOccurred()) { + Specialization->setInvalidDecl(true); return TDK_SubstitutionFailure; - - // Turn the specialization into an actual function template specialization. - Specialization->setFunctionTemplateSpecialization(Context, - FunctionTemplate, - Info.take()); + } + return TDK_Success; } |