[cfe-commits] r39121 - in /cfe/cfe/trunk: AST/Sema.cpp AST/Sema.h AST/StmtPrinter.cpp Sema/Sema.cpp Sema/Sema.h include/clang/AST/Stmt.h include/clang/AST/StmtNodes.def include/clang/Parse/Action.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:27:44 PDT 2007
Author: sabre
Date: Wed Jul 11 11:27:44 2007
New Revision: 39121
URL: http://llvm.org/viewvc/llvm-project?rev=39121&view=rev
Log:
build ast nodes and print goto/goto*/break/continue.
Modified:
cfe/cfe/trunk/AST/Sema.cpp
cfe/cfe/trunk/AST/Sema.h
cfe/cfe/trunk/AST/StmtPrinter.cpp
cfe/cfe/trunk/Sema/Sema.cpp
cfe/cfe/trunk/Sema/Sema.h
cfe/cfe/trunk/include/clang/AST/Stmt.h
cfe/cfe/trunk/include/clang/AST/StmtNodes.def
cfe/cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/cfe/trunk/AST/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.cpp?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:27:44 2007
@@ -130,13 +130,6 @@
return new SwitchStmt((Expr*)Cond, (Stmt*)Body);
}
-Action::StmtResult
-ASTBuilder::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second, ExprTy *Third,
- SourceLocation RParenLoc, StmtTy *Body) {
- return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
-}
-
Action::StmtResult
ASTBuilder::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body){
return new WhileStmt((Expr*)Cond, (Stmt*)Body);
@@ -148,6 +141,36 @@
return new DoStmt((Stmt*)Body, (Expr*)Cond);
}
+Action::StmtResult
+ASTBuilder::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
+ StmtTy *First, ExprTy *Second, ExprTy *Third,
+ SourceLocation RParenLoc, StmtTy *Body) {
+ return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
+}
+
+
+Action::StmtResult
+ASTBuilder::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
+ IdentifierInfo *LabelII) {
+ return new GotoStmt(LabelII);
+}
+Action::StmtResult
+ASTBuilder::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
+ ExprTy *DestExp) {
+ return new IndirectGotoStmt((Expr*)DestExp);
+}
+
+Action::StmtResult
+ASTBuilder::ParseContinueStmt(SourceLocation ContinueLoc) {
+ return new ContinueStmt();
+}
+
+Action::StmtResult
+ASTBuilder::ParseBreakStmt(SourceLocation GotoLoc) {
+ return new BreakStmt();
+}
+
+
Action::StmtResult
ASTBuilder::ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp) {
Modified: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (original)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:27:44 2007
@@ -77,6 +77,14 @@
SourceLocation LParenLoc,
StmtTy *First, ExprTy *Second, ExprTy *Third,
SourceLocation RParenLoc, StmtTy *Body);
+ virtual StmtResult ParseGotoStmt(SourceLocation GotoLoc,
+ SourceLocation LabelLoc,
+ IdentifierInfo *LabelII);
+ virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
+ SourceLocation StarLoc,
+ ExprTy *DestExp);
+ virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc);
+ virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc);
virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
Modified: cfe/cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/StmtPrinter.cpp?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/cfe/trunk/AST/StmtPrinter.cpp Wed Jul 11 11:27:44 2007
@@ -174,6 +174,25 @@
PrintStmt(Node->getBody());
}
+void StmtPrinter::VisitGotoStmt(GotoStmt *Node) {
+ Indent() << "goto " << Node->getLabel()->getName() << "\n";
+}
+
+void StmtPrinter::VisitIndirectGotoStmt(IndirectGotoStmt *Node) {
+ Indent() << "goto ";
+ PrintExpr(Node->getTarget());
+ OS << "\n";
+}
+
+void StmtPrinter::VisitContinueStmt(ContinueStmt *Node) {
+ Indent() << "continue\n";
+}
+
+void StmtPrinter::VisitBreakStmt(BreakStmt *Node) {
+ Indent() << "break\n";
+}
+
+
void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
Indent() << "return";
if (Node->getRetValue()) {
Modified: cfe/cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.cpp?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:27:44 2007
@@ -130,13 +130,6 @@
return new SwitchStmt((Expr*)Cond, (Stmt*)Body);
}
-Action::StmtResult
-ASTBuilder::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
- StmtTy *First, ExprTy *Second, ExprTy *Third,
- SourceLocation RParenLoc, StmtTy *Body) {
- return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
-}
-
Action::StmtResult
ASTBuilder::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body){
return new WhileStmt((Expr*)Cond, (Stmt*)Body);
@@ -148,6 +141,36 @@
return new DoStmt((Stmt*)Body, (Expr*)Cond);
}
+Action::StmtResult
+ASTBuilder::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
+ StmtTy *First, ExprTy *Second, ExprTy *Third,
+ SourceLocation RParenLoc, StmtTy *Body) {
+ return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
+}
+
+
+Action::StmtResult
+ASTBuilder::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
+ IdentifierInfo *LabelII) {
+ return new GotoStmt(LabelII);
+}
+Action::StmtResult
+ASTBuilder::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
+ ExprTy *DestExp) {
+ return new IndirectGotoStmt((Expr*)DestExp);
+}
+
+Action::StmtResult
+ASTBuilder::ParseContinueStmt(SourceLocation ContinueLoc) {
+ return new ContinueStmt();
+}
+
+Action::StmtResult
+ASTBuilder::ParseBreakStmt(SourceLocation GotoLoc) {
+ return new BreakStmt();
+}
+
+
Action::StmtResult
ASTBuilder::ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp) {
Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:27:44 2007
@@ -77,6 +77,14 @@
SourceLocation LParenLoc,
StmtTy *First, ExprTy *Second, ExprTy *Third,
SourceLocation RParenLoc, StmtTy *Body);
+ virtual StmtResult ParseGotoStmt(SourceLocation GotoLoc,
+ SourceLocation LabelLoc,
+ IdentifierInfo *LabelII);
+ virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
+ SourceLocation StarLoc,
+ ExprTy *DestExp);
+ virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc);
+ virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc);
virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
Modified: cfe/cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Stmt.h?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Stmt.h Wed Jul 11 11:27:44 2007
@@ -177,6 +177,44 @@
virtual void visit(StmtVisitor &Visitor);
};
+/// GotoStmt - This represents a direct goto.
+///
+class GotoStmt : public Stmt {
+ IdentifierInfo *Label;
+public:
+ GotoStmt(IdentifierInfo *label) : Label(label) {}
+
+ IdentifierInfo *getLabel() { return Label; }
+
+ virtual void visit(StmtVisitor &Visitor);
+};
+
+/// IndirectGotoStmt - This represents an indirect goto.
+///
+class IndirectGotoStmt : public Stmt {
+ Expr *Target;
+public:
+ IndirectGotoStmt(Expr *target) : Target(target) {}
+
+ Expr *getTarget() { return Target; }
+
+ virtual void visit(StmtVisitor &Visitor);
+};
+
+
+/// ContinueStmt - This represents a continue.
+///
+class ContinueStmt : public Stmt {
+public:
+ virtual void visit(StmtVisitor &Visitor);
+};
+
+/// BreakStmt - This represents a break.
+///
+class BreakStmt : public Stmt {
+public:
+ virtual void visit(StmtVisitor &Visitor);
+};
/// ReturnStmt - This represents a return, optionally of an expression.
Modified: cfe/cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/StmtNodes.def?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/cfe/trunk/include/clang/AST/StmtNodes.def Wed Jul 11 11:27:44 2007
@@ -12,16 +12,20 @@
//===----------------------------------------------------------------------===//
// Normal Statements.
-STMT(CompoundStmt, Stmt)
-STMT(CaseStmt , Stmt)
-STMT(DefaultStmt , Stmt)
-STMT(LabelStmt , Stmt)
-STMT(IfStmt , Stmt)
-STMT(SwitchStmt , Stmt)
-STMT(WhileStmt , Stmt)
-STMT(DoStmt , Stmt)
-STMT(ForStmt , Stmt)
-STMT(ReturnStmt , Stmt)
+STMT(CompoundStmt , Stmt)
+STMT(CaseStmt , Stmt)
+STMT(DefaultStmt , Stmt)
+STMT(LabelStmt , Stmt)
+STMT(IfStmt , Stmt)
+STMT(SwitchStmt , Stmt)
+STMT(WhileStmt , Stmt)
+STMT(DoStmt , Stmt)
+STMT(ForStmt , Stmt)
+STMT(GotoStmt , Stmt)
+STMT(IndirectGotoStmt, Stmt)
+STMT(ContinueStmt , Stmt)
+STMT(BreakStmt , Stmt)
+STMT(ReturnStmt , Stmt)
// Expressions.
STMT(Expr , Stmt)
Modified: cfe/cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Action.h?rev=39121&r1=39120&r2=39121&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Action.h Wed Jul 11 11:27:44 2007
@@ -175,15 +175,15 @@
IdentifierInfo *LabelII) {
return 0;
}
- virtual StmtResult ParseContinueStmt(SourceLocation GotoLoc) {
+ virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
+ SourceLocation StarLoc,
+ ExprTy *DestExp) {
return 0;
}
- virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc) {
+ virtual StmtResult ParseContinueStmt(SourceLocation ContinueLoc) {
return 0;
}
- virtual StmtResult ParseIndirectGotoStmt(SourceLocation GotoLoc,
- SourceLocation StarLoc,
- ExprTy *DestExp) {
+ virtual StmtResult ParseBreakStmt(SourceLocation GotoLoc) {
return 0;
}
virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
More information about the cfe-commits
mailing list