[cfe-commits] r69319 - in /cfe/trunk: include/clang/Frontend/PCHBitCodes.h include/clang/Frontend/PCHReader.h include/clang/Frontend/PCHWriter.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp
Douglas Gregor
dgregor at apple.com
Thu Apr 16 15:23:13 PDT 2009
Author: dgregor
Date: Thu Apr 16 17:23:12 2009
New Revision: 69319
URL: http://llvm.org/viewvc/llvm-project?rev=69319&view=rev
Log:
Prepare PCH reader and writer for (de-)serialization of statements. No
functionality change.
Modified:
cfe/trunk/include/clang/Frontend/PCHBitCodes.h
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/include/clang/Frontend/PCHWriter.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHBitCodes.h?rev=69319&r1=69318&r2=69319&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHBitCodes.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHBitCodes.h Thu Apr 16 17:23:12 2009
@@ -372,9 +372,9 @@
enum StmtCode {
/// \brief A marker record that indicates that we are at the end
/// of an expression.
- EXPR_STOP,
+ STMT_STOP,
/// \brief A NULL expression.
- EXPR_NULL,
+ STMT_NULL_PTR,
/// \brief A PredefinedExpr record.
EXPR_PREDEFINED,
/// \brief A DeclRefExpr record.
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=69319&r1=69318&r2=69319&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Thu Apr 16 17:23:12 2009
@@ -235,6 +235,9 @@
/// \brief Reads an expression from the current stream position.
Expr *ReadExpr();
+ /// \brief Reads a statement from the current stream position.
+ Stmt *ReadStmt();
+
/// \brief Retrieve the AST context that this PCH reader
/// supplements.
ASTContext &getContext() { return Context; }
Modified: cfe/trunk/include/clang/Frontend/PCHWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHWriter.h?rev=69319&r1=69318&r2=69319&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHWriter.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHWriter.h Thu Apr 16 17:23:12 2009
@@ -48,7 +48,7 @@
private:
/// \brief The bitstream writer used to emit this precompiled header.
- llvm::BitstreamWriter &S;
+ llvm::BitstreamWriter &Stream;
/// \brief Map that provides the ID numbers of each declaration within
/// the output stream.
@@ -104,9 +104,9 @@
/// record.
llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
- /// \brief Expressions that we've encountered while serializing a
+ /// \brief Statements that we've encountered while serializing a
/// declaration or type.
- llvm::SmallVector<Expr *, 8> ExprsToEmit;
+ llvm::SmallVector<Stmt *, 8> StmtsToEmit;
void WriteTargetTriple(const TargetInfo &Target);
void WriteLanguageOptions(const LangOptions &LangOpts);
@@ -125,7 +125,7 @@
public:
/// \brief Create a new precompiled header writer that outputs to
/// the given bitstream.
- PCHWriter(llvm::BitstreamWriter &S);
+ PCHWriter(llvm::BitstreamWriter &Stream);
/// \brief Write a precompiled header for the given AST context.
void WritePCH(ASTContext &Context, const Preprocessor &PP);
@@ -154,22 +154,22 @@
/// \brief Emit a declaration name.
void AddDeclarationName(DeclarationName Name, RecordData &Record);
- /// \brief Add the given expression to the queue of expressions to
+ /// \brief Add the given statement or expression to the queue of statements to
/// emit.
///
/// This routine should be used when emitting types and declarations
/// that have expressions as part of their formulation. Once the
- /// type or declaration has been written, call FlushExprs() to write
- /// the corresponding expressions just after the type or
+ /// type or declaration has been written, call FlushStmts() to write
+ /// the corresponding statements just after the type or
/// declaration.
- void AddExpr(Expr *E) { ExprsToEmit.push_back(E); }
+ void AddStmt(Stmt *S) { StmtsToEmit.push_back(S); }
/// \brief Write the given subexpression to the bitstream.
- void WriteSubExpr(Expr *E);
+ void WriteSubStmt(Stmt *S);
- /// \brief Flush all of the expressions that have been added to the
- /// queue via AddExpr().
- void FlushExprs();
+ /// \brief Flush all of the statements and expressions that have
+ /// been added to the queue via AddStmt().
+ void FlushStmts();
};
} // end namespace clang
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=69319&r1=69318&r2=69319&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Thu Apr 16 17:23:12 2009
@@ -220,12 +220,12 @@
PCHReader &Reader;
const PCHReader::RecordData &Record;
unsigned &Idx;
- llvm::SmallVectorImpl<Expr *> &ExprStack;
+ llvm::SmallVectorImpl<Stmt *> &StmtStack;
public:
PCHStmtReader(PCHReader &Reader, const PCHReader::RecordData &Record,
- unsigned &Idx, llvm::SmallVectorImpl<Expr *> &ExprStack)
- : Reader(Reader), Record(Record), Idx(Idx), ExprStack(ExprStack) { }
+ unsigned &Idx, llvm::SmallVectorImpl<Stmt *> &StmtStack)
+ : Reader(Reader), Record(Record), Idx(Idx), StmtStack(StmtStack) { }
/// \brief The number of record fields required for the Expr class
/// itself.
@@ -310,7 +310,7 @@
unsigned PCHStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
VisitExpr(E);
- E->setSubExpr(ExprStack.back());
+ E->setSubExpr(cast<Expr>(StmtStack.back()));
return 1;
}
@@ -346,13 +346,13 @@
VisitExpr(E);
E->setLParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParen(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setSubExpr(ExprStack.back());
+ E->setSubExpr(cast<Expr>(StmtStack.back()));
return 1;
}
unsigned PCHStmtReader::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
- E->setSubExpr(ExprStack.back());
+ E->setSubExpr(cast<Expr>(StmtStack.back()));
E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 1;
@@ -362,7 +362,7 @@
VisitExpr(E);
E->setSizeof(Record[Idx++]);
if (Record[Idx] == 0) {
- E->setArgument(ExprStack.back());
+ E->setArgument(cast<Expr>(StmtStack.back()));
++Idx;
} else {
E->setArgument(Reader.GetType(Record[Idx++]));
@@ -374,8 +374,8 @@
unsigned PCHStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
VisitExpr(E);
- E->setLHS(ExprStack[ExprStack.size() - 2]);
- E->setRHS(ExprStack[ExprStack.size() - 2]);
+ E->setLHS(cast<Expr>(StmtStack[StmtStack.size() - 2]));
+ E->setRHS(cast<Expr>(StmtStack[StmtStack.size() - 2]));
E->setRBracketLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 2;
}
@@ -384,15 +384,15 @@
VisitExpr(E);
E->setNumArgs(Reader.getContext(), Record[Idx++]);
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setCallee(ExprStack[ExprStack.size() - E->getNumArgs() - 1]);
+ E->setCallee(cast<Expr>(StmtStack[StmtStack.size() - E->getNumArgs() - 1]));
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, ExprStack[ExprStack.size() - N + I]);
+ E->setArg(I, cast<Expr>(StmtStack[StmtStack.size() - N + I]));
return E->getNumArgs() + 1;
}
unsigned PCHStmtReader::VisitMemberExpr(MemberExpr *E) {
VisitExpr(E);
- E->setBase(ExprStack.back());
+ E->setBase(cast<Expr>(StmtStack.back()));
E->setMemberDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
E->setMemberLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setArrow(Record[Idx++]);
@@ -401,14 +401,14 @@
unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
- E->setSubExpr(ExprStack.back());
+ E->setSubExpr(cast<Expr>(StmtStack.back()));
return 1;
}
unsigned PCHStmtReader::VisitBinaryOperator(BinaryOperator *E) {
VisitExpr(E);
- E->setLHS(ExprStack.end()[-2]);
- E->setRHS(ExprStack.end()[-1]);
+ E->setLHS(cast<Expr>(StmtStack.end()[-2]));
+ E->setRHS(cast<Expr>(StmtStack.end()[-1]));
E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
E->setOperatorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 2;
@@ -423,9 +423,9 @@
unsigned PCHStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
VisitExpr(E);
- E->setCond(ExprStack[ExprStack.size() - 3]);
- E->setLHS(ExprStack[ExprStack.size() - 2]);
- E->setRHS(ExprStack[ExprStack.size() - 1]);
+ E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3]));
+ E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
+ E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1]));
return 3;
}
@@ -451,14 +451,14 @@
unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
VisitExpr(E);
E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
- E->setInitializer(ExprStack.back());
+ E->setInitializer(cast<Expr>(StmtStack.back()));
E->setFileScope(Record[Idx++]);
return 1;
}
unsigned PCHStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
- E->setBase(ExprStack.back());
+ E->setBase(cast<Expr>(StmtStack.back()));
E->setAccessor(Reader.GetIdentifierInfo(Record, Idx));
E->setAccessorLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 1;
@@ -469,8 +469,9 @@
unsigned NumInits = Record[Idx++];
E->reserveInits(NumInits);
for (unsigned I = 0; I != NumInits; ++I)
- E->updateInit(I, ExprStack[ExprStack.size() - NumInits - 1 + I]);
- E->setSyntacticForm(cast_or_null<InitListExpr>(ExprStack.back()));
+ E->updateInit(I,
+ cast<Expr>(StmtStack[StmtStack.size() - NumInits - 1 + I]));
+ E->setSyntacticForm(cast_or_null<InitListExpr>(StmtStack.back()));
E->setLBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setInitializedFieldInUnion(
@@ -486,7 +487,7 @@
unsigned NumSubExprs = Record[Idx++];
assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
for (unsigned I = 0; I != NumSubExprs; ++I)
- E->setSubExpr(I, ExprStack[ExprStack.size() - NumSubExprs + I]);
+ E->setSubExpr(I, cast<Expr>(StmtStack[StmtStack.size() - NumSubExprs + I]));
E->setEqualOrColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setGNUSyntax(Record[Idx++]);
@@ -551,7 +552,7 @@
unsigned PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) {
VisitExpr(E);
- E->setSubExpr(ExprStack.back());
+ E->setSubExpr(cast<Expr>(StmtStack.back()));
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 1;
@@ -568,9 +569,9 @@
unsigned PCHStmtReader::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
- E->setCond(ExprStack[ExprStack.size() - 3]);
- E->setLHS(ExprStack[ExprStack.size() - 2]);
- E->setRHS(ExprStack[ExprStack.size() - 1]);
+ E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3]));
+ E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
+ E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1]));
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return 3;
@@ -585,7 +586,7 @@
unsigned PCHStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
VisitExpr(E);
unsigned NumExprs = Record[Idx++];
- E->setExprs(&ExprStack[ExprStack.size() - NumExprs], NumExprs);
+ E->setExprs((Expr **)&StmtStack[StmtStack.size() - NumExprs], NumExprs);
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
return NumExprs;
@@ -1982,18 +1983,18 @@
return PrevAttr;
}
-Expr *PCHReader::ReadExpr() {
+Stmt *PCHReader::ReadStmt() {
// Within the bitstream, expressions are stored in Reverse Polish
// Notation, with each of the subexpressions preceding the
// expression they are stored in. To evaluate expressions, we
// continue reading expressions and placing them on the stack, with
// expressions having operands removing those operands from the
- // stack. Evaluation terminates when we see a EXPR_STOP record, and
+ // stack. Evaluation terminates when we see a STMT_STOP record, and
// the single remaining expression on the stack is our result.
RecordData Record;
unsigned Idx;
- llvm::SmallVector<Expr *, 16> ExprStack;
- PCHStmtReader Reader(*this, Record, Idx, ExprStack);
+ llvm::SmallVector<Stmt *, 16> StmtStack;
+ PCHStmtReader Reader(*this, Record, Idx, StmtStack);
Stmt::EmptyShell Empty;
while (true) {
@@ -2021,159 +2022,163 @@
continue;
}
- Expr *E = 0;
+ Stmt *S = 0;
Idx = 0;
Record.clear();
bool Finished = false;
switch ((pch::StmtCode)Stream.ReadRecord(Code, Record)) {
- case pch::EXPR_STOP:
+ case pch::STMT_STOP:
Finished = true;
break;
- case pch::EXPR_NULL:
- E = 0;
+ case pch::STMT_NULL_PTR:
+ S = 0;
break;
case pch::EXPR_PREDEFINED:
// FIXME: untested (until we can serialize function bodies).
- E = new (Context) PredefinedExpr(Empty);
+ S = new (Context) PredefinedExpr(Empty);
break;
case pch::EXPR_DECL_REF:
- E = new (Context) DeclRefExpr(Empty);
+ S = new (Context) DeclRefExpr(Empty);
break;
case pch::EXPR_INTEGER_LITERAL:
- E = new (Context) IntegerLiteral(Empty);
+ S = new (Context) IntegerLiteral(Empty);
break;
case pch::EXPR_FLOATING_LITERAL:
- E = new (Context) FloatingLiteral(Empty);
+ S = new (Context) FloatingLiteral(Empty);
break;
case pch::EXPR_IMAGINARY_LITERAL:
- E = new (Context) ImaginaryLiteral(Empty);
+ S = new (Context) ImaginaryLiteral(Empty);
break;
case pch::EXPR_STRING_LITERAL:
- E = StringLiteral::CreateEmpty(Context,
+ S = StringLiteral::CreateEmpty(Context,
Record[PCHStmtReader::NumExprFields + 1]);
break;
case pch::EXPR_CHARACTER_LITERAL:
- E = new (Context) CharacterLiteral(Empty);
+ S = new (Context) CharacterLiteral(Empty);
break;
case pch::EXPR_PAREN:
- E = new (Context) ParenExpr(Empty);
+ S = new (Context) ParenExpr(Empty);
break;
case pch::EXPR_UNARY_OPERATOR:
- E = new (Context) UnaryOperator(Empty);
+ S = new (Context) UnaryOperator(Empty);
break;
case pch::EXPR_SIZEOF_ALIGN_OF:
- E = new (Context) SizeOfAlignOfExpr(Empty);
+ S = new (Context) SizeOfAlignOfExpr(Empty);
break;
case pch::EXPR_ARRAY_SUBSCRIPT:
- E = new (Context) ArraySubscriptExpr(Empty);
+ S = new (Context) ArraySubscriptExpr(Empty);
break;
case pch::EXPR_CALL:
- E = new (Context) CallExpr(Context, Empty);
+ S = new (Context) CallExpr(Context, Empty);
break;
case pch::EXPR_MEMBER:
- E = new (Context) MemberExpr(Empty);
+ S = new (Context) MemberExpr(Empty);
break;
case pch::EXPR_BINARY_OPERATOR:
- E = new (Context) BinaryOperator(Empty);
+ S = new (Context) BinaryOperator(Empty);
break;
case pch::EXPR_COMPOUND_ASSIGN_OPERATOR:
- E = new (Context) CompoundAssignOperator(Empty);
+ S = new (Context) CompoundAssignOperator(Empty);
break;
case pch::EXPR_CONDITIONAL_OPERATOR:
- E = new (Context) ConditionalOperator(Empty);
+ S = new (Context) ConditionalOperator(Empty);
break;
case pch::EXPR_IMPLICIT_CAST:
- E = new (Context) ImplicitCastExpr(Empty);
+ S = new (Context) ImplicitCastExpr(Empty);
break;
case pch::EXPR_CSTYLE_CAST:
- E = new (Context) CStyleCastExpr(Empty);
+ S = new (Context) CStyleCastExpr(Empty);
break;
case pch::EXPR_COMPOUND_LITERAL:
- E = new (Context) CompoundLiteralExpr(Empty);
+ S = new (Context) CompoundLiteralExpr(Empty);
break;
case pch::EXPR_EXT_VECTOR_ELEMENT:
- E = new (Context) ExtVectorElementExpr(Empty);
+ S = new (Context) ExtVectorElementExpr(Empty);
break;
case pch::EXPR_INIT_LIST:
- E = new (Context) InitListExpr(Empty);
+ S = new (Context) InitListExpr(Empty);
break;
case pch::EXPR_DESIGNATED_INIT:
- E = DesignatedInitExpr::CreateEmpty(Context,
+ S = DesignatedInitExpr::CreateEmpty(Context,
Record[PCHStmtReader::NumExprFields] - 1);
break;
case pch::EXPR_IMPLICIT_VALUE_INIT:
- E = new (Context) ImplicitValueInitExpr(Empty);
+ S = new (Context) ImplicitValueInitExpr(Empty);
break;
case pch::EXPR_VA_ARG:
// FIXME: untested; we need function bodies first
- E = new (Context) VAArgExpr(Empty);
+ S = new (Context) VAArgExpr(Empty);
break;
case pch::EXPR_TYPES_COMPATIBLE:
- E = new (Context) TypesCompatibleExpr(Empty);
+ S = new (Context) TypesCompatibleExpr(Empty);
break;
case pch::EXPR_CHOOSE:
- E = new (Context) ChooseExpr(Empty);
+ S = new (Context) ChooseExpr(Empty);
break;
case pch::EXPR_GNU_NULL:
- E = new (Context) GNUNullExpr(Empty);
+ S = new (Context) GNUNullExpr(Empty);
break;
case pch::EXPR_SHUFFLE_VECTOR:
- E = new (Context) ShuffleVectorExpr(Empty);
+ S = new (Context) ShuffleVectorExpr(Empty);
break;
case pch::EXPR_BLOCK_DECL_REF:
// FIXME: untested until we have statement and block support
- E = new (Context) BlockDeclRefExpr(Empty);
+ S = new (Context) BlockDeclRefExpr(Empty);
break;
}
- // We hit an EXPR_STOP, so we're done with this expression.
+ // We hit a STMT_STOP, so we're done with this expression.
if (Finished)
break;
- if (E) {
- unsigned NumSubExprs = Reader.Visit(E);
- while (NumSubExprs > 0) {
- ExprStack.pop_back();
- --NumSubExprs;
+ if (S) {
+ unsigned NumSubStmts = Reader.Visit(S);
+ while (NumSubStmts > 0) {
+ StmtStack.pop_back();
+ --NumSubStmts;
}
}
assert(Idx == Record.size() && "Invalid deserialization of expression");
- ExprStack.push_back(E);
+ StmtStack.push_back(S);
}
- assert(ExprStack.size() == 1 && "Extra expressions on stack!");
- return ExprStack.back();
+ assert(StmtStack.size() == 1 && "Extra expressions on stack!");
+ return StmtStack.back();
+}
+
+Expr *PCHReader::ReadExpr() {
+ return dyn_cast_or_null<Expr>(ReadStmt());
}
DiagnosticBuilder PCHReader::Diag(unsigned DiagID) {
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=69319&r1=69318&r2=69319&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Thu Apr 16 17:23:12 2009
@@ -126,7 +126,7 @@
void PCHTypeWriter::VisitVariableArrayType(const VariableArrayType *T) {
VisitArrayType(T);
- Writer.AddExpr(T->getSizeExpr());
+ Writer.AddStmt(T->getSizeExpr());
Code = pch::TYPE_VARIABLE_ARRAY;
}
@@ -166,7 +166,7 @@
}
void PCHTypeWriter::VisitTypeOfExprType(const TypeOfExprType *T) {
- Writer.AddExpr(T->getUnderlyingExpr());
+ Writer.AddStmt(T->getUnderlyingExpr());
Code = pch::TYPE_TYPEOF_EXPR;
}
@@ -331,7 +331,7 @@
VisitValueDecl(D);
Record.push_back(D->getInitExpr()? 1 : 0);
if (D->getInitExpr())
- Writer.AddExpr(D->getInitExpr());
+ Writer.AddStmt(D->getInitExpr());
Writer.AddAPSInt(D->getInitVal(), Record);
Code = pch::DECL_ENUM_CONSTANT;
}
@@ -360,7 +360,7 @@
Record.push_back(D->isMutable());
Record.push_back(D->getBitWidth()? 1 : 0);
if (D->getBitWidth())
- Writer.AddExpr(D->getBitWidth());
+ Writer.AddStmt(D->getBitWidth());
Code = pch::DECL_FIELD;
}
@@ -374,7 +374,7 @@
Writer.AddSourceLocation(D->getTypeSpecStartLoc(), Record);
Record.push_back(D->getInit()? 1 : 0);
if (D->getInit())
- Writer.AddExpr(D->getInit());
+ Writer.AddStmt(D->getInit());
Code = pch::DECL_VAR;
}
@@ -395,7 +395,7 @@
void PCHDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
VisitDecl(D);
- Writer.AddExpr(D->getAsmString());
+ Writer.AddStmt(D->getAsmString());
Code = pch::DECL_FILE_SCOPE_ASM;
}
@@ -515,7 +515,7 @@
void PCHStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getSubExpr());
+ Writer.WriteSubStmt(E->getSubExpr());
Code = pch::EXPR_IMAGINARY_LITERAL;
}
@@ -547,13 +547,13 @@
VisitExpr(E);
Writer.AddSourceLocation(E->getLParen(), Record);
Writer.AddSourceLocation(E->getRParen(), Record);
- Writer.WriteSubExpr(E->getSubExpr());
+ Writer.WriteSubStmt(E->getSubExpr());
Code = pch::EXPR_PAREN;
}
void PCHStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getSubExpr());
+ Writer.WriteSubStmt(E->getSubExpr());
Record.push_back(E->getOpcode()); // FIXME: stable encoding
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
Code = pch::EXPR_UNARY_OPERATOR;
@@ -566,7 +566,7 @@
Writer.AddTypeRef(E->getArgumentType(), Record);
else {
Record.push_back(0);
- Writer.WriteSubExpr(E->getArgumentExpr());
+ Writer.WriteSubStmt(E->getArgumentExpr());
}
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
@@ -575,8 +575,8 @@
void PCHStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getLHS());
- Writer.WriteSubExpr(E->getRHS());
+ Writer.WriteSubStmt(E->getLHS());
+ Writer.WriteSubStmt(E->getRHS());
Writer.AddSourceLocation(E->getRBracketLoc(), Record);
Code = pch::EXPR_ARRAY_SUBSCRIPT;
}
@@ -585,16 +585,16 @@
VisitExpr(E);
Record.push_back(E->getNumArgs());
Writer.AddSourceLocation(E->getRParenLoc(), Record);
- Writer.WriteSubExpr(E->getCallee());
+ Writer.WriteSubStmt(E->getCallee());
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg)
- Writer.WriteSubExpr(*Arg);
+ Writer.WriteSubStmt(*Arg);
Code = pch::EXPR_CALL;
}
void PCHStmtWriter::VisitMemberExpr(MemberExpr *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getBase());
+ Writer.WriteSubStmt(E->getBase());
Writer.AddDeclRef(E->getMemberDecl(), Record);
Writer.AddSourceLocation(E->getMemberLoc(), Record);
Record.push_back(E->isArrow());
@@ -603,13 +603,13 @@
void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getSubExpr());
+ Writer.WriteSubStmt(E->getSubExpr());
}
void PCHStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getLHS());
- Writer.WriteSubExpr(E->getRHS());
+ Writer.WriteSubStmt(E->getLHS());
+ Writer.WriteSubStmt(E->getRHS());
Record.push_back(E->getOpcode()); // FIXME: stable encoding
Writer.AddSourceLocation(E->getOperatorLoc(), Record);
Code = pch::EXPR_BINARY_OPERATOR;
@@ -624,9 +624,9 @@
void PCHStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getCond());
- Writer.WriteSubExpr(E->getLHS());
- Writer.WriteSubExpr(E->getRHS());
+ Writer.WriteSubStmt(E->getCond());
+ Writer.WriteSubStmt(E->getLHS());
+ Writer.WriteSubStmt(E->getRHS());
Code = pch::EXPR_CONDITIONAL_OPERATOR;
}
@@ -651,14 +651,14 @@
void PCHStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
VisitExpr(E);
Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.WriteSubExpr(E->getInitializer());
+ Writer.WriteSubStmt(E->getInitializer());
Record.push_back(E->isFileScope());
Code = pch::EXPR_COMPOUND_LITERAL;
}
void PCHStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getBase());
+ Writer.WriteSubStmt(E->getBase());
Writer.AddIdentifierRef(&E->getAccessor(), Record);
Writer.AddSourceLocation(E->getAccessorLoc(), Record);
Code = pch::EXPR_EXT_VECTOR_ELEMENT;
@@ -668,8 +668,8 @@
VisitExpr(E);
Record.push_back(E->getNumInits());
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
- Writer.WriteSubExpr(E->getInit(I));
- Writer.WriteSubExpr(E->getSyntacticForm());
+ Writer.WriteSubStmt(E->getInit(I));
+ Writer.WriteSubStmt(E->getSyntacticForm());
Writer.AddSourceLocation(E->getLBraceLoc(), Record);
Writer.AddSourceLocation(E->getRBraceLoc(), Record);
Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record);
@@ -681,7 +681,7 @@
VisitExpr(E);
Record.push_back(E->getNumSubExprs());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
- Writer.WriteSubExpr(E->getSubExpr(I));
+ Writer.WriteSubStmt(E->getSubExpr(I));
Writer.AddSourceLocation(E->getEqualOrColonLoc(), Record);
Record.push_back(E->usesGNUSyntax());
for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
@@ -721,7 +721,7 @@
void PCHStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getSubExpr());
+ Writer.WriteSubStmt(E->getSubExpr());
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_VA_ARG;
@@ -738,9 +738,9 @@
void PCHStmtWriter::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
- Writer.WriteSubExpr(E->getCond());
- Writer.WriteSubExpr(E->getLHS());
- Writer.WriteSubExpr(E->getRHS());
+ Writer.WriteSubStmt(E->getCond());
+ Writer.WriteSubStmt(E->getLHS());
+ Writer.WriteSubStmt(E->getRHS());
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_CHOOSE;
@@ -756,7 +756,7 @@
VisitExpr(E);
Record.push_back(E->getNumSubExprs());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
- Writer.WriteSubExpr(E->getExpr(I));
+ Writer.WriteSubStmt(E->getExpr(I));
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
Writer.AddSourceLocation(E->getRParenLoc(), Record);
Code = pch::EXPR_SHUFFLE_VECTOR;
@@ -780,12 +780,12 @@
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::TARGET_TRIPLE));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Triple name
- unsigned TripleAbbrev = S.EmitAbbrev(Abbrev);
+ unsigned TripleAbbrev = Stream.EmitAbbrev(Abbrev);
RecordData Record;
Record.push_back(pch::TARGET_TRIPLE);
const char *Triple = Target.getTargetTriple();
- S.EmitRecordWithBlob(TripleAbbrev, Record, Triple, strlen(Triple));
+ Stream.EmitRecordWithBlob(TripleAbbrev, Record, Triple, strlen(Triple));
}
/// \brief Write the LangOptions structure.
@@ -847,7 +847,7 @@
Record.push_back(LangOpts.getGCMode());
Record.push_back(LangOpts.getVisibilityMode());
Record.push_back(LangOpts.InstantiationDepth);
- S.EmitRecord(pch::LANGUAGE_OPTIONS, Record);
+ Stream.EmitRecord(pch::LANGUAGE_OPTIONS, Record);
}
//===----------------------------------------------------------------------===//
@@ -856,7 +856,7 @@
/// \brief Create an abbreviation for the SLocEntry that refers to a
/// file.
-static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &S) {
+static unsigned CreateSLocFileAbbrev(llvm::BitstreamWriter &Stream) {
using namespace llvm;
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::SM_SLOC_FILE_ENTRY));
@@ -865,12 +865,12 @@
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
- return S.EmitAbbrev(Abbrev);
+ return Stream.EmitAbbrev(Abbrev);
}
/// \brief Create an abbreviation for the SLocEntry that refers to a
/// buffer.
-static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &S) {
+static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream) {
using namespace llvm;
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::SM_SLOC_BUFFER_ENTRY));
@@ -879,22 +879,22 @@
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Characteristic
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Line directives
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Buffer name blob
- return S.EmitAbbrev(Abbrev);
+ return Stream.EmitAbbrev(Abbrev);
}
/// \brief Create an abbreviation for the SLocEntry that refers to a
/// buffer's blob.
-static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &S) {
+static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream) {
using namespace llvm;
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::SM_SLOC_BUFFER_BLOB));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Blob
- return S.EmitAbbrev(Abbrev);
+ return Stream.EmitAbbrev(Abbrev);
}
/// \brief Create an abbreviation for the SLocEntry that refers to an
/// buffer.
-static unsigned CreateSLocInstantiationAbbrev(llvm::BitstreamWriter &S) {
+static unsigned CreateSLocInstantiationAbbrev(llvm::BitstreamWriter &Stream) {
using namespace llvm;
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::SM_SLOC_INSTANTIATION_ENTRY));
@@ -903,7 +903,7 @@
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Start location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // End location
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
- return S.EmitAbbrev(Abbrev);
+ return Stream.EmitAbbrev(Abbrev);
}
/// \brief Writes the block containing the serialized form of the
@@ -916,7 +916,7 @@
/// the files in the AST.
void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
// Enter the source manager block.
- S.EnterSubblock(pch::SOURCE_MANAGER_BLOCK_ID, 3);
+ Stream.EnterSubblock(pch::SOURCE_MANAGER_BLOCK_ID, 3);
// Abbreviations for the various kinds of source-location entries.
int SLocFileAbbrv = -1;
@@ -954,16 +954,16 @@
// The source location entry is a file. The blob associated
// with this entry is the file name.
if (SLocFileAbbrv == -1)
- SLocFileAbbrv = CreateSLocFileAbbrev(S);
- S.EmitRecordWithBlob(SLocFileAbbrv, Record,
+ SLocFileAbbrv = CreateSLocFileAbbrev(Stream);
+ Stream.EmitRecordWithBlob(SLocFileAbbrv, Record,
Content->Entry->getName(),
strlen(Content->Entry->getName()));
} else {
// The source location entry is a buffer. The blob associated
// with this entry contains the contents of the buffer.
if (SLocBufferAbbrv == -1) {
- SLocBufferAbbrv = CreateSLocBufferAbbrev(S);
- SLocBufferBlobAbbrv = CreateSLocBufferBlobAbbrev(S);
+ SLocBufferAbbrv = CreateSLocBufferAbbrev(Stream);
+ SLocBufferBlobAbbrv = CreateSLocBufferBlobAbbrev(Stream);
}
// We add one to the size so that we capture the trailing NULL
@@ -971,10 +971,10 @@
// the reader side).
const llvm::MemoryBuffer *Buffer = Content->getBuffer();
const char *Name = Buffer->getBufferIdentifier();
- S.EmitRecordWithBlob(SLocBufferAbbrv, Record, Name, strlen(Name) + 1);
+ Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record, Name, strlen(Name) + 1);
Record.clear();
Record.push_back(pch::SM_SLOC_BUFFER_BLOB);
- S.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
+ Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
Buffer->getBufferStart(),
Buffer->getBufferSize() + 1);
}
@@ -993,8 +993,8 @@
Record.push_back(NextOffset - SLoc->getOffset() - 1);
if (SLocInstantiationAbbrv == -1)
- SLocInstantiationAbbrv = CreateSLocInstantiationAbbrev(S);
- S.EmitRecordWithAbbrev(SLocInstantiationAbbrv, Record);
+ SLocInstantiationAbbrv = CreateSLocInstantiationAbbrev(Stream);
+ Stream.EmitRecordWithAbbrev(SLocInstantiationAbbrv, Record);
}
Record.clear();
@@ -1032,11 +1032,11 @@
Record.push_back((unsigned)LE->FileKind);
Record.push_back(LE->IncludeOffset);
}
- S.EmitRecord(pch::SM_LINE_TABLE, Record);
+ Stream.EmitRecord(pch::SM_LINE_TABLE, Record);
}
}
- S.ExitBlock();
+ Stream.ExitBlock();
}
/// \brief Writes the block containing the serialized form of the
@@ -1044,7 +1044,7 @@
///
void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
// Enter the preprocessor block.
- S.EnterSubblock(pch::PREPROCESSOR_BLOCK_ID, 3);
+ Stream.EnterSubblock(pch::PREPROCESSOR_BLOCK_ID, 3);
// If the PCH file contains __DATE__ or __TIME__ emit a warning about this.
// FIXME: use diagnostics subsystem for localization etc.
@@ -1056,7 +1056,7 @@
// If the preprocessor __COUNTER__ value has been bumped, remember it.
if (PP.getCounterValue() != 0) {
Record.push_back(PP.getCounterValue());
- S.EmitRecord(pch::PP_COUNTER_VALUE, Record);
+ Stream.EmitRecord(pch::PP_COUNTER_VALUE, Record);
Record.clear();
}
@@ -1092,7 +1092,7 @@
I != E; ++I)
AddIdentifierRef(*I, Record);
}
- S.EmitRecord(Code, Record);
+ Stream.EmitRecord(Code, Record);
Record.clear();
// Emit the tokens array.
@@ -1114,13 +1114,13 @@
// FIXME: Should translate token flags to a stable encoding.
Record.push_back(Tok.getFlags());
- S.EmitRecord(pch::PP_TOKEN, Record);
+ Stream.EmitRecord(pch::PP_TOKEN, Record);
Record.clear();
}
}
- S.ExitBlock();
+ Stream.ExitBlock();
}
@@ -1132,10 +1132,10 @@
// Record the offset for this type.
if (TypeOffsets.size() == ID - pch::NUM_PREDEF_TYPE_IDS)
- TypeOffsets.push_back(S.GetCurrentBitNo());
+ TypeOffsets.push_back(Stream.GetCurrentBitNo());
else if (TypeOffsets.size() < ID - pch::NUM_PREDEF_TYPE_IDS) {
TypeOffsets.resize(ID + 1 - pch::NUM_PREDEF_TYPE_IDS);
- TypeOffsets[ID - pch::NUM_PREDEF_TYPE_IDS] = S.GetCurrentBitNo();
+ TypeOffsets[ID - pch::NUM_PREDEF_TYPE_IDS] = Stream.GetCurrentBitNo();
}
RecordData Record;
@@ -1161,16 +1161,16 @@
}
// Emit the serialized record.
- S.EmitRecord(W.Code, Record);
+ Stream.EmitRecord(W.Code, Record);
// Flush any expressions that were written as part of this type.
- FlushExprs();
+ FlushStmts();
}
/// \brief Write a block containing all of the types.
void PCHWriter::WriteTypesBlock(ASTContext &Context) {
// Enter the types block.
- S.EnterSubblock(pch::TYPES_BLOCK_ID, 2);
+ Stream.EnterSubblock(pch::TYPES_BLOCK_ID, 2);
// Emit all of the types in the ASTContext
for (std::vector<Type*>::const_iterator T = Context.getTypes().begin(),
@@ -1184,7 +1184,7 @@
}
// Exit the types block
- S.ExitBlock();
+ Stream.ExitBlock();
}
/// \brief Write the block containing all of the declaration IDs
@@ -1197,14 +1197,14 @@
if (DC->decls_empty(Context))
return 0;
- uint64_t Offset = S.GetCurrentBitNo();
+ uint64_t Offset = Stream.GetCurrentBitNo();
RecordData Record;
for (DeclContext::decl_iterator D = DC->decls_begin(Context),
DEnd = DC->decls_end(Context);
D != DEnd; ++D)
AddDeclRef(*D, Record);
- S.EmitRecord(pch::DECL_CONTEXT_LEXICAL, Record);
+ Stream.EmitRecord(pch::DECL_CONTEXT_LEXICAL, Record);
return Offset;
}
@@ -1226,7 +1226,7 @@
// representation is the same for both cases: a declaration name,
// followed by a size, followed by references to the visible
// declarations that have that name.
- uint64_t Offset = S.GetCurrentBitNo();
+ uint64_t Offset = Stream.GetCurrentBitNo();
RecordData Record;
StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(DC->getLookupPtr());
if (!Map)
@@ -1244,14 +1244,14 @@
if (Record.size() == 0)
return 0;
- S.EmitRecord(pch::DECL_CONTEXT_VISIBLE, Record);
+ Stream.EmitRecord(pch::DECL_CONTEXT_VISIBLE, Record);
return Offset;
}
/// \brief Write a block containing all of the declarations.
void PCHWriter::WriteDeclsBlock(ASTContext &Context) {
// Enter the declarations block.
- S.EnterSubblock(pch::DECLS_BLOCK_ID, 2);
+ Stream.EnterSubblock(pch::DECLS_BLOCK_ID, 2);
// Emit all of the declarations.
RecordData Record;
@@ -1283,10 +1283,10 @@
// Record the offset for this declaration
if (DeclOffsets.size() == Index)
- DeclOffsets.push_back(S.GetCurrentBitNo());
+ DeclOffsets.push_back(Stream.GetCurrentBitNo());
else if (DeclOffsets.size() < Index) {
DeclOffsets.resize(Index+1);
- DeclOffsets[Index] = S.GetCurrentBitNo();
+ DeclOffsets[Index] = Stream.GetCurrentBitNo();
}
// Build and emit a record for this declaration
@@ -1295,14 +1295,14 @@
W.Visit(D);
if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset);
assert(W.Code && "Unhandled declaration kind while generating PCH");
- S.EmitRecord(W.Code, Record);
+ Stream.EmitRecord(W.Code, Record);
// If the declaration had any attributes, write them now.
if (D->hasAttrs())
WriteAttributeRecord(D->getAttrs());
// Flush any expressions that were written as part of this declaration.
- FlushExprs();
+ FlushStmts();
// Note external declarations so that we can add them to a record
// in the PCH file later.
@@ -1327,7 +1327,7 @@
}
// Exit the declarations block
- S.ExitBlock();
+ Stream.ExitBlock();
}
/// \brief Write the identifier table into the PCH file.
@@ -1367,16 +1367,16 @@
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
Abbrev->Add(BitCodeAbbrevOp(pch::IDENTIFIER_TABLE));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Triple name
- unsigned IDTableAbbrev = S.EmitAbbrev(Abbrev);
+ unsigned IDTableAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the identifier table
RecordData Record;
Record.push_back(pch::IDENTIFIER_TABLE);
- S.EmitRecordWithBlob(IDTableAbbrev, Record, &Data.front(), Data.size());
+ Stream.EmitRecordWithBlob(IDTableAbbrev, Record, &Data.front(), Data.size());
}
// Write the offsets table for identifier IDs.
- S.EmitRecord(pch::IDENTIFIER_OFFSET, IdentOffsets);
+ Stream.EmitRecord(pch::IDENTIFIER_OFFSET, IdentOffsets);
}
/// \brief Write a record containing the given attributes.
@@ -1497,7 +1497,7 @@
}
}
- S.EmitRecord(pch::DECL_ATTR, Record);
+ Stream.EmitRecord(pch::DECL_ATTR, Record);
}
void PCHWriter::AddString(const std::string &Str, RecordData &Record) {
@@ -1505,22 +1505,22 @@
Record.insert(Record.end(), Str.begin(), Str.end());
}
-PCHWriter::PCHWriter(llvm::BitstreamWriter &S)
- : S(S), NextTypeID(pch::NUM_PREDEF_TYPE_IDS) { }
+PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream)
+ : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS) { }
void PCHWriter::WritePCH(ASTContext &Context, const Preprocessor &PP) {
// Emit the file header.
- S.Emit((unsigned)'C', 8);
- S.Emit((unsigned)'P', 8);
- S.Emit((unsigned)'C', 8);
- S.Emit((unsigned)'H', 8);
+ Stream.Emit((unsigned)'C', 8);
+ Stream.Emit((unsigned)'P', 8);
+ Stream.Emit((unsigned)'C', 8);
+ Stream.Emit((unsigned)'H', 8);
// The translation unit is the first declaration we'll emit.
DeclIDs[Context.getTranslationUnitDecl()] = 1;
DeclsToEmit.push(Context.getTranslationUnitDecl());
// Write the remaining PCH contents.
- S.EnterSubblock(pch::PCH_BLOCK_ID, 3);
+ Stream.EnterSubblock(pch::PCH_BLOCK_ID, 3);
WriteTargetTriple(Context.Target);
WriteLanguageOptions(Context.getLangOptions());
WriteSourceManagerBlock(Context.getSourceManager());
@@ -1528,11 +1528,11 @@
WriteTypesBlock(Context);
WriteDeclsBlock(Context);
WriteIdentifierTable();
- S.EmitRecord(pch::TYPE_OFFSET, TypeOffsets);
- S.EmitRecord(pch::DECL_OFFSET, DeclOffsets);
+ Stream.EmitRecord(pch::TYPE_OFFSET, TypeOffsets);
+ Stream.EmitRecord(pch::DECL_OFFSET, DeclOffsets);
if (!ExternalDefinitions.empty())
- S.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions);
- S.ExitBlock();
+ Stream.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions);
+ Stream.ExitBlock();
}
void PCHWriter::AddSourceLocation(SourceLocation Loc, RecordData &Record) {
@@ -1658,52 +1658,53 @@
}
}
-/// \brief Write the given subexpression to the bitstream.
-void PCHWriter::WriteSubExpr(Expr *E) {
+/// \brief Write the given substatement or subexpression to the
+/// bitstream.
+void PCHWriter::WriteSubStmt(Stmt *S) {
RecordData Record;
PCHStmtWriter Writer(*this, Record);
- if (!E) {
- S.EmitRecord(pch::EXPR_NULL, Record);
+ if (!S) {
+ Stream.EmitRecord(pch::STMT_NULL_PTR, Record);
return;
}
- Writer.Code = pch::EXPR_NULL;
- Writer.Visit(E);
- assert(Writer.Code != pch::EXPR_NULL &&
+ Writer.Code = pch::STMT_NULL_PTR;
+ Writer.Visit(S);
+ assert(Writer.Code != pch::STMT_NULL_PTR &&
"Unhandled expression writing PCH file");
- S.EmitRecord(Writer.Code, Record);
+ Stream.EmitRecord(Writer.Code, Record);
}
-/// \brief Flush all of the expressions that have been added to the
-/// queue via AddExpr().
-void PCHWriter::FlushExprs() {
+/// \brief Flush all of the statements that have been added to the
+/// queue via AddStmt().
+void PCHWriter::FlushStmts() {
RecordData Record;
PCHStmtWriter Writer(*this, Record);
- for (unsigned I = 0, N = ExprsToEmit.size(); I != N; ++I) {
- Expr *E = ExprsToEmit[I];
+ for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
+ Stmt *S = StmtsToEmit[I];
- if (!E) {
- S.EmitRecord(pch::EXPR_NULL, Record);
+ if (!S) {
+ Stream.EmitRecord(pch::STMT_NULL_PTR, Record);
continue;
}
- Writer.Code = pch::EXPR_NULL;
- Writer.Visit(E);
- assert(Writer.Code != pch::EXPR_NULL &&
+ Writer.Code = pch::STMT_NULL_PTR;
+ Writer.Visit(S);
+ assert(Writer.Code != pch::STMT_NULL_PTR &&
"Unhandled expression writing PCH file");
- S.EmitRecord(Writer.Code, Record);
+ Stream.EmitRecord(Writer.Code, Record);
- assert(N == ExprsToEmit.size() &&
- "Subexpression writen via AddExpr rather than WriteSubExpr!");
+ assert(N == StmtsToEmit.size() &&
+ "Substatement writen via AddStmt rather than WriteSubStmt!");
// Note that we are at the end of a full expression. Any
// expression records that follow this one are part of a different
// expression.
Record.clear();
- S.EmitRecord(pch::EXPR_STOP, Record);
+ Stream.EmitRecord(pch::STMT_STOP, Record);
}
- ExprsToEmit.clear();
+ StmtsToEmit.clear();
}
More information about the cfe-commits
mailing list