give the SourceMgr object a cookie.
authorChris Lattner <sabre@nondot.org>
Tue, 6 Apr 2010 00:33:43 +0000 (00:33 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 6 Apr 2010 00:33:43 +0000 (00:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100504 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/SourceMgr.h
lib/Support/SourceMgr.cpp

index caa67c03c593f06d25d246b36215012b055ebb43..3e66762ae349023660c9d63ea8dd33ea97c39b8f 100644 (file)
@@ -35,7 +35,8 @@ public:
   /// 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);
+  typedef void (*DiagHandlerTy)(const SMDiagnostic&, void *Context,
+                                unsigned LocCookie);
 private:
   struct SrcBuffer {
     /// Buffer - The memory buffer for the file.
@@ -59,6 +60,7 @@ private:
 
   DiagHandlerTy DiagHandler;
   void *DiagContext;
+  unsigned DiagLocCookie;
   
   SourceMgr(const SourceMgr&);    // DO NOT IMPLEMENT
   void operator=(const SourceMgr&); // DO NOT IMPLEMENT
@@ -71,10 +73,12 @@ public:
   }
 
   /// setDiagHandler - Specify a diagnostic handler to be invoked every time
-  /// PrintMessage is called.
-  void setDiagHandler(DiagHandlerTy DH, void *Ctx = 0) {
+  /// 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) {
     DiagHandler = DH;
     DiagContext = Ctx;
+    DiagLocCookie = Cookie;
   }
 
   const SrcBuffer &getBufferInfo(unsigned i) const {
index fe2fbd96f7724d505705f41c7119996c6ebf0aac..4e7520c9d3397ccf128114ee112e465e0164984b 100644 (file)
@@ -178,7 +178,8 @@ void SourceMgr::PrintMessage(SMLoc Loc, const std::string &Msg,
                              const char *Type, bool ShowLine) const {
   // Report the message with the diagnostic handler if present.
   if (DiagHandler) {
-    DiagHandler(GetMessage(Loc, Msg, Type, ShowLine), DiagContext);
+    DiagHandler(GetMessage(Loc, Msg, Type, ShowLine),
+                DiagContext, DiagLocCookie);
     return;
   }