diff options
Diffstat (limited to 'clang/include/clang/AST/Stmt.h')
-rw-r--r-- | clang/include/clang/AST/Stmt.h | 145 |
1 files changed, 99 insertions, 46 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index eaacb1a5b252..d3fad58fcf59 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -14,12 +14,14 @@ #define LLVM_CLANG_AST_STMT_H #include "clang/AST/DeclGroup.h" +#include "clang/AST/DependenceFlags.h" #include "clang/AST/StmtIterator.h" #include "clang/Basic/CapturedStmt.h" #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/BitmaskEnum.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" @@ -98,14 +100,8 @@ protected: /// The statement class. unsigned sClass : 8; - - /// This bit is set only for the Stmts that are the structured-block of - /// OpenMP executable directives. Directives that have a structured block - /// are called "non-standalone" directives. - /// I.e. those returned by OMPExecutableDirective::getStructuredBlock(). - unsigned IsOMPStructuredBlock : 1; }; - enum { NumStmtBits = 9 }; + enum { NumStmtBits = 8 }; class NullStmtBitfields { friend class ASTStmtReader; @@ -315,12 +311,9 @@ protected: unsigned ValueKind : 2; unsigned ObjectKind : 3; - unsigned TypeDependent : 1; - unsigned ValueDependent : 1; - unsigned InstantiationDependent : 1; - unsigned ContainsUnexpandedParameterPack : 1; + unsigned /*ExprDependence*/ Dependent : llvm::BitWidth<ExprDependence>; }; - enum { NumExprBits = NumStmtBits + 9 }; + enum { NumExprBits = NumStmtBits + 5 + llvm::BitWidth<ExprDependence> }; class ConstantExprBitfields { friend class ASTStmtReader; @@ -329,24 +322,27 @@ protected: unsigned : NumExprBits; - /// The kind of result that is trail-allocated. + /// The kind of result that is tail-allocated. unsigned ResultKind : 2; - /// Kind of Result as defined by APValue::Kind + /// The kind of Result as defined by APValue::Kind. unsigned APValueKind : 4; - /// When ResultKind == RSK_Int64. whether the trail-allocated integer is - /// signed. + /// When ResultKind == RSK_Int64, true if the tail-allocated integer is + /// unsigned. unsigned IsUnsigned : 1; - /// When ResultKind == RSK_Int64. the BitWidth of the trail-allocated - /// integer. 7 bits because it is the minimal number of bit to represent a - /// value from 0 to 64 (the size of the trail-allocated number). + /// When ResultKind == RSK_Int64. the BitWidth of the tail-allocated + /// integer. 7 bits because it is the minimal number of bits to represent a + /// value from 0 to 64 (the size of the tail-allocated integer). unsigned BitWidth : 7; - /// When ResultKind == RSK_APValue. Wether the ASTContext will cleanup the - /// destructor on the trail-allocated APValue. + /// When ResultKind == RSK_APValue, true if the ASTContext will cleanup the + /// tail-allocated APValue. unsigned HasCleanup : 1; + + /// True if this ConstantExpr was created for immediate invocation. + unsigned IsImmediateInvocation : 1; }; class PredefinedExprBitfields { @@ -431,6 +427,11 @@ protected: unsigned Opc : 5; unsigned CanOverflow : 1; + // + /// This is only meaningful for operations on floating point + /// types when additional values need to be in trailing storage. + /// It is 0 otherwise. + unsigned HasFPFeatures : 1; SourceLocation Loc; }; @@ -444,8 +445,9 @@ protected: unsigned IsType : 1; // true if operand is a type, false if an expression. }; - class ArraySubscriptExprBitfields { + class ArrayOrMatrixSubscriptExprBitfields { friend class ArraySubscriptExpr; + friend class MatrixSubscriptExpr; unsigned : NumExprBits; @@ -529,8 +531,9 @@ protected: unsigned Opc : 6; /// This is only meaningful for operations on floating point - /// types and 0 otherwise. - unsigned FPFeatures : 3; + /// types when additional values need to be in trailing storage. + /// It is 0 otherwise. + unsigned HasFPFeatures : 1; SourceLocation OpLoc; }; @@ -588,6 +591,18 @@ protected: unsigned Kind : 2; }; + class StmtExprBitfields { + friend class ASTStmtReader; + friend class StmtExpr; + + unsigned : NumExprBits; + + /// The number of levels of template parameters enclosing this statement + /// expression. Used to determine if a statement expression remains + /// dependent after instantiation. + unsigned TemplateDepth; + }; + //===--- C++ Expression bitfields classes ---===// class CXXOperatorCallExprBitfields { @@ -599,9 +614,6 @@ protected: /// The kind of this overloaded operator. One of the enumerator /// value of OverloadedOperatorKind. unsigned OperatorKind : 6; - - // Only meaningful for floating point types. - unsigned FPFeatures : 3; }; class CXXRewrittenBinaryOperatorBitfields { @@ -760,8 +772,10 @@ protected: /// the trait evaluated true or false. unsigned Value : 1; - /// The number of arguments to this type trait. - unsigned NumArgs : 32 - 8 - 1 - NumExprBits; + /// The number of arguments to this type trait. According to [implimits] + /// 8 bits would be enough, but we require (and test for) at least 16 bits + /// to mirror FunctionType. + unsigned NumArgs; }; class DependentScopeDeclRefExprBitfields { @@ -910,6 +924,39 @@ protected: SourceLocation NameLoc; }; + class LambdaExprBitfields { + friend class ASTStmtReader; + friend class ASTStmtWriter; + friend class LambdaExpr; + + unsigned : NumExprBits; + + /// The default capture kind, which is a value of type + /// LambdaCaptureDefault. + unsigned CaptureDefault : 2; + + /// Whether this lambda had an explicit parameter list vs. an + /// implicit (and empty) parameter list. + unsigned ExplicitParams : 1; + + /// Whether this lambda had the result type explicitly specified. + unsigned ExplicitResultType : 1; + + /// The number of captures. + unsigned NumCaptures : 16; + }; + + class RequiresExprBitfields { + friend class ASTStmtReader; + friend class ASTStmtWriter; + friend class RequiresExpr; + + unsigned : NumExprBits; + + unsigned IsSatisfied : 1; + SourceLocation RequiresKWLoc; + }; + //===--- C++ Coroutines TS bitfields classes ---===// class CoawaitExprBitfields { @@ -974,7 +1021,7 @@ protected: CharacterLiteralBitfields CharacterLiteralBits; UnaryOperatorBitfields UnaryOperatorBits; UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits; - ArraySubscriptExprBitfields ArraySubscriptExprBits; + ArrayOrMatrixSubscriptExprBitfields ArrayOrMatrixSubscriptExprBits; CallExprBitfields CallExprBits; MemberExprBitfields MemberExprBits; CastExprBitfields CastExprBits; @@ -985,6 +1032,9 @@ protected: PseudoObjectExprBitfields PseudoObjectExprBits; SourceLocExprBitfields SourceLocExprBits; + // GNU Extensions. + StmtExprBitfields StmtExprBits; + // C++ Expressions CXXOperatorCallExprBitfields CXXOperatorCallExprBits; CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits; @@ -1008,6 +1058,8 @@ protected: UnresolvedMemberExprBitfields UnresolvedMemberExprBits; CXXNoexceptExprBitfields CXXNoexceptExprBits; SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits; + LambdaExprBitfields LambdaExprBits; + RequiresExprBitfields RequiresExprBits; // C++ Coroutines TS expressions CoawaitExprBitfields CoawaitBits; @@ -1090,7 +1142,6 @@ public: static_assert(sizeof(*this) % alignof(void *) == 0, "Insufficient alignment!"); StmtBits.sClass = SC; - StmtBits.IsOMPStructuredBlock = false; if (StatisticsEnabled) Stmt::addStmtClass(SC); } @@ -1100,11 +1151,6 @@ public: const char *getStmtClassName() const; - bool isOMPStructuredBlock() const { return StmtBits.IsOMPStructuredBlock; } - void setIsOMPStructuredBlock(bool IsOMPStructuredBlock) { - StmtBits.IsOMPStructuredBlock = IsOMPStructuredBlock; - } - /// SourceLocation tokens are not useful in isolation - they are low level /// value objects created/interpreted by SourceManager. We assume AST /// clients will have a pointer to the respective SourceManager. @@ -1120,9 +1166,7 @@ public: /// Dumps the specified AST fragment and all subtrees to /// \c llvm::errs(). void dump() const; - void dump(SourceManager &SM) const; - void dump(raw_ostream &OS, SourceManager &SM) const; - void dump(raw_ostream &OS) const; + void dump(raw_ostream &OS, const ASTContext &Context) const; /// \return Unique reproducible object identifier int64_t getID(const ASTContext &Context) const; @@ -2233,6 +2277,8 @@ class WhileStmt final : public Stmt, enum { VarOffset = 0, BodyOffsetFromCond = 1 }; enum { NumMandatoryStmtPtr = 2 }; + SourceLocation LParenLoc, RParenLoc; + unsigned varOffset() const { return VarOffset; } unsigned condOffset() const { return VarOffset + hasVarStorage(); } unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; } @@ -2243,7 +2289,8 @@ class WhileStmt final : public Stmt, /// Build a while statement. WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, - SourceLocation WL); + SourceLocation WL, SourceLocation LParenLoc, + SourceLocation RParenLoc); /// Build an empty while statement. explicit WhileStmt(EmptyShell Empty, bool HasVar); @@ -2251,7 +2298,8 @@ class WhileStmt final : public Stmt, public: /// Create a while statement. static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, - Stmt *Body, SourceLocation WL); + Stmt *Body, SourceLocation WL, + SourceLocation LParenLoc, SourceLocation RParenLoc); /// Create an empty while statement optionally with storage for /// a condition variable. @@ -2315,6 +2363,11 @@ public: SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; } void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; } + SourceLocation getLParenLoc() const { return LParenLoc; } + void setLParenLoc(SourceLocation L) { LParenLoc = L; } + SourceLocation getRParenLoc() const { return RParenLoc; } + void setRParenLoc(SourceLocation L) { RParenLoc = L; } + SourceLocation getBeginLoc() const { return getWhileLoc(); } SourceLocation getEndLoc() const LLVM_READONLY { return getBody()->getEndLoc(); @@ -3017,7 +3070,7 @@ public: } IdentifierInfo *getLabelIdentifier(unsigned i) const { - return Names[i + NumInputs]; + return Names[i + NumOutputs + NumInputs]; } AddrLabelExpr *getLabelExpr(unsigned i) const; @@ -3028,11 +3081,11 @@ public: using labels_const_range = llvm::iterator_range<const_labels_iterator>; labels_iterator begin_labels() { - return &Exprs[0] + NumInputs; + return &Exprs[0] + NumOutputs + NumInputs; } labels_iterator end_labels() { - return &Exprs[0] + NumInputs + NumLabels; + return &Exprs[0] + NumOutputs + NumInputs + NumLabels; } labels_range labels() { @@ -3040,11 +3093,11 @@ public: } const_labels_iterator begin_labels() const { - return &Exprs[0] + NumInputs; + return &Exprs[0] + NumOutputs + NumInputs; } const_labels_iterator end_labels() const { - return &Exprs[0] + NumInputs + NumLabels; + return &Exprs[0] + NumOutputs + NumInputs + NumLabels; } labels_const_range labels() const { |