16 #ifndef LLVM_SUPPORT_SOURCEMGR_H 17 #define LLVM_SUPPORT_SOURCEMGR_H 59 std::unique_ptr<MemoryBuffer> Buffer;
66 std::vector<uint16_t> *,
67 std::vector<uint32_t> *,
68 std::vector<uint64_t> *>;
76 mutable VariableSizeOffsets OffsetCache;
83 unsigned getLineNumber(
const char *
Ptr)
const;
88 SrcBuffer() =
default;
89 SrcBuffer(SrcBuffer &&);
90 SrcBuffer(
const SrcBuffer &) =
delete;
91 SrcBuffer &
operator=(
const SrcBuffer &) =
delete;
96 std::vector<SrcBuffer> Buffers;
99 std::vector<std::string> IncludeDirectories;
102 void *DiagContext =
nullptr;
104 bool isValidBufferID(
unsigned i)
const {
return i && i <= Buffers.size(); }
113 IncludeDirectories = Dirs;
127 assert(isValidBufferID(i));
128 return Buffers[i - 1];
132 assert(isValidBufferID(i));
133 return Buffers[i - 1].Buffer.get();
137 return Buffers.size();
146 assert(isValidBufferID(i));
147 return Buffers[i - 1].IncludeLoc;
155 NB.Buffer = std::move(F);
156 NB.IncludeLoc = IncludeLoc;
157 Buffers.push_back(std::move(NB));
158 return Buffers.size();
168 std::string &IncludedFile);
184 unsigned BufferID = 0)
const;
194 bool ShowColors =
true)
const;
200 bool ShowColors =
true)
const;
207 bool ShowColors =
true)
const;
236 : Range(Loc, Loc), Text(Insertion.str()) {
242 : Range(R), Text(Replacement.str()) {
254 return Text < Other.Text;
263 std::string Filename;
267 std::string Message, LineContents;
268 std::vector<std::pair<unsigned, unsigned>> Ranges;
276 : Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd), Message(Msg) {}
282 ArrayRef<std::pair<unsigned,unsigned>> Ranges,
304 bool ShowKindLabel =
true)
const;
309 #endif // LLVM_SUPPORT_SOURCEMGR_H Represents a range in source code.
void push_back(const T &Elt)
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
Compute iterated dominance frontiers using a linear time algorithm.
DiagHandlerTy getDiagHandler() const
SMFixIt(SMLoc Loc, const Twine &Insertion)
unsigned getNumBuffers() const
void PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const
Prints the names of included files and the line of the file they were included from.
ArrayRef< SMFixIt > getFixIts() const
std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file. ...
void addFixIt(const SMFixIt &Hint)
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const MemoryBuffer * getMemoryBuffer(unsigned i) const
StringRef getLineContents() const
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
StringRef getText() const
unsigned getMainFileID() const
const char * getPointer() const
void setDiagHandler(DiagHandlerTy DH, void *Ctx=nullptr)
Specify a diagnostic handler to be invoked every time PrintMessage is called.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Represents a single fixit, a replacement of one range of text with another.
void(*)(const SMDiagnostic &, void *Context) DiagHandlerTy
Clients that want to handle their own diagnostics in a custom way can register a function pointer+con...
SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None) const
Return an SMDiagnostic at the specified location with the specified string.
const SrcBuffer & getBufferInfo(unsigned i) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
StringRef getMessage() const
ArrayRef< std::pair< unsigned, unsigned > > getRanges() const
This interface provides simple read-only access to a block of memory, and provides simple methods for...
StringRef getFilename() const
SourceMgr::DiagKind getKind() const
unsigned FindLineNumber(SMLoc Loc, unsigned BufferID=0) const
Find the line number for the specified location in the specified file.
bool operator<(const SMFixIt &Other) const
unsigned AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc, std::string &IncludedFile)
Search for a file with the specified name in the current directory or in one of the IncludeDirs...
SMLoc getParentIncludeLoc(unsigned i) const
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
void * getDiagContext() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SourceMgr & operator=(const SourceMgr &)=delete
This class implements an extremely fast bulk output stream that can only output to a stream...
void setIncludeDirs(const std::vector< std::string > &Dirs)
SMDiagnostic(StringRef filename, SourceMgr::DiagKind Knd, StringRef Msg)
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
SMFixIt(SMRange R, const Twine &Replacement)
const SourceMgr * getSourceMgr() const
A pointer union of four pointer types.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...