From: Ted Kremenek Date: Wed, 7 Nov 2007 19:08:19 +0000 (+0000) Subject: Implemented serialization of StringLiteral. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7febad7377c04607aa2c744d58af61e1abea6250;p=clang 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 ffe4312e63..7c671c6a31 100644 --- a/AST/StmtSerialization.cpp +++ b/AST/StmtSerialization.cpp @@ -96,6 +96,9 @@ Stmt* Stmt::Materialize(llvm::Deserializer& D) { case ReturnStmtClass: return ReturnStmt::directMaterialize(D); + + case StringLiteralClass: + return StringLiteral::directMaterialize(D); case SwitchStmtClass: return SwitchStmt::directMaterialize(D); @@ -410,6 +413,36 @@ ReturnStmt* ReturnStmt::directMaterialize(llvm::Deserializer& D) { 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 c5f477747f..100386e321 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -328,6 +328,9 @@ public: // 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