Keep track of the number of statements/expressions written to and read
from a PCH file. It turns out that "Hello, World!" is bringing in 19%
of all of the statements in Carbon.h, so we need to be lazy.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69393 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 5775ac4..64bf383 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -1723,7 +1723,7 @@
 }
 
 PCHWriter::PCHWriter(llvm::BitstreamWriter &Stream) 
-  : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS) { }
+  : Stream(Stream), NextTypeID(pch::NUM_PREDEF_TYPE_IDS), NumStatements(0) { }
 
 void PCHWriter::WritePCH(ASTContext &Context, const Preprocessor &PP) {
   // Emit the file header.
@@ -1749,6 +1749,11 @@
   Stream.EmitRecord(pch::DECL_OFFSET, DeclOffsets);
   if (!ExternalDefinitions.empty())
     Stream.EmitRecord(pch::EXTERNAL_DEFINITIONS, ExternalDefinitions);
+  
+  // Some simple statistics
+  RecordData Record;
+  Record.push_back(NumStatements);
+  Stream.EmitRecord(pch::STATISTICS, Record);
   Stream.ExitBlock();
 }
 
@@ -1880,6 +1885,7 @@
 void PCHWriter::WriteSubStmt(Stmt *S) {
   RecordData Record;
   PCHStmtWriter Writer(*this, Record);
+  ++NumStatements;
 
   if (!S) {
     Stream.EmitRecord(pch::STMT_NULL_PTR, Record);
@@ -1900,6 +1906,7 @@
   PCHStmtWriter Writer(*this, Record);
 
   for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
+    ++NumStatements;
     Stmt *S = StmtsToEmit[I];
 
     if (!S) {