[cfe-commits] r70188 - in /cfe/trunk: include/clang/Frontend/PCHReader.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHReaderStmt.cpp

Chris Lattner sabre at nondot.org
Sun Apr 26 22:41:06 PDT 2009


Author: lattner
Date: Mon Apr 27 00:41:06 2009
New Revision: 70188

URL: http://llvm.org/viewvc/llvm-project?rev=70188&view=rev
Log:
change the interface to ReadStmt to force clients to pass a cursor in to read from.

Modified:
    cfe/trunk/include/clang/Frontend/PCHReader.h
    cfe/trunk/lib/Frontend/PCHReader.cpp
    cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
    cfe/trunk/lib/Frontend/PCHReaderStmt.cpp

Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=70188&r1=70187&r2=70188&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Mon Apr 27 00:41:06 2009
@@ -88,7 +88,9 @@
 
   /// \brief The bitstream reader from which we'll read the PCH file.
   llvm::BitstreamReader StreamFile;
+public:
   llvm::BitstreamCursor Stream;
+private:
 
   /// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.  It
   /// has read all the abbreviations at the start of the block and is ready to
@@ -405,8 +407,8 @@
   /// \brief Reads an expression from the current stream position.
   Expr *ReadExpr();
 
-  /// \brief Reads a statement from the current stream position.
-  Stmt *ReadStmt();
+  /// \brief Reads a statement from the specified cursor.
+  Stmt *ReadStmt(llvm::BitstreamCursor &Cursor);
 
   /// \brief Reads the macro record located at the given offset.
   void ReadMacroRecord(uint64_t Offset);

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=70188&r1=70187&r2=70188&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Mon Apr 27 00:41:06 2009
@@ -67,7 +67,7 @@
 PCHReader::~PCHReader() {}
 
 Expr *PCHReader::ReadExpr() {
-  return dyn_cast_or_null<Expr>(ReadStmt());
+  return dyn_cast_or_null<Expr>(ReadStmt(Stream));
 }
 
 
@@ -1337,7 +1337,7 @@
   SavedStreamPosition SavedPosition(Stream);
 
   Stream.JumpToBit(Offset);
-  return ReadStmt();
+  return ReadStmt(Stream);
 }
 
 bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC,

Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=70188&r1=70187&r2=70188&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Mon Apr 27 00:41:06 2009
@@ -186,7 +186,7 @@
   if (Record[Idx++]) {
     // In practice, this won't be executed (since method definitions
     // don't occur in header files).
-    MD->setBody(Reader.ReadStmt());
+    MD->setBody(Reader.ReadStmt(Reader.Stream));
     MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++])));
     MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++])));
   }
@@ -384,7 +384,7 @@
 
 void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) {
   VisitDecl(BD);
-  BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt()));
+  BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(Reader.Stream)));
   unsigned NumParams = Record[Idx++];
   llvm::SmallVector<ParmVarDecl *, 16> Params;
   Params.reserve(NumParams);

Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=70188&r1=70187&r2=70188&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Mon Apr 27 00:41:06 2009
@@ -812,14 +812,14 @@
 }
 
 
-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 STMT_STOP record, and
-  // the single remaining expression on the stack is our result.
+// 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 STMT_STOP record, and
+// the single remaining expression on the stack is our result.
+Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
   RecordData Record;
   unsigned Idx;
   llvm::SmallVector<Stmt *, 16> StmtStack;
@@ -827,9 +827,9 @@
   Stmt::EmptyShell Empty;
 
   while (true) {
-    unsigned Code = Stream.ReadCode();
+    unsigned Code = Cursor.ReadCode();
     if (Code == llvm::bitc::END_BLOCK) {
-      if (Stream.ReadBlockEnd()) {
+      if (Cursor.ReadBlockEnd()) {
         Error("Error at end of Source Manager block");
         return 0;
       }
@@ -838,8 +838,8 @@
 
     if (Code == llvm::bitc::ENTER_SUBBLOCK) {
       // No known subblocks, always skip them.
-      Stream.ReadSubBlockID();
-      if (Stream.SkipBlock()) {
+      Cursor.ReadSubBlockID();
+      if (Cursor.SkipBlock()) {
         Error("Malformed block record");
         return 0;
       }
@@ -847,7 +847,7 @@
     }
 
     if (Code == llvm::bitc::DEFINE_ABBREV) {
-      Stream.ReadAbbrevRecord();
+      Cursor.ReadAbbrevRecord();
       continue;
     }
 
@@ -855,7 +855,7 @@
     Idx = 0;
     Record.clear();
     bool Finished = false;
-    switch ((pch::StmtCode)Stream.ReadRecord(Code, Record)) {
+    switch ((pch::StmtCode)Cursor.ReadRecord(Code, Record)) {
     case pch::STMT_STOP:
       Finished = true;
       break;





More information about the cfe-commits mailing list