class MemoryBuffer;
class SourceMgr;
class SMDiagnostic;
+ class Twine;
class raw_ostream;
/// SourceMgr - This owns the files read by a parser, handles include stacks,
/// DiagHandlerTy - Clients that want to handle their own diagnostics in a
/// custom way can register a function pointer+context as a diagnostic
/// handler. It gets called each time PrintMessage is invoked.
- typedef void (*DiagHandlerTy)(const SMDiagnostic&, void *Context,
- unsigned LocCookie);
+ typedef void (*DiagHandlerTy)(const SMDiagnostic&, void *Context);
private:
struct SrcBuffer {
/// Buffer - The memory buffer for the file.
DiagHandlerTy DiagHandler;
void *DiagContext;
- unsigned DiagLocCookie;
SourceMgr(const SourceMgr&); // DO NOT IMPLEMENT
void operator=(const SourceMgr&); // DO NOT IMPLEMENT
}
/// setDiagHandler - Specify a diagnostic handler to be invoked every time
- /// PrintMessage is called. Ctx and Cookie are passed into the handler when
- /// it is invoked.
- void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0, unsigned Cookie = 0) {
+ /// PrintMessage is called. Ctx is passed into the handler when it is invoked.
+ void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0) {
DiagHandler = DH;
DiagContext = Ctx;
- DiagLocCookie = Cookie;
}
const SrcBuffer &getBufferInfo(unsigned i) const {
/// @param Type - If non-null, the kind of message (e.g., "error") which is
/// prefixed to the message.
/// @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 Twine &Msg, const char *Type,
bool ShowLine = true) const;
/// prefixed to the message.
/// @param ShowLine - Should the diagnostic show the source line.
SMDiagnostic GetMessage(SMLoc Loc,
- const std::string &Msg, const char *Type,
+ const Twine &Msg, const char *Type,
bool ShowLine = true) const;
// Diagnostic with no location (e.g. file not found, command line arg error).
SMDiagnostic(const std::string &filename, const std::string &Msg,
bool showline = true)
- : SM(0), Loc(), Filename(filename), LineNo(-1), ColumnNo(-1),
- Message(Msg), LineContents(""), ShowLine(showline) {}
+ : SM(0), Filename(filename), LineNo(-1), ColumnNo(-1),
+ Message(Msg), ShowLine(showline) {}
// Diagnostic with a location.
SMDiagnostic(const SourceMgr &sm, SMLoc L, const std::string &FN,
const SourceMgr *getSourceMgr() const { return SM; }
SMLoc getLoc() const { return Loc; }
- const std::string getFilename() { return Filename; }
+ const std::string &getFilename() { return Filename; }
int getLineNo() const { return LineNo; }
int getColumnNo() const { return ColumnNo; }
const std::string &getMessage() const { return Message; }