From 68d10c47c50ad7e866db4cc035ad5ff4555593c2 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 18 May 2009 19:08:47 +0000 Subject: [PATCH] Include StmtNodes.def to declare Visit methods for all of the known kinds of statements (in the instantiation logic). No functionality change, but now we'll get linker errors if we add a statement but forget to introduce its instantiation logic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72031 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateInstantiateStmt.cpp | 106 +++++++++++++++++++---- 1 file changed, 87 insertions(+), 19 deletions(-) diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp index 938e58b8fd..a8dd6c194c 100644 --- a/lib/Sema/SemaTemplateInstantiateStmt.cpp +++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp @@ -38,26 +38,14 @@ namespace { const TemplateArgumentList &TemplateArgs) : SemaRef(SemaRef), TemplateArgs(TemplateArgs) { } - // FIXME: Once we get closer to completion, replace these manually-written - // declarations with automatically-generated ones from - // clang/AST/StmtNodes.def. - OwningStmtResult VisitDeclStmt(DeclStmt *S); - OwningStmtResult VisitNullStmt(NullStmt *S); - OwningStmtResult VisitCompoundStmt(CompoundStmt *S); - OwningStmtResult VisitCaseStmt(CaseStmt *S); - OwningStmtResult VisitDefaultStmt(DefaultStmt *S); - OwningStmtResult VisitIfStmt(IfStmt *S); - OwningStmtResult VisitSwitchStmt(SwitchStmt *S); - OwningStmtResult VisitWhileStmt(WhileStmt *S); - OwningStmtResult VisitDoStmt(DoStmt *S); - OwningStmtResult VisitForStmt(ForStmt *S); + // Declare VisitXXXStmt nodes for all of the statement kinds. +#define STMT(Type, Base) OwningStmtResult Visit##Type(Type *S); +#define EXPR(Type, Base) +#include "clang/AST/StmtNodes.def" + + // Visit an expression (which will use the expression + // instantiator). OwningStmtResult VisitExpr(Expr *E); - OwningStmtResult VisitLabelStmt(LabelStmt *S); - OwningStmtResult VisitGotoStmt(GotoStmt *S); - OwningStmtResult VisitIndirectGotoStmt(IndirectGotoStmt *S); - OwningStmtResult VisitBreakStmt(BreakStmt *S); - OwningStmtResult VisitContinueStmt(ContinueStmt *S); - OwningStmtResult VisitReturnStmt(ReturnStmt *S); // Base case. I'm supposed to ignore this. OwningStmtResult VisitStmt(Stmt *S) { @@ -68,6 +56,9 @@ namespace { }; } +//===----------------------------------------------------------------------===/ +// Common/C statements +//===----------------------------------------------------------------------===/ Sema::OwningStmtResult TemplateStmtInstantiator::VisitDeclStmt(DeclStmt *S) { llvm::SmallVector Decls; for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end(); @@ -170,6 +161,12 @@ TemplateStmtInstantiator::VisitCompoundStmt(CompoundStmt *S) { S->getRBracLoc())); } +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitSwitchCase(SwitchCase *S) { + assert(false && "SwitchCase statements are never directly instantiated"); + return SemaRef.StmtError(); +} + Sema::OwningStmtResult TemplateStmtInstantiator::VisitCaseStmt(CaseStmt *S) { // Instantiate left-hand case value. OwningExprResult LHS = SemaRef.InstantiateExpr(S->getLHS(), TemplateArgs); @@ -311,6 +308,77 @@ Sema::OwningStmtResult TemplateStmtInstantiator::VisitForStmt(ForStmt *S) { S->getRParenLoc(), move(Body)); } +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitAsmStmt(AsmStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an 'asm' statement"); + return SemaRef.StmtError(); +} + +//===----------------------------------------------------------------------===/ +// C++ statements +//===----------------------------------------------------------------------===/ +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitCXXTryStmt(CXXTryStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate a C++ try statement"); + return SemaRef.StmtError(); +} + +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitCXXCatchStmt(CXXCatchStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate a C++ catch statement"); + return SemaRef.StmtError(); +} + +//===----------------------------------------------------------------------===/ +// Objective-C statements +//===----------------------------------------------------------------------===/ +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an Objective-C @finally statement"); + return SemaRef.StmtError(); +} + +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitObjCAtSynchronizedStmt( + ObjCAtSynchronizedStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an Objective-C @synchronized statement"); + return SemaRef.StmtError(); +} + +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an Objective-C @try statement"); + return SemaRef.StmtError(); +} + +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitObjCForCollectionStmt( + ObjCForCollectionStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an Objective-C \"for\" statement"); + return SemaRef.StmtError(); +} + +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an Objective-C @throw statement"); + return SemaRef.StmtError(); +} + +Sema::OwningStmtResult +TemplateStmtInstantiator::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { + // FIXME: Implement this + assert(false && "Cannot instantiate an Objective-C @catch statement"); + return SemaRef.StmtError(); +} + Sema::OwningStmtResult TemplateStmtInstantiator::VisitExpr(Expr *E) { Sema::OwningExprResult Result = SemaRef.InstantiateExpr(E, TemplateArgs); if (Result.isInvalid()) -- 2.40.0