[cfe-commits] r39051 - in /cfe/cfe/trunk: AST/Sema.cpp AST/Stmt.cpp Sema/Sema.cpp include/clang/AST/Stmt.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:27:08 PDT 2007
Author: sabre
Date: Wed Jul 11 11:27:08 2007
New Revision: 39051
URL: http://llvm.org/viewvc/llvm-project?rev=39051&view=rev
Log:
add ast node for ifstmt
Modified:
cfe/cfe/trunk/AST/Sema.cpp
cfe/cfe/trunk/AST/Stmt.cpp
cfe/cfe/trunk/Sema/Sema.cpp
cfe/cfe/trunk/include/clang/AST/Stmt.h
Modified: cfe/cfe/trunk/AST/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.cpp?rev=39051&r1=39050&r2=39051&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:27:08 2007
@@ -61,6 +61,10 @@
return Expr; // Exprs are Stmts.
}
+ virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+ StmtTy *ThenVal, SourceLocation ElseLoc,
+ StmtTy *ElseVal);
+
virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
@@ -195,6 +199,12 @@
return 0; // {} -> ;
}
+Action::StmtResult
+ASTBuilder::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+ StmtTy *ThenVal, SourceLocation ElseLoc,
+ StmtTy *ElseVal) {
+ return new IfStmt((Expr*)CondVal, (Stmt*)ThenVal, (Stmt*)ElseVal);
+}
Action::StmtResult
ASTBuilder::ParseReturnStmt(SourceLocation ReturnLoc,
Modified: cfe/cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Stmt.cpp?rev=39051&r1=39050&r2=39051&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/cfe/trunk/AST/Stmt.cpp Wed Jul 11 11:27:08 2007
@@ -38,6 +38,14 @@
std::cerr << "}";
}
+void IfStmt::dump_impl() const {
+ std::cerr << "if ";
+ Cond->dump();
+ std::cerr << " then\n";
+ Then->dump();
+ std::cerr << "\n else ";
+ Else->dump();
+}
void ReturnStmt::dump_impl() const {
std::cerr << "return ";
Modified: cfe/cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.cpp?rev=39051&r1=39050&r2=39051&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:27:08 2007
@@ -61,6 +61,10 @@
return Expr; // Exprs are Stmts.
}
+ virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+ StmtTy *ThenVal, SourceLocation ElseLoc,
+ StmtTy *ElseVal);
+
virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
@@ -195,6 +199,12 @@
return 0; // {} -> ;
}
+Action::StmtResult
+ASTBuilder::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+ StmtTy *ThenVal, SourceLocation ElseLoc,
+ StmtTy *ElseVal) {
+ return new IfStmt((Expr*)CondVal, (Stmt*)ThenVal, (Stmt*)ElseVal);
+}
Action::StmtResult
ASTBuilder::ParseReturnStmt(SourceLocation ReturnLoc,
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=39051&r1=39050&r2=39051&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Stmt.h Wed Jul 11 11:27:08 2007
@@ -51,6 +51,17 @@
virtual void dump_impl() const;
};
+/// IfStmt - This represents an if/then/else.
+///
+class IfStmt : public Stmt {
+ Expr *Cond;
+ Stmt *Then, *Else;
+public:
+ IfStmt(Expr *cond, Stmt *then, Stmt *elsev = 0)
+ : Cond(cond), Then(then), Else(elsev) {}
+
+ virtual void dump_impl() const;
+};
More information about the cfe-commits
mailing list