[cfe-commits] r43343 - in /cfe/trunk: Basic/SourceLocation.cpp include/clang/Basic/SourceLocation.h
Ted Kremenek
kremenek at apple.com
Thu Oct 25 09:02:43 PDT 2007
Author: kremenek
Date: Thu Oct 25 11:02:43 2007
New Revision: 43343
URL: http://llvm.org/viewvc/llvm-project?rev=43343&view=rev
Log:
Implemented serialization of SourceLocation and SourceRange objects.
Added:
cfe/trunk/Basic/SourceLocation.cpp
Modified:
cfe/trunk/include/clang/Basic/SourceLocation.h
Added: cfe/trunk/Basic/SourceLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceLocation.cpp?rev=43343&view=auto
==============================================================================
--- cfe/trunk/Basic/SourceLocation.cpp (added)
+++ cfe/trunk/Basic/SourceLocation.cpp Thu Oct 25 11:02:43 2007
@@ -0,0 +1,30 @@
+//==--- SourceLocation.cpp - Compact identifier for Source Files -*- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Ted Kremenek and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines serialization methods for the SourceLocation class.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/Bitcode/Serialize.h"
+#include "llvm/Bitcode/Deserialize.h"
+
+using llvm::Serializer;
+using llvm::Deserializer;
+using llvm::SerializeTrait;
+using namespace clang;
+
+void SerializeTrait<SourceLocation>::Emit(Serializer& S, SourceLocation L) {
+ // FIXME: Add code for abbreviation.
+ S.EmitInt(L.getRawEncoding());
+}
+
+SourceLocation SerializeTrait<SourceLocation>::ReadVal(Deserializer& D) {
+ return SourceLocation::getFromRawEncoding(D.ReadInt());
+}
Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=43343&r1=43342&r2=43343&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
+++ cfe/trunk/include/clang/Basic/SourceLocation.h Thu Oct 25 11:02:43 2007
@@ -15,6 +15,7 @@
#define LLVM_CLANG_SOURCELOCATION_H
#include <cassert>
+#include "llvm/Bitcode/Serialization.h"
namespace clang {
@@ -177,4 +178,31 @@
} // end namespace clang
+//===----------------------------------------------------------------------===//
+// Serialization of SourceLocations and SourceRanges.
+//===----------------------------------------------------------------------===//
+
+namespace llvm {
+
+template<> struct SerializeTrait<clang::SourceLocation> {
+ static void Emit(Serializer& S, clang::SourceLocation L);
+ static clang::SourceLocation ReadVal(Deserializer& D);
+};
+
+template<> struct SerializeTrait<clang::SourceRange> {
+ static inline void Emit(Serializer& S, clang::SourceRange R) {
+ SerializeTrait<clang::SourceLocation>::Emit(S,R.getBegin());
+ SerializeTrait<clang::SourceLocation>::Emit(S,R.getEnd());
+ }
+
+ static inline clang::SourceRange ReadVal(Deserializer& D) {
+ using clang::SourceLocation;
+ SourceLocation L = SerializeTrait<SourceLocation>::ReadVal(D);
+ SourceLocation R = SerializeTrait<SourceLocation>::ReadVal(D);
+ return clang::SourceRange(L,R);
+ }
+};
+
+} // end namespace llvm
+
#endif
More information about the cfe-commits
mailing list