make "locations" a class instead of a typedef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66895 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-03-13 16:01:53 +00:00
parent d9c9bf77d8
commit 1c8ae59dfd
7 changed files with 82 additions and 58 deletions
+14 -5
View File
@@ -31,6 +31,10 @@ TGLexer::TGLexer(TGSourceMgr &SM) : SrcMgr(SM) {
TokStart = 0;
}
TGLoc TGLexer::getLoc() const {
return TGLoc::getFromPointer(TokStart);
}
/// ReturnError - Set the error to the specified string at the specified
/// location. This is defined to always return tgtok::Error.
@@ -40,10 +44,15 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const std::string &Msg) {
}
void TGLexer::PrintError(LocTy Loc, const std::string &Msg) const {
void TGLexer::PrintError(const char *Loc, const std::string &Msg) const {
SrcMgr.PrintError(TGLoc::getFromPointer(Loc), Msg);
}
void TGLexer::PrintError(TGLoc Loc, const std::string &Msg) const {
SrcMgr.PrintError(Loc, Msg);
}
int TGLexer::getNextChar() {
char CurChar = *CurPtr++;
switch (CurChar) {
@@ -57,11 +66,11 @@ int TGLexer::getNextChar() {
// If this is the end of an included file, pop the parent file off the
// include stack.
TGLocTy ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
if (ParentIncludeLoc != TGLocTy()) {
TGLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
if (ParentIncludeLoc != TGLoc()) {
CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = ParentIncludeLoc;
CurPtr = ParentIncludeLoc.getPointer();
return getNextChar();
}
@@ -239,7 +248,7 @@ bool TGLexer::LexInclude() {
}
// Save the line number and lex buffer of the includer.
CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, CurPtr);
CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, TGLoc::getFromPointer(CurPtr));
CurBuf = NewBuf;
CurPtr = CurBuf->getBufferStart();