diff options
Diffstat (limited to 'clang/include')
-rw-r--r-- | clang/include/clang/AST/Decl.h | 2 | ||||
-rw-r--r-- | clang/include/clang/AST/Expr.h | 29 | ||||
-rw-r--r-- | clang/include/clang/AST/Stmt.h | 7 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHBitCodes.h | 18 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHReader.h | 3 | ||||
-rw-r--r-- | clang/include/clang/Frontend/PCHWriter.h | 22 |
6 files changed, 77 insertions, 4 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index fd6e210104f..3f4ea122bdb 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -807,6 +807,8 @@ public: bool isAnonymousStructOrUnion() const; Expr *getBitWidth() const { return BitWidth; } + void setBitWidth(Expr *BW) { BitWidth = BW; } + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= FieldFirst && D->getKind() <= FieldLast; diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 6fd2970153e..7001e290fce 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -63,6 +63,9 @@ protected: setType(T); } + /// \brief Construct an empty expression. + explicit Expr(StmtClass SC, EmptyShell) : Stmt(SC) { } + public: QualType getType() const { return TR; } void setType(QualType t) { @@ -88,6 +91,9 @@ public: /// @endcode bool isValueDependent() const { return ValueDependent; } + /// \brief Set whether this expression is value-dependent or not. + void setValueDependent(bool VD) { ValueDependent = VD; } + /// isTypeDependent - Determines whether this expression is /// type-dependent (C++ [temp.dep.expr]), which means that its type /// could change from one template instantiation to the next. For @@ -101,6 +107,9 @@ public: /// @endcode bool isTypeDependent() const { return TypeDependent; } + /// \brief Set whether this expression is type-dependent or not. + void setTypeDependent(bool TD) { TypeDependent = TD; } + /// 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. @@ -315,11 +324,16 @@ public: DeclRefExpr(NamedDecl *d, QualType t, SourceLocation l, bool TD, bool VD) : Expr(DeclRefExprClass, t, TD, VD), D(d), Loc(l) {} + /// \brief Construct an empty declaration reference expression. + explicit DeclRefExpr(EmptyShell Empty) + : Expr(DeclRefExprClass, Empty) { } + NamedDecl *getDecl() { return D; } const NamedDecl *getDecl() const { return D; } void setDecl(NamedDecl *NewD) { D = NewD; } SourceLocation getLocation() const { return Loc; } + void setLocation(SourceLocation L) { Loc = L; } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } static bool classof(const Stmt *T) { @@ -381,6 +395,10 @@ public: assert(type->isIntegerType() && "Illegal type in IntegerLiteral"); } + /// \brief Construct an empty integer literal. + explicit IntegerLiteral(EmptyShell Empty) + : Expr(IntegerLiteralClass, Empty) { } + IntegerLiteral* Clone(ASTContext &C) const; const llvm::APInt &getValue() const { return Value; } @@ -389,6 +407,9 @@ public: /// \brief Retrieve the location of the literal. SourceLocation getLocation() const { return Loc; } + void setValue(const llvm::APInt &Val) { Value = Val; } + void setLocation(SourceLocation Location) { Loc = Location; } + static bool classof(const Stmt *T) { return T->getStmtClass() == IntegerLiteralClass; } @@ -411,6 +432,10 @@ public: CharacterLiteral(unsigned value, bool iswide, QualType type, SourceLocation l) : Expr(CharacterLiteralClass, type), Value(value), Loc(l), IsWide(iswide) { } + + /// \brief Construct an empty character literal. + CharacterLiteral(EmptyShell Empty) : Expr(CharacterLiteralClass, Empty) { } + SourceLocation getLoc() const { return Loc; } bool isWide() const { return IsWide; } @@ -418,6 +443,10 @@ public: unsigned getValue() const { return Value; } + void setLocation(SourceLocation Location) { Loc = Location; } + void setWide(bool W) { IsWide = W; } + void setValue(unsigned Val) { Value = Val; } + static bool classof(const Stmt *T) { return T->getStmtClass() == CharacterLiteralClass; } diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index c99f0a9b2fa..c20d602a7cc 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -210,7 +210,12 @@ public: const_child_iterator child_end() const { return const_child_iterator(const_cast<Stmt*>(this)->child_end()); } - + + /// \brief A placeholder type used to construct an empty shell of a + /// type, that will be filled in later (e.g., by some + /// de-serialization). + struct EmptyShell { }; + void Emit(llvm::Serializer& S) const; static Stmt* Create(llvm::Deserializer& D, ASTContext& C); diff --git a/clang/include/clang/Frontend/PCHBitCodes.h b/clang/include/clang/Frontend/PCHBitCodes.h index bda1370c6f7..54f686bbb08 100644 --- a/clang/include/clang/Frontend/PCHBitCodes.h +++ b/clang/include/clang/Frontend/PCHBitCodes.h @@ -359,6 +359,24 @@ namespace clang { /// into a DeclContext via DeclContext::lookup. DECL_CONTEXT_VISIBLE }; + + /// \brief Record codes for each kind of statement or expression. + /// + /// These constants describe the records that describe statements + /// or expressions. These records can occur within either the type + /// or declaration blocks, so they begin with record values of + /// 100. Each constant describes a record for a specific + /// statement or expression class in the AST. + enum StmtCode { + /// \brief A NULL expression. + EXPR_NULL = 100, + /// \brief A DeclRefExpr record. + EXPR_DECL_REF, + /// \brief An IntegerLiteral record. + EXPR_INTEGER_LITERAL, + /// \brief A CharacterLiteral record. + EXPR_CHARACTER_LITERAL + }; /// @} } } // end namespace clang diff --git a/clang/include/clang/Frontend/PCHReader.h b/clang/include/clang/Frontend/PCHReader.h index 6928d26b0c7..b9596b6de26 100644 --- a/clang/include/clang/Frontend/PCHReader.h +++ b/clang/include/clang/Frontend/PCHReader.h @@ -221,6 +221,9 @@ public: /// \brief Read a signed integral value llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx); + /// \brief Reads an expression from the current stream position. + Expr *ReadExpr(); + /// \brief Retrieve the AST context that this PCH reader /// supplements. ASTContext &getContext() { return Context; } diff --git a/clang/include/clang/Frontend/PCHWriter.h b/clang/include/clang/Frontend/PCHWriter.h index a887e71899c..4713b1e4900 100644 --- a/clang/include/clang/Frontend/PCHWriter.h +++ b/clang/include/clang/Frontend/PCHWriter.h @@ -21,7 +21,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include <queue> -#include <vector> namespace llvm { class APInt; @@ -43,6 +42,10 @@ class TargetInfo; /// data structures. This bitstream can be de-serialized via an /// instance of the PCHReader class. class PCHWriter { +public: + typedef llvm::SmallVector<uint64_t, 64> RecordData; + +private: /// \brief The bitstream writer used to emit this precompiled header. llvm::BitstreamWriter &S; @@ -100,6 +103,13 @@ class PCHWriter { /// record. llvm::SmallVector<uint64_t, 16> ExternalDefinitions; + /// \brief Expressions that we've encountered while serializing a + /// declaration or type. + /// + /// The expressions in this queue will be emitted following the + /// declaration or type. + std::queue<Expr *> ExprsToEmit; + void WriteTargetTriple(const TargetInfo &Target); void WriteLanguageOptions(const LangOptions &LangOpts); void WriteSourceManagerBlock(SourceManager &SourceMgr); @@ -112,8 +122,6 @@ class PCHWriter { void WriteIdentifierTable(); public: - typedef llvm::SmallVector<uint64_t, 64> RecordData; - /// \brief Create a new precompiled header writer that outputs to /// the given bitstream. PCHWriter(llvm::BitstreamWriter &S); @@ -141,6 +149,14 @@ public: /// \brief Emit a declaration name. void AddDeclarationName(DeclarationName Name, RecordData &Record); + + /// \brief Add the given expression to the queue of expressions to + /// emit. + void AddExpr(Expr *E) { ExprsToEmit.push(E); } + + /// \brief Flush all of the expressions that have been added to the + /// queue via AddExpr(). + void FlushExprs(); }; } // end namespace clang |