[cfe-commits] r43834 - in /cfe/trunk: AST/StmtSerialization.cpp include/clang/AST/Expr.h
Ted Kremenek
kremenek at apple.com
Wed Nov 7 11:08:20 PST 2007
Author: kremenek
Date: Wed Nov 7 13:08:19 2007
New Revision: 43834
URL: http://llvm.org/viewvc/llvm-project?rev=43834&view=rev
Log:
Implemented serialization of StringLiteral.
Modified:
cfe/trunk/AST/StmtSerialization.cpp
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=43834&r1=43833&r2=43834&view=diff
==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Wed Nov 7 13:08:19 2007
@@ -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());
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=43834&r1=43833&r2=43834&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Nov 7 13:08:19 2007
@@ -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
More information about the cfe-commits
mailing list