mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
Trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94671 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -34,33 +34,33 @@ class SourceMgr {
|
|||||||
struct SrcBuffer {
|
struct SrcBuffer {
|
||||||
/// Buffer - The memory buffer for the file.
|
/// Buffer - The memory buffer for the file.
|
||||||
MemoryBuffer *Buffer;
|
MemoryBuffer *Buffer;
|
||||||
|
|
||||||
/// IncludeLoc - This is the location of the parent include, or null if at
|
/// IncludeLoc - This is the location of the parent include, or null if at
|
||||||
/// the top level.
|
/// the top level.
|
||||||
SMLoc IncludeLoc;
|
SMLoc IncludeLoc;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Buffers - This is all of the buffers that we are reading from.
|
/// Buffers - This is all of the buffers that we are reading from.
|
||||||
std::vector<SrcBuffer> Buffers;
|
std::vector<SrcBuffer> Buffers;
|
||||||
|
|
||||||
// IncludeDirectories - This is the list of directories we should search for
|
// IncludeDirectories - This is the list of directories we should search for
|
||||||
// include files in.
|
// include files in.
|
||||||
std::vector<std::string> IncludeDirectories;
|
std::vector<std::string> IncludeDirectories;
|
||||||
|
|
||||||
/// LineNoCache - This is a cache for line number queries, its implementation
|
/// LineNoCache - This is a cache for line number queries, its implementation
|
||||||
/// is really private to SourceMgr.cpp.
|
/// is really private to SourceMgr.cpp.
|
||||||
mutable void *LineNoCache;
|
mutable void *LineNoCache;
|
||||||
|
|
||||||
SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT
|
SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT
|
||||||
void operator=(const SourceMgr&); // DO NOT IMPLEMENT
|
void operator=(const SourceMgr&); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
SourceMgr() : LineNoCache(0) {}
|
SourceMgr() : LineNoCache(0) {}
|
||||||
~SourceMgr();
|
~SourceMgr();
|
||||||
|
|
||||||
void setIncludeDirs(const std::vector<std::string> &Dirs) {
|
void setIncludeDirs(const std::vector<std::string> &Dirs) {
|
||||||
IncludeDirectories = Dirs;
|
IncludeDirectories = Dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SrcBuffer &getBufferInfo(unsigned i) const {
|
const SrcBuffer &getBufferInfo(unsigned i) const {
|
||||||
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||||
return Buffers[i];
|
return Buffers[i];
|
||||||
@ -70,12 +70,12 @@ public:
|
|||||||
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||||
return Buffers[i].Buffer;
|
return Buffers[i].Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMLoc getParentIncludeLoc(unsigned i) const {
|
SMLoc getParentIncludeLoc(unsigned i) const {
|
||||||
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||||
return Buffers[i].IncludeLoc;
|
return Buffers[i].IncludeLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) {
|
unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) {
|
||||||
SrcBuffer NB;
|
SrcBuffer NB;
|
||||||
NB.Buffer = F;
|
NB.Buffer = F;
|
||||||
@ -83,20 +83,20 @@ public:
|
|||||||
Buffers.push_back(NB);
|
Buffers.push_back(NB);
|
||||||
return Buffers.size()-1;
|
return Buffers.size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AddIncludeFile - Search for a file with the specified name in the current
|
/// AddIncludeFile - Search for a file with the specified name in the current
|
||||||
/// directory or in one of the IncludeDirs. If no file is found, this returns
|
/// directory or in one of the IncludeDirs. If no file is found, this returns
|
||||||
/// ~0, otherwise it returns the buffer ID of the stacked file.
|
/// ~0, otherwise it returns the buffer ID of the stacked file.
|
||||||
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc);
|
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc);
|
||||||
|
|
||||||
/// FindBufferContainingLoc - Return the ID of the buffer containing the
|
/// FindBufferContainingLoc - Return the ID of the buffer containing the
|
||||||
/// specified location, returning -1 if not found.
|
/// specified location, returning -1 if not found.
|
||||||
int FindBufferContainingLoc(SMLoc Loc) const;
|
int FindBufferContainingLoc(SMLoc Loc) const;
|
||||||
|
|
||||||
/// FindLineNumber - Find the line number for the specified location in the
|
/// FindLineNumber - Find the line number for the specified location in the
|
||||||
/// specified file. This is not a fast method.
|
/// specified file. This is not a fast method.
|
||||||
unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
|
unsigned FindLineNumber(SMLoc Loc, int BufferID = -1) const;
|
||||||
|
|
||||||
/// PrintMessage - Emit a message about the specified location with the
|
/// PrintMessage - Emit a message about the specified location with the
|
||||||
/// specified string.
|
/// specified string.
|
||||||
///
|
///
|
||||||
@ -105,8 +105,8 @@ public:
|
|||||||
/// @param ShowLine - Should the diagnostic show the source line.
|
/// @param ShowLine - Should the diagnostic show the source line.
|
||||||
void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type,
|
void PrintMessage(SMLoc Loc, const std::string &Msg, const char *Type,
|
||||||
bool ShowLine = true) const;
|
bool ShowLine = true) const;
|
||||||
|
|
||||||
|
|
||||||
/// GetMessage - Return an SMDiagnostic at the specified location with the
|
/// GetMessage - Return an SMDiagnostic at the specified location with the
|
||||||
/// specified string.
|
/// specified string.
|
||||||
///
|
///
|
||||||
@ -116,13 +116,13 @@ public:
|
|||||||
SMDiagnostic GetMessage(SMLoc Loc,
|
SMDiagnostic GetMessage(SMLoc Loc,
|
||||||
const std::string &Msg, const char *Type,
|
const std::string &Msg, const char *Type,
|
||||||
bool ShowLine = true) const;
|
bool ShowLine = true) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const;
|
void PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// SMDiagnostic - Instances of this class encapsulate one diagnostic report,
|
/// SMDiagnostic - Instances of this class encapsulate one diagnostic report,
|
||||||
/// allowing printing to a raw_ostream as a caret diagnostic.
|
/// allowing printing to a raw_ostream as a caret diagnostic.
|
||||||
class SMDiagnostic {
|
class SMDiagnostic {
|
||||||
@ -141,7 +141,7 @@ public:
|
|||||||
|
|
||||||
void Print(const char *ProgName, raw_ostream &S);
|
void Print(const char *ProgName, raw_ostream &S);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end llvm namespace
|
} // end llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,7 +35,7 @@ SourceMgr::~SourceMgr() {
|
|||||||
// Delete the line # cache if allocated.
|
// Delete the line # cache if allocated.
|
||||||
if (LineNoCacheTy *Cache = getCache(LineNoCache))
|
if (LineNoCacheTy *Cache = getCache(LineNoCache))
|
||||||
delete Cache;
|
delete Cache;
|
||||||
|
|
||||||
while (!Buffers.empty()) {
|
while (!Buffers.empty()) {
|
||||||
delete Buffers.back().Buffer;
|
delete Buffers.back().Buffer;
|
||||||
Buffers.pop_back();
|
Buffers.pop_back();
|
||||||
@ -47,7 +47,7 @@ SourceMgr::~SourceMgr() {
|
|||||||
/// ~0, otherwise it returns the buffer ID of the stacked file.
|
/// ~0, otherwise it returns the buffer ID of the stacked file.
|
||||||
unsigned SourceMgr::AddIncludeFile(const std::string &Filename,
|
unsigned SourceMgr::AddIncludeFile(const std::string &Filename,
|
||||||
SMLoc IncludeLoc) {
|
SMLoc IncludeLoc) {
|
||||||
|
|
||||||
MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str());
|
MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str());
|
||||||
|
|
||||||
// If the file didn't exist directly, see if it's in an include path.
|
// If the file didn't exist directly, see if it's in an include path.
|
||||||
@ -55,7 +55,7 @@ unsigned SourceMgr::AddIncludeFile(const std::string &Filename,
|
|||||||
std::string IncFile = IncludeDirectories[i] + "/" + Filename;
|
std::string IncFile = IncludeDirectories[i] + "/" + Filename;
|
||||||
NewBuf = MemoryBuffer::getFile(IncFile.c_str());
|
NewBuf = MemoryBuffer::getFile(IncFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewBuf == 0) return ~0U;
|
if (NewBuf == 0) return ~0U;
|
||||||
|
|
||||||
return AddNewSourceBuffer(NewBuf, IncludeLoc);
|
return AddNewSourceBuffer(NewBuf, IncludeLoc);
|
||||||
@ -79,20 +79,20 @@ int SourceMgr::FindBufferContainingLoc(SMLoc Loc) const {
|
|||||||
unsigned SourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const {
|
unsigned SourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const {
|
||||||
if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc);
|
if (BufferID == -1) BufferID = FindBufferContainingLoc(Loc);
|
||||||
assert(BufferID != -1 && "Invalid Location!");
|
assert(BufferID != -1 && "Invalid Location!");
|
||||||
|
|
||||||
MemoryBuffer *Buff = getBufferInfo(BufferID).Buffer;
|
MemoryBuffer *Buff = getBufferInfo(BufferID).Buffer;
|
||||||
|
|
||||||
// Count the number of \n's between the start of the file and the specified
|
// Count the number of \n's between the start of the file and the specified
|
||||||
// location.
|
// location.
|
||||||
unsigned LineNo = 1;
|
unsigned LineNo = 1;
|
||||||
|
|
||||||
const char *Ptr = Buff->getBufferStart();
|
const char *Ptr = Buff->getBufferStart();
|
||||||
|
|
||||||
// If we have a line number cache, and if the query is to a later point in the
|
// If we have a line number cache, and if the query is to a later point in the
|
||||||
// same file, start searching from the last query location. This optimizes
|
// same file, start searching from the last query location. This optimizes
|
||||||
// for the case when multiple diagnostics come out of one file in order.
|
// for the case when multiple diagnostics come out of one file in order.
|
||||||
if (LineNoCacheTy *Cache = getCache(LineNoCache))
|
if (LineNoCacheTy *Cache = getCache(LineNoCache))
|
||||||
if (Cache->LastQueryBufferID == BufferID &&
|
if (Cache->LastQueryBufferID == BufferID &&
|
||||||
Cache->LastQuery <= Loc.getPointer()) {
|
Cache->LastQuery <= Loc.getPointer()) {
|
||||||
Ptr = Cache->LastQuery;
|
Ptr = Cache->LastQuery;
|
||||||
LineNo = Cache->LineNoOfQuery;
|
LineNo = Cache->LineNoOfQuery;
|
||||||
@ -102,12 +102,12 @@ unsigned SourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const {
|
|||||||
// we see.
|
// we see.
|
||||||
for (; SMLoc::getFromPointer(Ptr) != Loc; ++Ptr)
|
for (; SMLoc::getFromPointer(Ptr) != Loc; ++Ptr)
|
||||||
if (*Ptr == '\n') ++LineNo;
|
if (*Ptr == '\n') ++LineNo;
|
||||||
|
|
||||||
|
|
||||||
// Allocate the line number cache if it doesn't exist.
|
// Allocate the line number cache if it doesn't exist.
|
||||||
if (LineNoCache == 0)
|
if (LineNoCache == 0)
|
||||||
LineNoCache = new LineNoCacheTy();
|
LineNoCache = new LineNoCacheTy();
|
||||||
|
|
||||||
// Update the line # cache.
|
// Update the line # cache.
|
||||||
LineNoCacheTy &Cache = *getCache(LineNoCache);
|
LineNoCacheTy &Cache = *getCache(LineNoCache);
|
||||||
Cache.LastQueryBufferID = BufferID;
|
Cache.LastQueryBufferID = BufferID;
|
||||||
@ -118,12 +118,12 @@ unsigned SourceMgr::FindLineNumber(SMLoc Loc, int BufferID) const {
|
|||||||
|
|
||||||
void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const {
|
void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const {
|
||||||
if (IncludeLoc == SMLoc()) return; // Top of stack.
|
if (IncludeLoc == SMLoc()) return; // Top of stack.
|
||||||
|
|
||||||
int CurBuf = FindBufferContainingLoc(IncludeLoc);
|
int CurBuf = FindBufferContainingLoc(IncludeLoc);
|
||||||
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
||||||
|
|
||||||
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
|
PrintIncludeStack(getBufferInfo(CurBuf).IncludeLoc, OS);
|
||||||
|
|
||||||
OS << "Included from "
|
OS << "Included from "
|
||||||
<< getBufferInfo(CurBuf).Buffer->getBufferIdentifier()
|
<< getBufferInfo(CurBuf).Buffer->getBufferIdentifier()
|
||||||
<< ":" << FindLineNumber(IncludeLoc, CurBuf) << ":\n";
|
<< ":" << FindLineNumber(IncludeLoc, CurBuf) << ":\n";
|
||||||
@ -137,12 +137,12 @@ void SourceMgr::PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const {
|
|||||||
/// prefixed to the message.
|
/// prefixed to the message.
|
||||||
SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg,
|
SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg,
|
||||||
const char *Type, bool ShowLine) const {
|
const char *Type, bool ShowLine) const {
|
||||||
|
|
||||||
// First thing to do: find the current buffer containing the specified
|
// First thing to do: find the current buffer containing the specified
|
||||||
// location.
|
// location.
|
||||||
int CurBuf = FindBufferContainingLoc(Loc);
|
int CurBuf = FindBufferContainingLoc(Loc);
|
||||||
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
assert(CurBuf != -1 && "Invalid or unspecified location!");
|
||||||
|
|
||||||
MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer;
|
MemoryBuffer *CurMB = getBufferInfo(CurBuf).Buffer;
|
||||||
|
|
||||||
// Scan backward to find the start of the line.
|
// Scan backward to find the start of the line.
|
||||||
@ -160,7 +160,7 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg,
|
|||||||
++LineEnd;
|
++LineEnd;
|
||||||
LineStr = std::string(LineStart, LineEnd);
|
LineStr = std::string(LineStart, LineEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PrintedMsg;
|
std::string PrintedMsg;
|
||||||
if (Type) {
|
if (Type) {
|
||||||
PrintedMsg = Type;
|
PrintedMsg = Type;
|
||||||
@ -173,7 +173,7 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, const std::string &Msg,
|
|||||||
LineStr, ShowLine);
|
LineStr, ShowLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
|
void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
|
||||||
const char *Type, bool ShowLine) const {
|
const char *Type, bool ShowLine) const {
|
||||||
raw_ostream &OS = errs();
|
raw_ostream &OS = errs();
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ void SMDiagnostic::Print(const char *ProgName, raw_ostream &S) {
|
|||||||
S << "<stdin>";
|
S << "<stdin>";
|
||||||
else
|
else
|
||||||
S << Filename;
|
S << Filename;
|
||||||
|
|
||||||
if (LineNo != -1) {
|
if (LineNo != -1) {
|
||||||
S << ':' << LineNo;
|
S << ':' << LineNo;
|
||||||
if (ColumnNo != -1)
|
if (ColumnNo != -1)
|
||||||
@ -205,12 +205,12 @@ void SMDiagnostic::Print(const char *ProgName, raw_ostream &S) {
|
|||||||
}
|
}
|
||||||
S << ": ";
|
S << ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
S << Message << '\n';
|
S << Message << '\n';
|
||||||
|
|
||||||
if (LineNo != -1 && ColumnNo != -1 && ShowLine) {
|
if (LineNo != -1 && ColumnNo != -1 && ShowLine) {
|
||||||
S << LineContents << '\n';
|
S << LineContents << '\n';
|
||||||
|
|
||||||
// Print out spaces/tabs before the caret.
|
// Print out spaces/tabs before the caret.
|
||||||
for (unsigned i = 0; i != unsigned(ColumnNo); ++i)
|
for (unsigned i = 0; i != unsigned(ColumnNo); ++i)
|
||||||
S << (LineContents[i] == '\t' ? '\t' : ' ');
|
S << (LineContents[i] == '\t' ? '\t' : ' ');
|
||||||
|
Reference in New Issue
Block a user