blob: eaf129f251efa6ed9ce7e74407eeee968677e292 [file] [log] [blame]
Ted Kremenek19a95bc2007-10-25 16:02:43 +00001//==--- SourceLocation.cpp - Compact identifier for Source Files -*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Ted Kremenek19a95bc2007-10-25 16:02:43 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines serialization methods for the SourceLocation class.
Ted Kremenek9c728dc2007-12-12 22:39:36 +000011// This file defines accessor methods for the FullSourceLoc class.
Ted Kremenek19a95bc2007-10-25 16:02:43 +000012//
13//===----------------------------------------------------------------------===//
14
15#include "clang/Basic/SourceLocation.h"
Ted Kremenek9c728dc2007-12-12 22:39:36 +000016#include "clang/Basic/SourceManager.h"
Ted Kremenek19a95bc2007-10-25 16:02:43 +000017#include "llvm/Bitcode/Serialize.h"
18#include "llvm/Bitcode/Deserialize.h"
19
Ted Kremenek19a95bc2007-10-25 16:02:43 +000020using namespace clang;
21
Ted Kremenekbeb77132007-11-01 22:25:41 +000022void SourceLocation::Emit(llvm::Serializer& S) const {
23 S.EmitInt(getRawEncoding());
Ted Kremenek19a95bc2007-10-25 16:02:43 +000024}
25
Ted Kremenekbeb77132007-11-01 22:25:41 +000026SourceLocation SourceLocation::ReadVal(llvm::Deserializer& D) {
Ted Kremenek19a95bc2007-10-25 16:02:43 +000027 return SourceLocation::getFromRawEncoding(D.ReadInt());
28}
Ted Kremenekbeb77132007-11-01 22:25:41 +000029
30void SourceRange::Emit(llvm::Serializer& S) const {
31 B.Emit(S);
32 E.Emit(S);
33}
34
35SourceRange SourceRange::ReadVal(llvm::Deserializer& D) {
36 SourceLocation A = SourceLocation::ReadVal(D);
37 SourceLocation B = SourceLocation::ReadVal(D);
38 return SourceRange(A,B);
39}
Ted Kremenek9c728dc2007-12-12 22:39:36 +000040
41FullSourceLoc FullSourceLoc::getLogicalLoc() {
42 assert (isValid());
43 return FullSourceLoc(SrcMgr->getLogicalLoc(Loc),*SrcMgr);
44}
45
46FullSourceLoc FullSourceLoc::getIncludeLoc() {
47 assert (isValid());
48 return FullSourceLoc(SrcMgr->getIncludeLoc(Loc),*SrcMgr);
49}
50
51unsigned FullSourceLoc::getLineNumber() {
52 assert (isValid());
53 return SrcMgr->getLineNumber(Loc);
54}
55
56unsigned FullSourceLoc::getColumnNumber() {
57 assert (isValid());
58 return SrcMgr->getColumnNumber(Loc);
59}
60
61const char* FullSourceLoc::getSourceName() const {
62 assert (isValid());
63 return SrcMgr->getSourceName(Loc);
64}
65
66const FileEntry* FullSourceLoc::getFileEntryForLoc() const {
67 assert (isValid());
68 return SrcMgr->getFileEntryForLoc(Loc);
69}
70
71const char * FullSourceLoc::getCharacterData() const {
72 assert (isValid());
73 return SrcMgr->getCharacterData(Loc);
74}
75
76const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
77 assert (isValid());
78 return SrcMgr->getBuffer(Loc.getFileID());
79}