diff options
Diffstat (limited to 'include/clang/AST/Decl.h')
-rw-r--r-- | include/clang/AST/Decl.h | 122 |
1 files changed, 108 insertions, 14 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 7927279ddd6d..a0c76c069b86 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -219,10 +219,6 @@ public: return getLinkage() == ExternalLinkage; } - /// \brief True if this decl has external linkage. Don't cache the linkage, - /// because we are not finished setting up the redecl chain for the decl. - bool hasExternalLinkageUncached() const; - /// \brief Determines the visibility of this entity. Visibility getVisibility() const { return getLinkageAndVisibility().getVisibility(); @@ -641,6 +637,13 @@ public: ListInit ///< Direct list-initialization (C++11) }; + /// \brief Kinds of thread-local storage. + enum TLSKind { + TLS_None, ///< Not a TLS variable. + TLS_Static, ///< TLS with a known-constant initializer. + TLS_Dynamic ///< TLS with a dynamic initializer. + }; + protected: /// \brief Placeholder type used in Init to denote an unparsed C++ default /// argument. @@ -664,7 +667,7 @@ private: friend class ASTDeclReader; unsigned SClass : 3; - unsigned ThreadSpecified : 1; + unsigned TSCSpec : 2; unsigned InitStyle : 2; /// \brief Whether this variable is the exception variable in a C++ catch @@ -687,7 +690,7 @@ private: /// \brief Whether this variable is (C++0x) constexpr. unsigned IsConstexpr : 1; }; - enum { NumVarDeclBits = 14 }; + enum { NumVarDeclBits = 12 }; friend class ASTDeclReader; friend class StmtIteratorBase; @@ -771,9 +774,23 @@ public: } void setStorageClass(StorageClass SC); - void setThreadSpecified(bool T) { VarDeclBits.ThreadSpecified = T; } - bool isThreadSpecified() const { - return VarDeclBits.ThreadSpecified; + void setTSCSpec(ThreadStorageClassSpecifier TSC) { + VarDeclBits.TSCSpec = TSC; + } + ThreadStorageClassSpecifier getTSCSpec() const { + return static_cast<ThreadStorageClassSpecifier>(VarDeclBits.TSCSpec); + } + TLSKind getTLSKind() const { + switch (VarDeclBits.TSCSpec) { + case TSCS_unspecified: + return TLS_None; + case TSCS___thread: // Fall through. + case TSCS__Thread_local: + return TLS_Static; + case TSCS_thread_local: + return TLS_Dynamic; + } + llvm_unreachable("Unknown thread storage class specifier!"); } /// hasLocalStorage - Returns true if a variable with function scope @@ -813,6 +830,14 @@ public: /// external, C linkage. bool isExternC() const; + /// \brief Determines whether this variable's context is, or is nested within, + /// a C++ extern "C" linkage spec. + bool isInExternCContext() const; + + /// \brief Determines whether this variable's context is, or is nested within, + /// a C++ extern "C++" linkage spec. + bool isInExternCXXContext() const; + /// isLocalVarDecl - Returns true for local variable declarations /// other than parameters. Note that this includes static variables /// inside of functions. It also includes variables inside blocks. @@ -1698,6 +1723,14 @@ public: /// external, C linkage. bool isExternC() const; + /// \brief Determines whether this function's context is, or is nested within, + /// a C++ extern "C" linkage spec. + bool isInExternCContext() const; + + /// \brief Determines whether this function's context is, or is nested within, + /// a C++ extern "C++" linkage spec. + bool isInExternCXXContext() const; + /// \brief Determines whether this is a global function. bool isGlobal() const; @@ -2394,7 +2427,7 @@ protected: bool IsScopedUsingClassTag : 1; /// IsFixed - True if this is an enumeration with fixed underlying type. Only - /// possible in C++11 or Microsoft extensions mode. + /// possible in C++11, Microsoft extensions, or Objective C mode. bool IsFixed : 1; /// \brief Indicates whether it is possible for declarations of this kind @@ -2780,18 +2813,18 @@ public: NumNegativeBits = Num; } - /// \brief Returns true if this is a C++0x scoped enumeration. + /// \brief Returns true if this is a C++11 scoped enumeration. bool isScoped() const { return IsScoped; } - /// \brief Returns true if this is a C++0x scoped enumeration. + /// \brief Returns true if this is a C++11 scoped enumeration. bool isScopedUsingClassTag() const { return IsScopedUsingClassTag; } - /// \brief Returns true if this is a C++0x enumeration with fixed underlying - /// type. + /// \brief Returns true if this is an Objective-C, C++11, or + /// Microsoft-style enumeration with a fixed underlying type. bool isFixed() const { return IsFixed; } @@ -3162,6 +3195,67 @@ public: } }; +/// \brief This represents the body of a CapturedStmt, and serves as its +/// DeclContext. +class CapturedDecl : public Decl, public DeclContext { +private: + /// \brief The number of parameters to the outlined function. + unsigned NumParams; + /// \brief The body of the outlined function. + Stmt *Body; + + explicit CapturedDecl(DeclContext *DC, unsigned NumParams) + : Decl(Captured, DC, SourceLocation()), DeclContext(Captured), + NumParams(NumParams), Body(0) { } + + ImplicitParamDecl **getParams() const { + return reinterpret_cast<ImplicitParamDecl **>( + const_cast<CapturedDecl *>(this) + 1); + } + +public: + static CapturedDecl *Create(ASTContext &C, DeclContext *DC, unsigned NumParams); + static CapturedDecl *CreateDeserialized(ASTContext &C, unsigned ID, + unsigned NumParams); + + Stmt *getBody() const { return Body; } + void setBody(Stmt *B) { Body = B; } + + unsigned getNumParams() const { return NumParams; } + + ImplicitParamDecl *getParam(unsigned i) const { + assert(i < NumParams); + return getParams()[i]; + } + void setParam(unsigned i, ImplicitParamDecl *P) { + assert(i < NumParams); + getParams()[i] = P; + } + + /// \brief Retrieve the parameter containing captured variables. + ImplicitParamDecl *getContextParam() const { return getParam(0); } + void setContextParam(ImplicitParamDecl *P) { setParam(0, P); } + + typedef ImplicitParamDecl **param_iterator; + /// \brief Retrieve an iterator pointing to the first parameter decl. + param_iterator param_begin() const { return getParams(); } + /// \brief Retrieve an iterator one past the last parameter decl. + param_iterator param_end() const { return getParams() + NumParams; } + + // Implement isa/cast/dyncast/etc. + static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Captured; } + static DeclContext *castToDeclContext(const CapturedDecl *D) { + return static_cast<DeclContext *>(const_cast<CapturedDecl *>(D)); + } + static CapturedDecl *castFromDeclContext(const DeclContext *DC) { + return static_cast<CapturedDecl *>(const_cast<DeclContext *>(DC)); + } + + friend class ASTDeclReader; + friend class ASTDeclWriter; +}; + /// \brief Describes a module import declaration, which makes the contents /// of the named module visible in the current translation unit. /// |