[cfe-commits] r43649 - in /cfe/trunk: AST/StmtPrinter.cpp Parse/ParseObjc.cpp include/clang/AST/Stmt.h
Fariborz Jahanian
fjahanian at apple.com
Fri Nov 2 11:16:07 PDT 2007
Author: fjahanian
Date: Fri Nov 2 13:16:07 2007
New Revision: 43649
URL: http://llvm.org/viewvc/llvm-project?rev=43649&view=rev
Log:
pretty-print @try/@catch/@finally from AST as the validation of AST.
Modified:
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/Parse/ParseObjc.cpp
cfe/trunk/include/clang/AST/Stmt.h
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=43649&r1=43648&r2=43649&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Fri Nov 2 13:16:07 2007
@@ -322,11 +322,40 @@
}
void StmtPrinter::VisitObjcAtTryStmt(ObjcAtTryStmt *Node) {
- Indent() << "@try { /* todo */ }\n";
+ Indent() << "@try";
+ if (CompoundStmt *TS = dyn_cast<CompoundStmt>(Node->getTryBody())) {
+ PrintRawCompoundStmt(TS);
+ OS << "\n";
+ }
+
+ for (ObjcAtCatchStmt *catchStmt =
+ static_cast<ObjcAtCatchStmt *>(Node->getCatchStmts());
+ catchStmt;
+ catchStmt =
+ static_cast<ObjcAtCatchStmt *>(catchStmt->getNextCatchStmt())) {
+ Indent() << "@catch(";
+ if (catchStmt->getCatchParamStmt()) {
+ if (DeclStmt *DS = dyn_cast<DeclStmt>(catchStmt->getCatchParamStmt()))
+ PrintRawDecl(DS->getDecl());
+ }
+ OS << ")";
+ if (CompoundStmt *CS = dyn_cast<CompoundStmt>(catchStmt->getCatchBody()))
+ {
+ PrintRawCompoundStmt(CS);
+ OS << "\n";
+ }
+ }
+
+ Indent() << "@finally";
+ if (CompoundStmt *FS = dyn_cast<CompoundStmt>(
+ static_cast<ObjcAtFinallyStmt *>(
+ Node->getFinallyStmt())->getFinallyBody())) {
+ PrintRawCompoundStmt(FS);
+ OS << "\n";
+ }
}
void StmtPrinter::VisitObjcAtFinallyStmt(ObjcAtFinallyStmt *Node) {
- Indent() << "@finally { /* todo */ } \n";
}
void StmtPrinter::VisitObjcAtCatchStmt (ObjcAtCatchStmt *Node) {
@@ -665,7 +694,6 @@
OS << "]";
}
-
//===----------------------------------------------------------------------===//
// Stmt method implementations
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=43649&r1=43648&r2=43649&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/Parse/ParseObjc.cpp Fri Nov 2 13:16:07 2007
@@ -1073,8 +1073,9 @@
// FIXME: Is BlockContext right?
Declarator DeclaratorInfo(DS, Declarator::BlockContext);
ParseDeclarator(DeclaratorInfo);
- StmtResult stmtResult = Actions.ActOnDeclarator(CurScope,
- DeclaratorInfo, 0);
+ DeclTy * aBlockVarDecl = Actions.ActOnDeclarator(CurScope,
+ DeclaratorInfo, 0);
+ StmtResult stmtResult = Actions.ActOnDeclStmt(aBlockVarDecl);
FirstPart = stmtResult.isInvalid ? 0 : stmtResult.Val;
}
else
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=43649&r1=43648&r2=43649&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 2 13:16:07 2007
@@ -686,6 +686,10 @@
}
}
+ Stmt *getCatchBody() const { return SubExprs[BODY]; }
+ Stmt *getNextCatchStmt() const { return NextAtCatchStmt; }
+ Stmt *getCatchParamStmt() const { return SubExprs[SELECTOR]; }
+
virtual SourceRange getSourceRange() const {
return SourceRange(AtCatchLoc, SubExprs[BODY]->getLocEnd());
}
@@ -711,6 +715,8 @@
: Stmt(ObjcAtFinallyStmtClass),
AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {}
+ Stmt *getFinallyBody () const { return AtFinallyStmt; }
+
virtual SourceRange getSourceRange() const {
return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
}
@@ -745,6 +751,10 @@
SubStmts[END_TRY] = NULL;
}
+ Stmt *getTryBody() const { return SubStmts[TRY]; }
+ Stmt *getCatchStmts() const { return SubStmts[CATCH]; }
+ Stmt *getFinallyStmt() const { return SubStmts[FINALLY]; }
+
virtual SourceRange getSourceRange() const {
return SourceRange(AtTryLoc, SubStmts[TRY]->getLocEnd());
}
More information about the cfe-commits
mailing list