summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
diff options
context:
space:
mode:
authorAlexis Hunt <alercah@gmail.com>2011-05-23 23:14:04 +0000
committerAlexis Hunt <alercah@gmail.com>2011-05-23 23:14:04 +0000
commit61ae8d395e9d96d8cae82372abd0c2b2c1f8c3eb (patch)
tree29f991839cafec0a35c1eb7c9e0c98e33b8ca5fc /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
parent1254f6efe24f5f65fc2dd419eaf81565d79b0c9e (diff)
downloadbcm5719-llvm-61ae8d395e9d96d8cae82372abd0c2b2c1f8c3eb.tar.gz
bcm5719-llvm-61ae8d395e9d96d8cae82372abd0c2b2c1f8c3eb.zip
Implement explicit specialization of explicitly-defaulted constructors.
The general out-of-line case (including explicit instantiation mostly works except that the definition is being lost somewhere between the AST and CodeGen, so the definition is never emitted. llvm-svn: 131933
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index fb34d9f1dad..2481bd004dc 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2320,6 +2320,9 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
Stmt *Pattern = 0;
if (PatternDecl)
Pattern = PatternDecl->getBody(PatternDecl);
+ if (!Pattern)
+ // Try to find a defaulted definition
+ PatternDecl->isDefined(PatternDecl);
// Postpone late parsed template instantiations.
if (PatternDecl && PatternDecl->isLateTemplateParsed() &&
@@ -2337,7 +2340,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
Pattern = PatternDecl->getBody(PatternDecl);
}
- if (!Pattern) {
+ if (!Pattern && !PatternDecl->isDefaulted()) {
if (DefinitionRequired) {
if (Function->getPrimaryTemplate())
Diag(PointOfInstantiation,
@@ -2432,21 +2435,29 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
MultiLevelTemplateArgumentList TemplateArgs =
getTemplateInstantiationArgs(Function, 0, false, PatternDecl);
- // If this is a constructor, instantiate the member initializers.
- if (const CXXConstructorDecl *Ctor =
- dyn_cast<CXXConstructorDecl>(PatternDecl)) {
- InstantiateMemInitializers(cast<CXXConstructorDecl>(Function), Ctor,
- TemplateArgs);
- }
+ if (PatternDecl->isDefaulted()) {
+ ActOnFinishFunctionBody(Function, 0, /*IsInstantiation=*/true);
- // Instantiate the function body.
- StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+ SetDeclDefaulted(Function, PatternDecl->getLocation());
- if (Body.isInvalid())
- Function->setInvalidDecl();
-
- ActOnFinishFunctionBody(Function, Body.get(),
- /*IsInstantiation=*/true);
+ return;
+ } else {
+ // If this is a constructor, instantiate the member initializers.
+ if (const CXXConstructorDecl *Ctor =
+ dyn_cast<CXXConstructorDecl>(PatternDecl)) {
+ InstantiateMemInitializers(cast<CXXConstructorDecl>(Function), Ctor,
+ TemplateArgs);
+ }
+
+ // Instantiate the function body.
+ StmtResult Body = SubstStmt(Pattern, TemplateArgs);
+
+ if (Body.isInvalid())
+ Function->setInvalidDecl();
+
+ ActOnFinishFunctionBody(Function, Body.get(),
+ /*IsInstantiation=*/true);
+ }
PerformDependentDiagnostics(PatternDecl, TemplateArgs);
OpenPOWER on IntegriCloud