forked from OSchip/llvm-project
pretty-print @try/@catch/@finally from AST as the validation of AST.
llvm-svn: 43649
This commit is contained in:
parent
dda9a56975
commit
8815795049
|
@ -322,11 +322,40 @@ void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
|
|||
}
|
||||
|
||||
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 @@ void StmtPrinter::VisitObjCMessageExpr(ObjCMessageExpr *Mess) {
|
|||
OS << "]";
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Stmt method implementations
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -1073,8 +1073,9 @@ Parser::StmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) {
|
|||
// 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
|
||||
|
|
|
@ -686,6 +686,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ class ObjcAtFinallyStmt : public Stmt {
|
|||
: Stmt(ObjcAtFinallyStmtClass),
|
||||
AtFinallyStmt(atFinallyStmt), AtFinallyLoc(atFinallyLoc) {}
|
||||
|
||||
Stmt *getFinallyBody () const { return AtFinallyStmt; }
|
||||
|
||||
virtual SourceRange getSourceRange() const {
|
||||
return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
|
||||
}
|
||||
|
@ -745,6 +751,10 @@ public:
|
|||
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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue