2007-10-25 16:02:43 +00:00
|
|
|
//==--- SourceLocation.cpp - Compact identifier for Source Files -*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:25 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-10-25 16:02:43 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines serialization methods for the SourceLocation class.
|
2007-12-12 22:39:36 +00:00
|
|
|
// This file defines accessor methods for the FullSourceLoc class.
|
2007-10-25 16:02:43 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Basic/SourceLocation.h"
|
2007-12-12 22:39:36 +00:00
|
|
|
#include "clang/Basic/SourceManager.h"
|
2007-10-25 16:02:43 +00:00
|
|
|
#include "llvm/Bitcode/Serialize.h"
|
|
|
|
#include "llvm/Bitcode/Deserialize.h"
|
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
|
2007-11-01 22:25:41 +00:00
|
|
|
void SourceLocation::Emit(llvm::Serializer& S) const {
|
|
|
|
S.EmitInt(getRawEncoding());
|
2007-10-25 16:02:43 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 22:25:41 +00:00
|
|
|
SourceLocation SourceLocation::ReadVal(llvm::Deserializer& D) {
|
2007-10-25 16:02:43 +00:00
|
|
|
return SourceLocation::getFromRawEncoding(D.ReadInt());
|
|
|
|
}
|
2007-11-01 22:25:41 +00:00
|
|
|
|
|
|
|
void SourceRange::Emit(llvm::Serializer& S) const {
|
|
|
|
B.Emit(S);
|
|
|
|
E.Emit(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
SourceRange SourceRange::ReadVal(llvm::Deserializer& D) {
|
|
|
|
SourceLocation A = SourceLocation::ReadVal(D);
|
|
|
|
SourceLocation B = SourceLocation::ReadVal(D);
|
|
|
|
return SourceRange(A,B);
|
|
|
|
}
|
2007-12-12 22:39:36 +00:00
|
|
|
|
|
|
|
FullSourceLoc FullSourceLoc::getLogicalLoc() {
|
|
|
|
assert (isValid());
|
|
|
|
return FullSourceLoc(SrcMgr->getLogicalLoc(Loc),*SrcMgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
FullSourceLoc FullSourceLoc::getIncludeLoc() {
|
|
|
|
assert (isValid());
|
|
|
|
return FullSourceLoc(SrcMgr->getIncludeLoc(Loc),*SrcMgr);
|
|
|
|
}
|
|
|
|
|
2008-04-03 17:55:15 +00:00
|
|
|
unsigned FullSourceLoc::getLineNumber() const {
|
2007-12-12 22:39:36 +00:00
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getLineNumber(Loc);
|
|
|
|
}
|
|
|
|
|
2008-04-03 17:55:15 +00:00
|
|
|
unsigned FullSourceLoc::getColumnNumber() const {
|
2007-12-12 22:39:36 +00:00
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getColumnNumber(Loc);
|
|
|
|
}
|
|
|
|
|
2008-04-03 17:55:15 +00:00
|
|
|
|
|
|
|
unsigned FullSourceLoc::getLogicalLineNumber() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getLogicalLineNumber(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned FullSourceLoc::getLogicalColumnNumber() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getLogicalColumnNumber(Loc);
|
|
|
|
}
|
|
|
|
|
2007-12-12 22:39:36 +00:00
|
|
|
const char* FullSourceLoc::getSourceName() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getSourceName(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
const FileEntry* FullSourceLoc::getFileEntryForLoc() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getFileEntryForLoc(Loc);
|
|
|
|
}
|
|
|
|
|
2008-08-10 19:59:06 +00:00
|
|
|
bool FullSourceLoc::isInSystemHeader() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->isInSystemHeader(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-12 22:39:36 +00:00
|
|
|
const char * FullSourceLoc::getCharacterData() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getCharacterData(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const {
|
|
|
|
assert (isValid());
|
|
|
|
return SrcMgr->getBuffer(Loc.getFileID());
|
|
|
|
}
|
2008-04-14 21:04:18 +00:00
|
|
|
|
|
|
|
unsigned FullSourceLoc::getCanonicalFileID() const {
|
|
|
|
return SrcMgr->getCanonicalFileID(Loc);
|
|
|
|
}
|