summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/clang/include/clang/AST/Stmt.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/AST/Stmt.h')
-rw-r--r--contrib/llvm/tools/clang/include/clang/AST/Stmt.h134
1 files changed, 103 insertions, 31 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/AST/Stmt.h b/contrib/llvm/tools/clang/include/clang/AST/Stmt.h
index 1b0f576..35fb693 100644
--- a/contrib/llvm/tools/clang/include/clang/AST/Stmt.h
+++ b/contrib/llvm/tools/clang/include/clang/AST/Stmt.h
@@ -19,8 +19,8 @@
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/StmtIterator.h"
#include "clang/AST/DeclGroup.h"
-#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
+#include "clang/Lex/Token.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
@@ -37,9 +37,11 @@ namespace clang {
class ParmVarDecl;
class QualType;
class IdentifierInfo;
+ class LabelDecl;
class SourceManager;
class StringLiteral;
class SwitchStmt;
+ class VarDecl;
//===--------------------------------------------------------------------===//
// ExprIterator - Iterators for iterating over Stmt* arrays that contain
@@ -371,15 +373,9 @@ public:
/// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
/// back to its original source language syntax.
- void dumpPretty(ASTContext& Context) const;
+ void dumpPretty(ASTContext &Context) const;
void printPretty(raw_ostream &OS, PrinterHelper *Helper,
const PrintingPolicy &Policy,
- unsigned Indentation = 0) const {
- printPretty(OS, *(ASTContext*)0, Helper, Policy, Indentation);
- }
- void printPretty(raw_ostream &OS, ASTContext &Context,
- PrinterHelper *Helper,
- const PrintingPolicy &Policy,
unsigned Indentation = 0) const;
/// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
@@ -499,6 +495,14 @@ public:
decl_iterator decl_end() { return DG.end(); }
const_decl_iterator decl_begin() const { return DG.begin(); }
const_decl_iterator decl_end() const { return DG.end(); }
+
+ typedef std::reverse_iterator<decl_iterator> reverse_decl_iterator;
+ reverse_decl_iterator decl_rbegin() {
+ return reverse_decl_iterator(decl_end());
+ }
+ reverse_decl_iterator decl_rend() {
+ return reverse_decl_iterator(decl_begin());
+ }
};
/// NullStmt - This is the null statement ";": C99 6.8.3p3.
@@ -545,20 +549,13 @@ class CompoundStmt : public Stmt {
Stmt** Body;
SourceLocation LBracLoc, RBracLoc;
public:
- CompoundStmt(ASTContext& C, Stmt **StmtStart, unsigned NumStmts,
- SourceLocation LB, SourceLocation RB)
- : Stmt(CompoundStmtClass), LBracLoc(LB), RBracLoc(RB) {
- CompoundStmtBits.NumStmts = NumStmts;
- assert(CompoundStmtBits.NumStmts == NumStmts &&
- "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
-
- if (NumStmts == 0) {
- Body = 0;
- return;
- }
+ CompoundStmt(ASTContext &C, Stmt **StmtStart, unsigned NumStmts,
+ SourceLocation LB, SourceLocation RB);
- Body = new (C) Stmt*[NumStmts];
- memcpy(Body, StmtStart, NumStmts * sizeof(*Body));
+ // \brief Build an empty compound statment with a location.
+ explicit CompoundStmt(SourceLocation Loc)
+ : Stmt(CompoundStmtClass), Body(0), LBracLoc(Loc), RBracLoc(Loc) {
+ CompoundStmtBits.NumStmts = 0;
}
// \brief Build an empty compound statement.
@@ -803,24 +800,32 @@ public:
class AttributedStmt : public Stmt {
Stmt *SubStmt;
SourceLocation AttrLoc;
- AttrVec Attrs;
- // TODO: It can be done as Attr *Attrs[1]; and variable size array as in
- // StringLiteral
+ unsigned NumAttrs;
+ const Attr *Attrs[1];
friend class ASTStmtReader;
-public:
- AttributedStmt(SourceLocation loc, const AttrVec &attrs, Stmt *substmt)
- : Stmt(AttributedStmtClass), SubStmt(substmt), AttrLoc(loc), Attrs(attrs) {
+ AttributedStmt(SourceLocation Loc, ArrayRef<const Attr*> Attrs, Stmt *SubStmt)
+ : Stmt(AttributedStmtClass), SubStmt(SubStmt), AttrLoc(Loc),
+ NumAttrs(Attrs.size()) {
+ memcpy(this->Attrs, Attrs.data(), Attrs.size() * sizeof(Attr*));
}
- // \brief Build an empty attributed statement.
- explicit AttributedStmt(EmptyShell Empty)
- : Stmt(AttributedStmtClass, Empty) {
+ explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)
+ : Stmt(AttributedStmtClass, Empty), NumAttrs(NumAttrs) {
+ memset(Attrs, 0, NumAttrs * sizeof(Attr*));
}
+public:
+ static AttributedStmt *Create(ASTContext &C, SourceLocation Loc,
+ ArrayRef<const Attr*> Attrs, Stmt *SubStmt);
+ // \brief Build an empty attributed statement.
+ static AttributedStmt *CreateEmpty(ASTContext &C, unsigned NumAttrs);
+
SourceLocation getAttrLoc() const { return AttrLoc; }
- const AttrVec &getAttrs() const { return Attrs; }
+ ArrayRef<const Attr*> getAttrs() const {
+ return ArrayRef<const Attr*>(Attrs, NumAttrs);
+ }
Stmt *getSubStmt() { return SubStmt; }
const Stmt *getSubStmt() const { return SubStmt; }
@@ -1606,6 +1611,73 @@ public:
}
};
+/// MSAsmStmt - This represents a MS inline-assembly statement extension.
+///
+class MSAsmStmt : public Stmt {
+ SourceLocation AsmLoc, LBraceLoc, EndLoc;
+ std::string AsmStr;
+
+ bool IsSimple;
+ bool IsVolatile;
+
+ unsigned NumAsmToks;
+ unsigned NumInputs;
+ unsigned NumOutputs;
+ unsigned NumClobbers;
+
+ Token *AsmToks;
+ IdentifierInfo **Names;
+ Stmt **Exprs;
+ StringRef *Clobbers;
+
+public:
+ MSAsmStmt(ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc,
+ bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
+ ArrayRef<IdentifierInfo*> inputs, ArrayRef<IdentifierInfo*> outputs,
+ StringRef asmstr, ArrayRef<StringRef> clobbers,
+ SourceLocation endloc);
+
+ SourceLocation getAsmLoc() const { return AsmLoc; }
+ void setAsmLoc(SourceLocation L) { AsmLoc = L; }
+ SourceLocation getLBraceLoc() const { return LBraceLoc; }
+ void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
+ SourceLocation getEndLoc() const { return EndLoc; }
+ void setEndLoc(SourceLocation L) { EndLoc = L; }
+
+ bool hasBraces() const { return LBraceLoc.isValid(); }
+
+ unsigned getNumAsmToks() { return NumAsmToks; }
+ Token *getAsmToks() { return AsmToks; }
+
+ bool isVolatile() const { return IsVolatile; }
+ void setVolatile(bool V) { IsVolatile = V; }
+ bool isSimple() const { return IsSimple; }
+ void setSimple(bool V) { IsSimple = V; }
+
+ //===--- Asm String Analysis ---===//
+
+ const std::string *getAsmString() const { return &AsmStr; }
+ std::string *getAsmString() { return &AsmStr; }
+ void setAsmString(StringRef &E) { AsmStr = E.str(); }
+
+ //===--- Other ---===//
+
+ unsigned getNumClobbers() const { return NumClobbers; }
+ StringRef getClobber(unsigned i) const { return Clobbers[i]; }
+
+ SourceRange getSourceRange() const LLVM_READONLY {
+ return SourceRange(AsmLoc, EndLoc);
+ }
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == MSAsmStmtClass;
+ }
+ static bool classof(const MSAsmStmt *) { return true; }
+
+ child_range children() {
+ return child_range(&Exprs[0], &Exprs[0]);
+ }
+};
+
class SEHExceptStmt : public Stmt {
SourceLocation Loc;
Stmt *Children[2];
OpenPOWER on IntegriCloud