Implemented serialization of StringLiteral.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43834 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/StmtSerialization.cpp b/AST/StmtSerialization.cpp
index ffe4312..7c671c6 100644
--- a/AST/StmtSerialization.cpp
+++ b/AST/StmtSerialization.cpp
@@ -96,6 +96,9 @@
       
     case ReturnStmtClass:
       return ReturnStmt::directMaterialize(D);
+     
+    case StringLiteralClass:
+      return StringLiteral::directMaterialize(D);
       
     case SwitchStmtClass:
       return SwitchStmt::directMaterialize(D);
@@ -410,6 +413,36 @@
   return new ReturnStmt(RetLoc,RetExpr);
 }
 
+void StringLiteral::directEmit(llvm::Serializer& S) const {
+  S.Emit(getType());
+  S.Emit(firstTokLoc);
+  S.Emit(lastTokLoc);
+  S.EmitBool(isWide());
+  S.Emit(getByteLength());
+
+  for (unsigned i = 0 ; i < ByteLength; ++i)
+    S.EmitInt(StrData[i]);
+}
+
+StringLiteral* StringLiteral::directMaterialize(llvm::Deserializer& D) {
+  QualType t = QualType::ReadVal(D);
+  SourceLocation firstTokLoc = SourceLocation::ReadVal(D);
+  SourceLocation lastTokLoc = SourceLocation::ReadVal(D);
+  bool isWide = D.ReadBool();
+  unsigned ByteLength = D.ReadInt();
+  
+  StringLiteral* sl = new StringLiteral(NULL,0,isWide,t,firstTokLoc,lastTokLoc);
+
+  char* StrData = new char[ByteLength];
+  for (unsigned i = 0; i < ByteLength; ++i)
+    StrData[i] = (char) D.ReadInt();
+
+  sl->ByteLength = ByteLength;
+  sl->StrData = StrData;
+  
+  return sl;
+}
+
 void SwitchStmt::directEmit(llvm::Serializer& S) const {
   S.Emit(SwitchLoc);
   S.EmitOwnedPtr(getCond());
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index c5f4777..100386e 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -328,6 +328,9 @@
   // Iterators
   virtual child_iterator child_begin();
   virtual child_iterator child_end();
+  
+  virtual void directEmit(llvm::Serializer& S) const;
+  static StringLiteral* directMaterialize(llvm::Deserializer& D);
 };
 
 /// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This