class SourceMgr
Declaration
class SourceMgr { /* full declaration omitted */ };
Description
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Declared at: llvm/include/llvm/Support/SourceMgr.h:41
Method Overview
- public unsigned int AddIncludeFile(const std::string & Filename, llvm::SMLoc IncludeLoc, std::string & IncludedFile)
- public unsigned int AddNewSourceBuffer(std::unique_ptr<MemoryBuffer> F, llvm::SMLoc IncludeLoc)
- public unsigned int FindBufferContainingLoc(llvm::SMLoc Loc) const
- public unsigned int FindLineNumber(llvm::SMLoc Loc, unsigned int BufferID = 0) const
- public llvm::SMDiagnostic GetMessage(llvm::SMLoc Loc, llvm::SourceMgr::DiagKind Kind, const llvm::Twine & Msg, ArrayRef<llvm::SMRange> Ranges = None, ArrayRef<llvm::SMFixIt> FixIts = None) const
- public void PrintIncludeStack(llvm::SMLoc IncludeLoc, llvm::raw_ostream & OS) const
- public void PrintMessage(llvm::raw_ostream & OS, const llvm::SMDiagnostic & Diagnostic, bool ShowColors = true) const
- public void PrintMessage(llvm::SMLoc Loc, llvm::SourceMgr::DiagKind Kind, const llvm::Twine & Msg, ArrayRef<llvm::SMRange> Ranges = None, ArrayRef<llvm::SMFixIt> FixIts = None, bool ShowColors = true) const
- public void PrintMessage(llvm::raw_ostream & OS, llvm::SMLoc Loc, llvm::SourceMgr::DiagKind Kind, const llvm::Twine & Msg, ArrayRef<llvm::SMRange> Ranges = None, ArrayRef<llvm::SMFixIt> FixIts = None, bool ShowColors = true) const
- public SourceMgr(const llvm::SourceMgr &)
- public SourceMgr(llvm::SourceMgr &&)
- public SourceMgr()
- public const llvm::SourceMgr::SrcBuffer & getBufferInfo(unsigned int i) const
- public void * getDiagContext() const
- public llvm::SourceMgr::DiagHandlerTy getDiagHandler() const
- public std::pair<unsigned int, unsigned int> getLineAndColumn(llvm::SMLoc Loc, unsigned int BufferID = 0) const
- public unsigned int getMainFileID() const
- public const llvm::MemoryBuffer * getMemoryBuffer(unsigned int i) const
- public unsigned int getNumBuffers() const
- public llvm::SMLoc getParentIncludeLoc(unsigned int i) const
- public void setDiagHandler(llvm::SourceMgr::DiagHandlerTy DH, void * Ctx = nullptr)
- public void setIncludeDirs(const std::vector<std::string> & Dirs)
- public ~SourceMgr()
Methods
¶unsigned int AddIncludeFile(
const std::string& Filename,
llvm::SMLoc IncludeLoc,
std::string& IncludedFile)
unsigned int AddIncludeFile(
const std::string& Filename,
llvm::SMLoc IncludeLoc,
std::string& IncludedFile)
Description
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 0, otherwise it returns the buffer ID of the stacked file. The full path to the included file can be found in\p IncludedFile.
Declared at: llvm/include/llvm/Support/SourceMgr.h:168
Parameters
- const std::string& Filename
- llvm::SMLoc IncludeLoc
- std::string& IncludedFile
¶unsigned int AddNewSourceBuffer(
std::unique_ptr<MemoryBuffer> F,
llvm::SMLoc IncludeLoc)
unsigned int AddNewSourceBuffer(
std::unique_ptr<MemoryBuffer> F,
llvm::SMLoc IncludeLoc)
Description
Add a new source buffer to this source manager. This takes ownership of the memory buffer.
Declared at: llvm/include/llvm/Support/SourceMgr.h:153
Parameters
- std::unique_ptr<MemoryBuffer> F
- llvm::SMLoc IncludeLoc
¶unsigned int FindBufferContainingLoc(
llvm::SMLoc Loc) const
unsigned int FindBufferContainingLoc(
llvm::SMLoc Loc) const
Description
Return the ID of the buffer containing the specified location. 0 is returned if the buffer is not found.
Declared at: llvm/include/llvm/Support/SourceMgr.h:174
Parameters
- llvm::SMLoc Loc
¶unsigned int FindLineNumber(
llvm::SMLoc Loc,
unsigned int BufferID = 0) const
unsigned int FindLineNumber(
llvm::SMLoc Loc,
unsigned int BufferID = 0) const
Description
Find the line number for the specified location in the specified file. This is not a fast method.
Declared at: llvm/include/llvm/Support/SourceMgr.h:178
Parameters
- llvm::SMLoc Loc
- unsigned int BufferID = 0
¶llvm::SMDiagnostic GetMessage(
llvm::SMLoc Loc,
llvm::SourceMgr::DiagKind Kind,
const llvm::Twine& Msg,
ArrayRef<llvm::SMRange> Ranges = None,
ArrayRef<llvm::SMFixIt> FixIts = None) const
llvm::SMDiagnostic GetMessage(
llvm::SMLoc Loc,
llvm::SourceMgr::DiagKind Kind,
const llvm::Twine& Msg,
ArrayRef<llvm::SMRange> Ranges = None,
ArrayRef<llvm::SMFixIt> FixIts = None) const
Description
Return an SMDiagnostic at the specified location with the specified string.
Declared at: llvm/include/llvm/Support/SourceMgr.h:215
Parameters
- llvm::SMLoc Loc
- llvm::SourceMgr::DiagKind Kind
- const llvm::Twine& Msg
- If non-null, the kind of message (e.g., "error") which is prefixed to the message.
- ArrayRef<llvm::SMRange> Ranges = None
- ArrayRef<llvm::SMFixIt> FixIts = None
¶void PrintIncludeStack(
llvm::SMLoc IncludeLoc,
llvm::raw_ostream& OS) const
void PrintIncludeStack(
llvm::SMLoc IncludeLoc,
llvm::raw_ostream& OS) const
Description
Prints the names of included files and the line of the file they were included from. A diagnostic handler can use this before printing its custom formatted message.
Declared at: llvm/include/llvm/Support/SourceMgr.h:225
Parameters
- llvm::SMLoc IncludeLoc
- The location of the include.
- llvm::raw_ostream& OS
- the raw_ostream to print on.
¶void PrintMessage(
llvm::raw_ostream& OS,
const llvm::SMDiagnostic& Diagnostic,
bool ShowColors = true) const
void PrintMessage(
llvm::raw_ostream& OS,
const llvm::SMDiagnostic& Diagnostic,
bool ShowColors = true) const
Description
Emits a manually-constructed diagnostic to the given output stream.
Declared at: llvm/include/llvm/Support/SourceMgr.h:207
Parameters
- llvm::raw_ostream& OS
- const llvm::SMDiagnostic& Diagnostic
- bool ShowColors = true
- Display colored messages if output is a terminal and the default error handler is used.
¶void PrintMessage(
llvm::SMLoc Loc,
llvm::SourceMgr::DiagKind Kind,
const llvm::Twine& Msg,
ArrayRef<llvm::SMRange> Ranges = None,
ArrayRef<llvm::SMFixIt> FixIts = None,
bool ShowColors = true) const
void PrintMessage(
llvm::SMLoc Loc,
llvm::SourceMgr::DiagKind Kind,
const llvm::Twine& Msg,
ArrayRef<llvm::SMRange> Ranges = None,
ArrayRef<llvm::SMFixIt> FixIts = None,
bool ShowColors = true) const
Description
Emits a diagnostic to llvm::errs().
Declared at: llvm/include/llvm/Support/SourceMgr.h:198
Parameters
- llvm::SMLoc Loc
- llvm::SourceMgr::DiagKind Kind
- const llvm::Twine& Msg
- ArrayRef<llvm::SMRange> Ranges = None
- ArrayRef<llvm::SMFixIt> FixIts = None
- bool ShowColors = true
¶void PrintMessage(
llvm::raw_ostream& OS,
llvm::SMLoc Loc,
llvm::SourceMgr::DiagKind Kind,
const llvm::Twine& Msg,
ArrayRef<llvm::SMRange> Ranges = None,
ArrayRef<llvm::SMFixIt> FixIts = None,
bool ShowColors = true) const
void PrintMessage(
llvm::raw_ostream& OS,
llvm::SMLoc Loc,
llvm::SourceMgr::DiagKind Kind,
const llvm::Twine& Msg,
ArrayRef<llvm::SMRange> Ranges = None,
ArrayRef<llvm::SMFixIt> FixIts = None,
bool ShowColors = true) const
Description
Emit a message about the specified location with the specified string.
Declared at: llvm/include/llvm/Support/SourceMgr.h:191
Parameters
- llvm::raw_ostream& OS
- llvm::SMLoc Loc
- llvm::SourceMgr::DiagKind Kind
- const llvm::Twine& Msg
- ArrayRef<llvm::SMRange> Ranges = None
- ArrayRef<llvm::SMFixIt> FixIts = None
- bool ShowColors = true
- Display colored messages if output is a terminal and the default error handler is used.
¶SourceMgr(const llvm::SourceMgr&)
SourceMgr(const llvm::SourceMgr&)
Declared at: llvm/include/llvm/Support/SourceMgr.h:107
Parameters
- const llvm::SourceMgr&
¶SourceMgr(llvm::SourceMgr&&)
SourceMgr(llvm::SourceMgr&&)
Declared at: llvm/include/llvm/Support/SourceMgr.h:109
Parameters
¶SourceMgr()
SourceMgr()
Declared at: llvm/include/llvm/Support/SourceMgr.h:106
¶const llvm::SourceMgr::SrcBuffer& getBufferInfo(
unsigned int i) const
const llvm::SourceMgr::SrcBuffer& getBufferInfo(
unsigned int i) const
Declared at: llvm/include/llvm/Support/SourceMgr.h:127
Parameters
- unsigned int i
¶void* getDiagContext() const
void* getDiagContext() const
Declared at: llvm/include/llvm/Support/SourceMgr.h:125
¶llvm::SourceMgr::DiagHandlerTy getDiagHandler()
const
llvm::SourceMgr::DiagHandlerTy getDiagHandler()
const
Declared at: llvm/include/llvm/Support/SourceMgr.h:124
¶std::pair<unsigned int, unsigned int>
getLineAndColumn(llvm::SMLoc Loc,
unsigned int BufferID = 0) const
std::pair<unsigned int, unsigned int>
getLineAndColumn(llvm::SMLoc Loc,
unsigned int BufferID = 0) const
Description
Find the line and column number for the specified location in the specified file. This is not a fast method.
Declared at: llvm/include/llvm/Support/SourceMgr.h:184
Parameters
- llvm::SMLoc Loc
- unsigned int BufferID = 0
¶unsigned int getMainFileID() const
unsigned int getMainFileID() const
Declared at: llvm/include/llvm/Support/SourceMgr.h:141
¶const llvm::MemoryBuffer* getMemoryBuffer(
unsigned int i) const
const llvm::MemoryBuffer* getMemoryBuffer(
unsigned int i) const
Declared at: llvm/include/llvm/Support/SourceMgr.h:132
Parameters
- unsigned int i
¶unsigned int getNumBuffers() const
unsigned int getNumBuffers() const
Declared at: llvm/include/llvm/Support/SourceMgr.h:137
¶llvm::SMLoc getParentIncludeLoc(
unsigned int i) const
llvm::SMLoc getParentIncludeLoc(
unsigned int i) const
Declared at: llvm/include/llvm/Support/SourceMgr.h:146
Parameters
- unsigned int i
¶void setDiagHandler(
llvm::SourceMgr::DiagHandlerTy DH,
void* Ctx = nullptr)
void setDiagHandler(
llvm::SourceMgr::DiagHandlerTy DH,
void* Ctx = nullptr)
Description
Specify a diagnostic handler to be invoked every time PrintMessage is called. \p Ctx is passed into the handler when it is invoked.
Declared at: llvm/include/llvm/Support/SourceMgr.h:119
Parameters
- llvm::SourceMgr::DiagHandlerTy DH
- void* Ctx = nullptr
¶void setIncludeDirs(
const std::vector<std::string>& Dirs)
void setIncludeDirs(
const std::vector<std::string>& Dirs)
Declared at: llvm/include/llvm/Support/SourceMgr.h:113
Parameters
- const std::vector<std::string>& Dirs
¶~SourceMgr()
~SourceMgr()
Declared at: llvm/include/llvm/Support/SourceMgr.h:111