Bunch of type defs, etc. for @synchronized.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46520 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2008-01-29 18:21:32 +00:00
Родитель 356916ec84
Коммит c385c90c68
6 изменённых файлов: 58 добавлений и 2 удалений

Просмотреть файл

@ -455,6 +455,17 @@ void StmtPrinter::VisitObjCAtThrowStmt (ObjCAtThrowStmt *Node) {
OS << ";\n";
}
void StmtPrinter::VisitObjCAtSynchronizedStmt (ObjCAtSynchronizedStmt *Node) {
Indent() << "@synchronized (";
PrintExpr(Node->getSynchExpr());
OS << ")";
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Node->getSynchBody()))
{
PrintRawCompoundStmt(CS);
OS << "\n";
}
}
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -1109,6 +1109,13 @@ Parser::StmtResult Parser::ParseObjCThrowStmt(SourceLocation atLoc) {
return Actions.ActOnObjCAtThrowStmt(atLoc, Res.Val);
}
/// objc-synchronized-statement:
/// @synchronized '(' expression ')'
///
Parser::StmtResult Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
return 0;
}
/// objc-try-catch-statement:
/// @try compound-statement objc-catch-list[opt]
/// @try compound-statement objc-catch-list[opt] @finally compound-statement

Просмотреть файл

@ -36,7 +36,7 @@ using namespace clang;
/// jump-statement
/// [OBC] objc-throw-statement
/// [OBC] objc-try-catch-statement
/// [OBC] objc-synchronized-statement [TODO]
/// [OBC] objc-synchronized-statement
/// [GNU] asm-statement
/// [OMP] openmp-construct [TODO]
///
@ -91,6 +91,8 @@ Parser::StmtResult Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
return ParseObjCTryStmt(AtLoc);
else if (Tok.isObjCAtKeyword(tok::objc_throw))
return ParseObjCThrowStmt(AtLoc);
else if (Tok.isObjCAtKeyword(tok::objc_synchronized))
return ParseObjCSynchronizedStmt(AtLoc);
ExprResult Res = ParseExpressionWithLeadingAt(AtLoc);
if (Res.isInvalid) {
// If the expression is invalid, skip ahead to the next semicolon. Not

Просмотреть файл

@ -962,6 +962,40 @@ public:
static ObjCAtTryStmt* CreateImpl(llvm::Deserializer& D);
};
/// ObjCAtSynchronizedStmt - This is for objective-c's @synchronized statement.
///
class ObjCAtSynchronizedStmt : public Stmt {
private:
Expr* SynchExpr;
Stmt* SynchBody;
SourceLocation AtSynchronizedLoc;
public:
ObjCAtSynchronizedStmt(SourceLocation atSynchronizedLoc, Expr *synchExpr,
Stmt *synchBody)
: Stmt(ObjCAtSynchronizedStmtClass),
SynchExpr(synchExpr), SynchBody(synchBody),
AtSynchronizedLoc(atSynchronizedLoc) {}
const Stmt *getSynchBody() const { return SynchBody; }
Stmt *getSynchBody() { return SynchBody; }
const Expr *getSynchExpr() const { return SynchExpr; }
Expr *getSynchExpr() { return SynchExpr; }
virtual SourceRange getSourceRange() const {
return SourceRange(AtSynchronizedLoc, SynchBody->getLocEnd());
}
static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtSynchronizedStmtClass;
}
static bool classof(const ObjCAtSynchronizedStmt *) { return true; }
virtual void EmitImpl(llvm::Serializer& S) const;
static ObjCAtSynchronizedStmt* CreateImpl(llvm::Deserializer& D);
};
/// ObjCAtThrowStmt - This represents objective-c's @throw statement.
class ObjCAtThrowStmt : public Stmt {
Stmt *Throw;

Просмотреть файл

@ -49,8 +49,9 @@ STMT(19, ObjCAtTryStmt , Stmt)
STMT(20, ObjCAtCatchStmt , Stmt)
STMT(21, ObjCAtFinallyStmt , Stmt)
STMT(22, ObjCAtThrowStmt , Stmt)
STMT(23, ObjCAtSynchronizedStmt , Stmt)
// Obj-C2 statements
STMT(23, ObjCForCollectionStmt, Stmt)
STMT(24, ObjCForCollectionStmt, Stmt)
LAST_STMT(23)

Просмотреть файл

@ -405,6 +405,7 @@ private:
StmtResult ParseAsmStatement();
StmtResult ParseObjCTryStmt(SourceLocation atLoc);
StmtResult ParseObjCThrowStmt(SourceLocation atLoc);
StmtResult ParseObjCSynchronizedStmt(SourceLocation atLoc);
void ParseAsmOperandsOpt(llvm::SmallVectorImpl<std::string> &Names,
llvm::SmallVectorImpl<ExprTy*> &Constraints,
llvm::SmallVectorImpl<ExprTy*> &Exprs);