diff options
Diffstat (limited to 'clang/include/clang')
-rw-r--r-- | clang/include/clang/AST/Decl.h | 21 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclBase.h | 2 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclCXX.h | 10 | ||||
-rw-r--r-- | clang/include/clang/AST/DeclObjC.h | 5 | ||||
-rw-r--r-- | clang/include/clang/AST/Expr.h | 3 | ||||
-rw-r--r-- | clang/include/clang/AST/ExternalASTSource.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHReader.h | 3 |
7 files changed, 32 insertions, 14 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 3f4ea122bdb..083f6c63638 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -16,6 +16,7 @@ #include "clang/AST/DeclBase.h" #include "clang/AST/DeclarationName.h" +#include "clang/AST/ExternalASTSource.h" namespace clang { class Expr; @@ -564,7 +565,7 @@ private: /// FunctionDecl object to save an allocation like FunctionType does. ParmVarDecl **ParamInfo; - Stmt *Body; // Null if a prototype. + Stmt *Body; /// PreviousDeclaration - A link to the previous declaration of this /// same function, NULL if this is the first declaration. For @@ -596,7 +597,7 @@ protected: SourceLocation TSSL = SourceLocation()) : ValueDecl(DK, DC, L, N, T), DeclContext(DK), - ParamInfo(0), Body(0), PreviousDeclaration(0), + ParamInfo(0), Body(), PreviousDeclaration(0), SClass(S), IsInline(isInline), IsVirtual(false), IsPure(false), InheritedPrototype(false), HasPrototype(true), IsDeleted(false), TypeSpecStartLoc(TSSL) {} @@ -619,20 +620,25 @@ public: /// function. The variant that accepts a FunctionDecl pointer will /// set that function declaration to the actual declaration /// containing the body (if there is one). - CompoundStmt *getBody(const FunctionDecl *&Definition) const; + CompoundStmt *getBody(ASTContext &Context, + const FunctionDecl *&Definition) const; - virtual CompoundStmt *getBody() const { + virtual CompoundStmt *getBody(ASTContext &Context) const { const FunctionDecl* Definition; - return getBody(Definition); + return getBody(Context, Definition); } - + + /// \brief If the function has a body that is immediately available, + /// return it. + CompoundStmt *getBodyIfAvailable() const; + /// isThisDeclarationADefinition - Returns whether this specific /// declaration of the function is also a definition. This does not /// determine whether the function has been defined (e.g., in a /// previous definition); for that information, use getBody. /// FIXME: Should return true if function is deleted or defaulted. However, /// CodeGenModule.cpp uses it, and I don't know if this would break it. - bool isThisDeclarationADefinition() const { return Body != 0; } + bool isThisDeclarationADefinition() const { return Body; } void setBody(CompoundStmt *B) { Body = (Stmt*) B; } @@ -1258,6 +1264,7 @@ public: SourceLocation getCaretLocation() const { return getLocation(); } CompoundStmt *getBody() const { return (CompoundStmt*) Body; } + CompoundStmt *getBody(ASTContext &C) const { return (CompoundStmt*) Body; } void setBody(CompoundStmt *B) { Body = (Stmt*) B; } // Iterator access to formal parameters. diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 7f427e3eb3a..434780baa02 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -281,7 +281,7 @@ public: // getBody - If this Decl represents a declaration for a body of code, // such as a function or method definition, this method returns the top-level // Stmt* of that body. Otherwise this method returns null. - virtual CompoundStmt* getBody() const { return 0; } + virtual CompoundStmt* getBody(ASTContext &Context) const { return 0; } // global temp stats (until we have a per-module visitor) static void addDeclKind(Kind k); diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 26f8f1a75f0..4dbfe4db0bd 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -676,8 +676,8 @@ public: /// defined. If false, then this constructor was defined by the /// user. This operation can only be invoked if the constructor has /// already been defined. - bool isImplicitlyDefined() const { - assert(getBody() != 0 && + bool isImplicitlyDefined(ASTContext &C) const { + assert(isThisDeclarationADefinition() && "Can only get the implicit-definition flag once the constructor has been defined"); return ImplicitlyDefined; } @@ -685,7 +685,7 @@ public: /// setImplicitlyDefined - Set whether this constructor was /// implicitly defined or not. void setImplicitlyDefined(bool ID) { - assert(getBody() != 0 && + assert(isThisDeclarationADefinition() && "Can only set the implicit-definition flag once the constructor has been defined"); ImplicitlyDefined = ID; } @@ -773,7 +773,7 @@ public: /// user. This operation can only be invoked if the destructor has /// already been defined. bool isImplicitlyDefined() const { - assert(getBody() != 0 && + assert(isThisDeclarationADefinition() && "Can only get the implicit-definition flag once the destructor has been defined"); return ImplicitlyDefined; } @@ -781,7 +781,7 @@ public: /// setImplicitlyDefined - Set whether this destructor was /// implicitly defined or not. void setImplicitlyDefined(bool ID) { - assert(getBody() != 0 && + assert(isThisDeclarationADefinition() && "Can only set the implicit-definition flag once the destructor has been defined"); ImplicitlyDefined = ID; } diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 62cd01ee8b5..7b02bb29fd4 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -225,7 +225,10 @@ public: return ImplementationControl(DeclImplementation); } - virtual CompoundStmt *getBody() const { return (CompoundStmt*) Body; } + virtual CompoundStmt *getBody(ASTContext &C) const { + return (CompoundStmt*) Body; + } + CompoundStmt *getBody() { return (CompoundStmt*)Body; } void setBody(CompoundStmt *B) { Body = (Stmt*) B; } // Implement isa/cast/dyncast/etc. diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index c8599ea5877..3b9b6273b15 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -2505,6 +2505,9 @@ public: const Stmt *getBody() const; Stmt *getBody(); + const Stmt *getBody(ASTContext &C) const { return getBody(); } + Stmt *getBody(ASTContext &C) { return getBody(); } + virtual SourceRange getSourceRange() const { return SourceRange(getCaretLocation(), getBody()->getLocEnd()); } diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index 2ec29d80ec0..d5499d7b05f 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -16,11 +16,13 @@ #include "clang/AST/DeclarationName.h" #include "clang/AST/Type.h" #include "llvm/ADT/SmallVector.h" +#include <cassert> namespace clang { class ASTConsumer; class Decl; class DeclContext; +class Stmt; /// \brief The deserialized representation of a set of declarations /// with the same name that are visible in a given context. diff --git a/clang/include/clang/Frontend/PCHReader.h b/clang/include/clang/Frontend/PCHReader.h index 1352908ef18..c4f90a3c794 100644 --- a/clang/include/clang/Frontend/PCHReader.h +++ b/clang/include/clang/Frontend/PCHReader.h @@ -273,6 +273,9 @@ public: /// supplements. ASTContext &getContext() { return Context; } + /// \brief Retrieve the stream that this PCH reader is reading from. + llvm::BitstreamReader &getStream() { return Stream; } + /// \brief Record that the given ID maps to the given switch-case /// statement. void RecordSwitchCaseID(SwitchCase *SC, unsigned ID); |