summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateStmt.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-15 18:53:42 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-15 18:53:42 +0000
commit9d73cabf22b970ec47eaae9b01ca55430f426618 (patch)
tree8e5c9800342159075873a353429e0c63672a0f62 /clang/lib/Sema/SemaTemplateInstantiateStmt.cpp
parenta3d4d7b4fa31f38ffb9f7709de3ebcdbd54ad88b (diff)
downloadbcm5719-llvm-9d73cabf22b970ec47eaae9b01ca55430f426618.tar.gz
bcm5719-llvm-9d73cabf22b970ec47eaae9b01ca55430f426618.zip
Template instantiation for "if" statements. Also:
- Skip semantic analysis of the "if" condition if it is type-dependent. - Added the location of the "else" keyword into IfStmt, so that we can provide it for type-checking after template instantiation. llvm-svn: 71875
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateStmt.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateStmt.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateStmt.cpp b/clang/lib/Sema/SemaTemplateInstantiateStmt.cpp
index cbe4449efcd..957402ac6f6 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateStmt.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateStmt.cpp
@@ -39,6 +39,7 @@ namespace {
OwningStmtResult VisitDeclStmt(DeclStmt *S);
OwningStmtResult VisitNullStmt(NullStmt *S);
OwningStmtResult VisitCompoundStmt(CompoundStmt *S);
+ OwningStmtResult VisitIfStmt(IfStmt *S);
OwningStmtResult VisitExpr(Expr *E);
OwningStmtResult VisitLabelStmt(LabelStmt *S);
OwningStmtResult VisitGotoStmt(GotoStmt *S);
@@ -135,6 +136,26 @@ TemplateStmtInstantiator::VisitCompoundStmt(CompoundStmt *S) {
S->getRBracLoc()));
}
+Sema::OwningStmtResult TemplateStmtInstantiator::VisitIfStmt(IfStmt *S) {
+ // Instantiate the condition
+ OwningExprResult Cond = SemaRef.InstantiateExpr(S->getCond(), TemplateArgs);
+ if (Cond.isInvalid())
+ return SemaRef.StmtError();
+
+ // Instantiate the "then" branch.
+ OwningStmtResult Then = SemaRef.InstantiateStmt(S->getThen(), TemplateArgs);
+ if (Then.isInvalid())
+ return SemaRef.StmtError();
+
+ // Instantiate the "else" branch.
+ OwningStmtResult Else = SemaRef.InstantiateStmt(S->getElse(), TemplateArgs);
+ if (Else.isInvalid())
+ return SemaRef.StmtError();
+
+ return SemaRef.ActOnIfStmt(S->getIfLoc(), move(Cond), move(Then),
+ S->getElseLoc(), move(Else));
+}
+
Sema::OwningStmtResult TemplateStmtInstantiator::VisitExpr(Expr *E) {
Sema::OwningExprResult Result = SemaRef.InstantiateExpr(E, TemplateArgs);
if (Result.isInvalid())
OpenPOWER on IntegriCloud