rename TGLoc -> SMLoc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73843 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-06-21 03:39:35 +00:00
parent 099e198ae8
commit 1e3a8a4924
8 changed files with 66 additions and 66 deletions

View File

@ -24,19 +24,19 @@ namespace llvm {
class MemoryBuffer;
class TGSourceMgr;
class TGLoc {
class SMLoc {
const char *Ptr;
public:
TGLoc() : Ptr(0) {}
TGLoc(const TGLoc &RHS) : Ptr(RHS.Ptr) {}
SMLoc() : Ptr(0) {}
SMLoc(const SMLoc &RHS) : Ptr(RHS.Ptr) {}
bool operator==(const TGLoc &RHS) const { return RHS.Ptr == Ptr; }
bool operator!=(const TGLoc &RHS) const { return RHS.Ptr != Ptr; }
bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; }
bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; }
const char *getPointer() const { return Ptr; }
static TGLoc getFromPointer(const char *Ptr) {
TGLoc L;
static SMLoc getFromPointer(const char *Ptr) {
SMLoc L;
L.Ptr = Ptr;
return L;
}
@ -51,7 +51,7 @@ class TGSourceMgr {
/// IncludeLoc - This is the location of the parent include, or null if at
/// the top level.
TGLoc IncludeLoc;
SMLoc IncludeLoc;
};
/// Buffers - This is all of the buffers that we are reading from.
@ -73,12 +73,12 @@ public:
return Buffers[i].Buffer;
}
TGLoc getParentIncludeLoc(unsigned i) const {
SMLoc getParentIncludeLoc(unsigned i) const {
assert(i < Buffers.size() && "Invalid Buffer ID!");
return Buffers[i].IncludeLoc;
}
unsigned AddNewSourceBuffer(MemoryBuffer *F, TGLoc IncludeLoc) {
unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) {
SrcBuffer NB;
NB.Buffer = F;
NB.IncludeLoc = IncludeLoc;
@ -88,19 +88,19 @@ public:
/// FindBufferContainingLoc - Return the ID of the buffer containing the
/// specified location, returning -1 if not found.
int FindBufferContainingLoc(TGLoc Loc) const;
int FindBufferContainingLoc(SMLoc Loc) const;
/// FindLineNumber - Find the line number for the specified location in the
/// specified file. This is not a fast method.
unsigned FindLineNumber(TGLoc Loc, int BufferID = -1) const;
unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
/// PrintError - Emit an error message about the specified location with the
/// specified string.
void PrintError(TGLoc ErrorLoc, const std::string &Msg) const;
void PrintError(SMLoc ErrorLoc, const std::string &Msg) const;
private:
void PrintIncludeStack(TGLoc IncludeLoc) const;
void PrintIncludeStack(SMLoc IncludeLoc) const;
};
} // end llvm namespace

View File

@ -27,7 +27,7 @@ TGSourceMgr::~TGSourceMgr() {
/// FindBufferContainingLoc - Return the ID of the buffer containing the
/// specified location, returning -1 if not found.
int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const {
int TGSourceMgr::FindBufferContainingLoc(SMLoc Loc) const {
for (unsigned i = 0, e = Buffers.size(); i != e; ++i)
if (Loc.getPointer() >= Buffers[i].Buffer->getBufferStart() &&
// Use <= here so that a pointer to the null at the end of the buffer
@ -39,7 +39,7 @@ int TGSourceMgr::FindBufferContainingLoc(TGLoc Loc) const {
/// FindLineNumber - Find the line number for the specified location in the
/// specified file. This is not a fast method.
unsigned TGSourceMgr::FindLineNumber(TGLoc Loc, int BufferID) const {
unsigned TGSourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const {
if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc);
assert(BufferID != -1 && "Invalid Location!");
@ -51,13 +51,13 @@ unsigned TGSourceMgr::FindLineNumber(TGLoc Loc, int BufferID) const {
const char *Ptr = Buff->getBufferStart();
for (; TGLoc::getFromPointer(Ptr) != Loc; ++Ptr)
for (; SMLoc::getFromPointer(Ptr) != Loc; ++Ptr)
if (*Ptr == '\n') ++LineNo;
return LineNo;
}
void TGSourceMgr::PrintIncludeStack(TGLoc IncludeLoc) const {
if (IncludeLoc == TGLoc()) return; // Top of stack.
void TGSourceMgr::PrintIncludeStack(SMLoc IncludeLoc) const {
if (IncludeLoc == SMLoc()) return; // Top of stack.
int CurBuf = FindBufferContainingLoc(IncludeLoc);
assert(CurBuf != -1 && "Invalid or unspecified location!");
@ -70,7 +70,7 @@ void TGSourceMgr::PrintIncludeStack(TGLoc IncludeLoc) const {
}
void TGSourceMgr::PrintError(TGLoc ErrorLoc, const std::string &Msg) const {
void TGSourceMgr::PrintError(SMLoc ErrorLoc, const std::string &Msg) const {
raw_ostream &OS = errs();
// First thing to do: find the current buffer containing the specified

View File

@ -1214,19 +1214,19 @@ inline std::ostream &operator<<(std::ostream &OS, const RecordVal &RV) {
class Record {
std::string Name;
TGLoc Loc;
SMLoc Loc;
std::vector<std::string> TemplateArgs;
std::vector<RecordVal> Values;
std::vector<Record*> SuperClasses;
public:
explicit Record(const std::string &N, TGLoc loc) : Name(N), Loc(loc) {}
explicit Record(const std::string &N, SMLoc loc) : Name(N), Loc(loc) {}
~Record() {}
const std::string &getName() const { return Name; }
void setName(const std::string &Name); // Also updates RecordKeeper.
TGLoc getLoc() const { return Loc; }
SMLoc getLoc() const { return Loc; }
const std::vector<std::string> &getTemplateArgs() const {
return TemplateArgs;
@ -1381,7 +1381,7 @@ struct MultiClass {
void dump() const;
MultiClass(const std::string &Name, TGLoc Loc) : Rec(Name, Loc) {}
MultiClass(const std::string &Name, SMLoc Loc) : Rec(Name, Loc) {}
};
class RecordKeeper {
@ -1461,12 +1461,12 @@ struct LessRecordFieldName {
class TGError {
TGLoc Loc;
SMLoc Loc;
std::string Message;
public:
TGError(TGLoc loc, const std::string &message) : Loc(loc), Message(message) {}
TGError(SMLoc loc, const std::string &message) : Loc(loc), Message(message) {}
TGLoc getLoc() const { return Loc; }
SMLoc getLoc() const { return Loc; }
const std::string &getMessage() const { return Message; }
};
@ -1475,7 +1475,7 @@ std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK);
extern RecordKeeper Records;
void PrintError(TGLoc ErrorLoc, const std::string &Msg);
void PrintError(SMLoc ErrorLoc, const std::string &Msg);
} // End llvm namespace

View File

@ -31,8 +31,8 @@ TGLexer::TGLexer(TGSourceMgr &SM) : SrcMgr(SM) {
TokStart = 0;
}
TGLoc TGLexer::getLoc() const {
return TGLoc::getFromPointer(TokStart);
SMLoc TGLexer::getLoc() const {
return SMLoc::getFromPointer(TokStart);
}
@ -45,10 +45,10 @@ tgtok::TokKind TGLexer::ReturnError(const char *Loc, const std::string &Msg) {
void TGLexer::PrintError(const char *Loc, const std::string &Msg) const {
SrcMgr.PrintError(TGLoc::getFromPointer(Loc), Msg);
SrcMgr.PrintError(SMLoc::getFromPointer(Loc), Msg);
}
void TGLexer::PrintError(TGLoc Loc, const std::string &Msg) const {
void TGLexer::PrintError(SMLoc Loc, const std::string &Msg) const {
SrcMgr.PrintError(Loc, Msg);
}
@ -66,8 +66,8 @@ int TGLexer::getNextChar() {
// If this is the end of an included file, pop the parent file off the
// include stack.
TGLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
if (ParentIncludeLoc != TGLoc()) {
SMLoc ParentIncludeLoc = SrcMgr.getParentIncludeLoc(CurBuffer);
if (ParentIncludeLoc != SMLoc()) {
CurBuffer = SrcMgr.FindBufferContainingLoc(ParentIncludeLoc);
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = ParentIncludeLoc.getPointer();
@ -293,7 +293,7 @@ bool TGLexer::LexInclude() {
}
// Save the line number and lex buffer of the includer.
CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, TGLoc::getFromPointer(CurPtr));
CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, SMLoc::getFromPointer(CurPtr));
CurBuf = NewBuf;
CurPtr = CurBuf->getBufferStart();

View File

@ -23,7 +23,7 @@
namespace llvm {
class MemoryBuffer;
class TGSourceMgr;
class TGLoc;
class SMLoc;
namespace tgtok {
enum TokKind {
@ -101,10 +101,10 @@ public:
return CurIntVal;
}
TGLoc getLoc() const;
SMLoc getLoc() const;
void PrintError(const char *Loc, const std::string &Msg) const;
void PrintError(TGLoc Loc, const std::string &Msg) const;
void PrintError(SMLoc Loc, const std::string &Msg) const;
private:
/// LexToken - Read the next token and return its code.

View File

@ -26,7 +26,7 @@ using namespace llvm;
namespace llvm {
struct SubClassReference {
TGLoc RefLoc;
SMLoc RefLoc;
Record *Rec;
std::vector<Init*> TemplateArgs;
SubClassReference() : Rec(0) {}
@ -35,7 +35,7 @@ struct SubClassReference {
};
struct SubMultiClassReference {
TGLoc RefLoc;
SMLoc RefLoc;
MultiClass *MC;
std::vector<Init*> TemplateArgs;
SubMultiClassReference() : MC(0) {}
@ -60,7 +60,7 @@ void SubMultiClassReference::dump() const {
} // end namespace llvm
bool TGParser::AddValue(Record *CurRec, TGLoc Loc, const RecordVal &RV) {
bool TGParser::AddValue(Record *CurRec, SMLoc Loc, const RecordVal &RV) {
if (CurRec == 0)
CurRec = &CurMultiClass->Rec;
@ -79,7 +79,7 @@ bool TGParser::AddValue(Record *CurRec, TGLoc Loc, const RecordVal &RV) {
/// SetValue -
/// Return true on error, false on success.
bool TGParser::SetValue(Record *CurRec, TGLoc Loc, const std::string &ValName,
bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName,
const std::vector<unsigned> &BitList, Init *V) {
if (!V) return false;
@ -527,7 +527,7 @@ bool TGParser::ParseOptionalRangeList(std::vector<unsigned> &Ranges) {
if (Lex.getCode() != tgtok::less)
return false;
TGLoc StartLoc = Lex.getLoc();
SMLoc StartLoc = Lex.getLoc();
Lex.Lex(); // eat the '<'
// Parse the range list.
@ -549,7 +549,7 @@ bool TGParser::ParseOptionalBitList(std::vector<unsigned> &Ranges) {
if (Lex.getCode() != tgtok::l_brace)
return false;
TGLoc StartLoc = Lex.getLoc();
SMLoc StartLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
// Parse the range list.
@ -634,7 +634,7 @@ RecTy *TGParser::ParseType() {
Init *TGParser::ParseIDValue(Record *CurRec) {
assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue");
std::string Name = Lex.getCurStrVal();
TGLoc Loc = Lex.getLoc();
SMLoc Loc = Lex.getLoc();
Lex.Lex();
return ParseIDValue(CurRec, Name, Loc);
}
@ -642,7 +642,7 @@ Init *TGParser::ParseIDValue(Record *CurRec) {
/// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID
/// has already been read.
Init *TGParser::ParseIDValue(Record *CurRec,
const std::string &Name, TGLoc NameLoc) {
const std::string &Name, SMLoc NameLoc) {
if (CurRec) {
if (const RecordVal *RV = CurRec->getValue(Name))
return new VarInit(Name, RV->getType());
@ -1041,7 +1041,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
R = new CodeInit(Lex.getCurStrVal()); Lex.Lex(); break;
case tgtok::question: R = new UnsetInit(); Lex.Lex(); break;
case tgtok::Id: {
TGLoc NameLoc = Lex.getLoc();
SMLoc NameLoc = Lex.getLoc();
std::string Name = Lex.getCurStrVal();
if (Lex.Lex() != tgtok::less) // consume the Id.
return ParseIDValue(CurRec, Name, NameLoc); // Value ::= IDValue
@ -1087,7 +1087,7 @@ Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) {
return new DefInit(NewRec);
}
case tgtok::l_brace: { // Value ::= '{' ValueList '}'
TGLoc BraceLoc = Lex.getLoc();
SMLoc BraceLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
std::vector<Init*> Vals;
@ -1295,7 +1295,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
switch (Lex.getCode()) {
default: return Result;
case tgtok::l_brace: {
TGLoc CurlyLoc = Lex.getLoc();
SMLoc CurlyLoc = Lex.getLoc();
Lex.Lex(); // eat the '{'
std::vector<unsigned> Ranges = ParseRangeList();
if (Ranges.empty()) return 0;
@ -1317,7 +1317,7 @@ Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) {
break;
}
case tgtok::l_square: {
TGLoc SquareLoc = Lex.getLoc();
SMLoc SquareLoc = Lex.getLoc();
Lex.Lex(); // eat the '['
std::vector<unsigned> Ranges = ParseRangeList();
if (Ranges.empty()) return 0;
@ -1449,7 +1449,7 @@ std::string TGParser::ParseDeclaration(Record *CurRec,
return "";
}
TGLoc IdLoc = Lex.getLoc();
SMLoc IdLoc = Lex.getLoc();
std::string DeclName = Lex.getCurStrVal();
Lex.Lex();
@ -1470,7 +1470,7 @@ std::string TGParser::ParseDeclaration(Record *CurRec,
// If a value is present, parse it.
if (Lex.getCode() == tgtok::equal) {
Lex.Lex();
TGLoc ValLoc = Lex.getLoc();
SMLoc ValLoc = Lex.getLoc();
Init *Val = ParseValue(CurRec, Type);
if (Val == 0 ||
SetValue(CurRec, ValLoc, DeclName, std::vector<unsigned>(), Val))
@ -1536,7 +1536,7 @@ bool TGParser::ParseBodyItem(Record *CurRec) {
if (Lex.Lex() != tgtok::Id)
return TokError("expected field identifier after let");
TGLoc IdLoc = Lex.getLoc();
SMLoc IdLoc = Lex.getLoc();
std::string FieldName = Lex.getCurStrVal();
Lex.Lex(); // eat the field name.
@ -1640,7 +1640,7 @@ bool TGParser::ParseObjectBody(Record *CurRec) {
/// DefInst ::= DEF ObjectName ObjectBody
///
llvm::Record *TGParser::ParseDef(MultiClass *CurMultiClass) {
TGLoc DefLoc = Lex.getLoc();
SMLoc DefLoc = Lex.getLoc();
assert(Lex.getCode() == tgtok::Def && "Unknown tok");
Lex.Lex(); // Eat the 'def' token.
@ -1728,7 +1728,7 @@ std::vector<LetRecord> TGParser::ParseLetList() {
return std::vector<LetRecord>();
}
std::string Name = Lex.getCurStrVal();
TGLoc NameLoc = Lex.getLoc();
SMLoc NameLoc = Lex.getLoc();
Lex.Lex(); // Eat the identifier.
// Check for an optional RangeList.
@ -1780,7 +1780,7 @@ bool TGParser::ParseTopLevelLet() {
if (ParseObject())
return true;
} else { // Object ::= LETCommand '{' ObjectList '}'
TGLoc BraceLoc = Lex.getLoc();
SMLoc BraceLoc = Lex.getLoc();
// Otherwise, this is a group let.
Lex.Lex(); // eat the '{'.
@ -1905,7 +1905,7 @@ bool TGParser::ParseDefm() {
if (Lex.Lex() != tgtok::Id) // eat the defm.
return TokError("expected identifier after defm");
TGLoc DefmPrefixLoc = Lex.getLoc();
SMLoc DefmPrefixLoc = Lex.getLoc();
std::string DefmPrefix = Lex.getCurStrVal();
if (Lex.Lex() != tgtok::colon)
return TokError("expected ':' after defm identifier");
@ -1913,7 +1913,7 @@ bool TGParser::ParseDefm() {
// eat the colon.
Lex.Lex();
TGLoc SubClassLoc = Lex.getLoc();
SMLoc SubClassLoc = Lex.getLoc();
SubClassReference Ref = ParseSubClassReference(0, true);
while (1) {

View File

@ -31,9 +31,9 @@ namespace llvm {
std::string Name;
std::vector<unsigned> Bits;
Init *Value;
TGLoc Loc;
SMLoc Loc;
LetRecord(const std::string &N, const std::vector<unsigned> &B, Init *V,
TGLoc L)
SMLoc L)
: Name(N), Bits(B), Value(V), Loc(L) {
}
};
@ -55,7 +55,7 @@ public:
/// routines return true on error, or false on success.
bool ParseFile();
bool Error(TGLoc L, const std::string &Msg) const {
bool Error(SMLoc L, const std::string &Msg) const {
Lex.PrintError(L, Msg);
return true;
}
@ -63,8 +63,8 @@ public:
return Error(Lex.getLoc(), Msg);
}
private: // Semantic analysis methods.
bool AddValue(Record *TheRec, TGLoc Loc, const RecordVal &RV);
bool SetValue(Record *TheRec, TGLoc Loc, const std::string &ValName,
bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV);
bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName,
const std::vector<unsigned> &BitList, Init *V);
bool AddSubClass(Record *Rec, SubClassReference &SubClass);
bool AddSubMultiClass(MultiClass *CurMC,
@ -92,7 +92,7 @@ private: // Parser methods.
SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC);
Init *ParseIDValue(Record *CurRec);
Init *ParseIDValue(Record *CurRec, const std::string &Name, TGLoc NameLoc);
Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc);
Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0);
Init *ParseValue(Record *CurRec, RecTy *ItemType = 0);
std::vector<Init*> ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0);

View File

@ -126,7 +126,7 @@ RecordKeeper llvm::Records;
static TGSourceMgr SrcMgr;
void llvm::PrintError(TGLoc ErrorLoc, const std::string &Msg) {
void llvm::PrintError(SMLoc ErrorLoc, const std::string &Msg) {
SrcMgr.PrintError(ErrorLoc, Msg);
}
@ -145,7 +145,7 @@ static bool ParseFile(const std::string &Filename,
}
// Tell SrcMgr about this buffer, which is what TGParser will pick up.
SrcMgr.AddNewSourceBuffer(F, TGLoc());
SrcMgr.AddNewSourceBuffer(F, SMLoc());
TGParser Parser(SrcMgr);