[cfe-commits] r72031 - /cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
Douglas Gregor
dgregor at apple.com
Mon May 18 12:08:48 PDT 2009
Author: dgregor
Date: Mon May 18 14:08:47 2009
New Revision: 72031
URL: http://llvm.org/viewvc/llvm-project?rev=72031&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp?rev=72031&r1=72030&r2=72031&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp Mon May 18 14:08:47 2009
@@ -38,26 +38,14 @@
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 @@
};
}
+//===----------------------------------------------------------------------===/
+// Common/C statements
+//===----------------------------------------------------------------------===/
Sema::OwningStmtResult TemplateStmtInstantiator::VisitDeclStmt(DeclStmt *S) {
llvm::SmallVector<Decl *, 8> Decls;
for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
@@ -170,6 +161,12 @@
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 @@
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())
More information about the cfe-commits
mailing list