Introduce additional abbreviations into the AST writer for
DeclRefExprs, IntegerLiterals, and others, reducing Cocoa PCH size by
~1% and C++ header size by ~2.5%. From Jonathan Turner!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132528 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index bd5889a..a397008 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -30,6 +30,7 @@
 
   public:
     serialization::StmtCode Code;
+    unsigned AbbrevToUse;
 
     ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
       : Writer(Writer), Record(Record) { }
@@ -392,6 +393,14 @@
     Record.push_back(NumTemplateArgs);
   }
 
+  DeclarationName::NameKind nk = (E->getDecl()->getDeclName().getNameKind());
+
+  if ((!E->hasExplicitTemplateArgs()) && (!E->hasQualifier()) &&
+      (E->getDecl() == E->getFoundDecl()) &&
+      nk == DeclarationName::Identifier) {
+    AbbrevToUse = Writer.getDeclRefExprAbbrev();
+  }
+
   if (E->hasQualifier())
     Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
 
@@ -411,6 +420,11 @@
   VisitExpr(E);
   Writer.AddSourceLocation(E->getLocation(), Record);
   Writer.AddAPInt(E->getValue(), Record);
+
+  if (E->getValue().getBitWidth() == 32) {
+    AbbrevToUse = Writer.getIntegerLiteralAbbrev();
+  }
+
   Code = serialization::EXPR_INTEGER_LITERAL;
 }
 
@@ -449,6 +463,9 @@
   Record.push_back(E->getValue());
   Writer.AddSourceLocation(E->getLocation(), Record);
   Record.push_back(E->isWide());
+
+  AbbrevToUse = Writer.getCharacterLiteralAbbrev();
+
   Code = serialization::EXPR_CHARACTER_LITERAL;
 }
 
@@ -1460,6 +1477,7 @@
   CollectedStmts = &SubStmts;
 
   Writer.Code = serialization::STMT_NULL_PTR;
+  Writer.AbbrevToUse = 0;
   Writer.Visit(S);
   
 #ifndef NDEBUG
@@ -1481,7 +1499,7 @@
   while (!SubStmts.empty())
     WriteSubStmt(SubStmts.pop_back_val());
   
-  Stream.EmitRecord(Writer.Code, Record);
+  Stream.EmitRecord(Writer.Code, Record, Writer.AbbrevToUse);
 }
 
 /// \brief Flush all of the statements that have been added to the