llvm.org GIT mirror llvm / f64c889
Revert "Rename LLVMContext diagnostic handler types and functions." This reverts my commit 171047. Now that I've removed my misguided attempt to support backend warnings, these diagnostics are only about inline assembly. It would take quite a bit more work to generalize them properly, so I'm just reverting this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174860 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 7 years ago
5 changed file(s) with 39 addition(s) and 49 deletion(s). Raw diff Collapse all Expand all
5757 void getMDKindNames(SmallVectorImpl &Result) const;
5858
5959
60 typedef void (*DiagHandlerTy)(const SMDiagnostic&, void *Context,
61 unsigned LocCookie);
60 typedef void (*InlineAsmDiagHandlerTy)(const SMDiagnostic&, void *Context,
61 unsigned LocCookie);
6262
63 /// setDiagnosticHandler - This method sets a handler that is invoked
64 /// when problems are detected by the backend. The first argument is a
65 /// function pointer and the second is a context pointer that gets passed
66 /// into the DiagHandler.
63 /// setInlineAsmDiagnosticHandler - This method sets a handler that is invoked
64 /// when problems with inline asm are detected by the backend. The first
65 /// argument is a function pointer and the second is a context pointer that
66 /// gets passed into the DiagHandler.
6767 ///
6868 /// LLVMContext doesn't take ownership or interpret either of these
6969 /// pointers.
70 void setDiagnosticHandler(DiagHandlerTy DiagHandler, void *DiagContext = 0);
70 void setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler,
71 void *DiagContext = 0);
7172
72 /// getDiagnosticHandler - Return the diagnostic handler set by
73 /// setDiagnosticHandler.
74 DiagHandlerTy getDiagnosticHandler() const;
73 /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by
74 /// setInlineAsmDiagnosticHandler.
75 InlineAsmDiagHandlerTy getInlineAsmDiagnosticHandler() const;
7576
76 /// getDiagnosticContext - Return the diagnostic context set by
77 /// setDiagnosticHandler.
78 void *getDiagnosticContext() const;
77 /// getInlineAsmDiagnosticContext - Return the diagnostic context set by
78 /// setInlineAsmDiagnosticHandler.
79 void *getInlineAsmDiagnosticContext() const;
7980
80 /// FIXME: Temporary copies of the old names; to be removed as soon as
81 /// clang switches to the new ones.
82 typedef DiagHandlerTy InlineAsmDiagHandlerTy;
83 void setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler,
84 void *DiagContext = 0) {
85 setDiagnosticHandler(DiagHandler, DiagContext);
86 }
87 InlineAsmDiagHandlerTy getInlineAsmDiagnosticHandler() const {
88 return getDiagnosticHandler();
89 }
90 void *getInlineAsmDiagnosticContext() const {
91 return getDiagnosticContext();
92 }
9381
9482 /// emitError - Emit an error message to the currently installed error handler
9583 /// with optional location information. This function returns, so code should
3737 namespace {
3838 struct SrcMgrDiagInfo {
3939 const MDNode *LocInfo;
40 LLVMContext::DiagHandlerTy DiagHandler;
40 LLVMContext::InlineAsmDiagHandlerTy DiagHandler;
4141 void *DiagContext;
4242 };
4343 }
8787 SourceMgr SrcMgr;
8888 SrcMgrDiagInfo DiagInfo;
8989
90 // If the current LLVMContext has a diagnostic handler, set it in SourceMgr.
90 // If the current LLVMContext has an inline asm handler, set it in SourceMgr.
9191 LLVMContext &LLVMCtx = MMI->getModule()->getContext();
9292 bool HasDiagHandler = false;
93 if (LLVMCtx.getDiagnosticHandler() != 0) {
93 if (LLVMCtx.getInlineAsmDiagnosticHandler() != 0) {
9494 // If the source manager has an issue, we arrange for srcMgrDiagHandler
9595 // to be invoked, getting DiagInfo passed into it.
9696 DiagInfo.LocInfo = LocMDNode;
97 DiagInfo.DiagHandler = LLVMCtx.getDiagnosticHandler();
98 DiagInfo.DiagContext = LLVMCtx.getDiagnosticContext();
97 DiagInfo.DiagHandler = LLVMCtx.getInlineAsmDiagnosticHandler();
98 DiagInfo.DiagContext = LLVMCtx.getInlineAsmDiagnosticContext();
9999 SrcMgr.setDiagHandler(srcMgrDiagHandler, &DiagInfo);
100100 HasDiagHandler = true;
101101 }
7272 // Recoverable Backend Errors
7373 //===----------------------------------------------------------------------===//
7474
75 void LLVMContext::setDiagnosticHandler(DiagHandlerTy DiagHandler,
76 void *DiagContext) {
77 pImpl->DiagHandler = DiagHandler;
78 pImpl->DiagContext = DiagContext;
75 void LLVMContext::
76 setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler,
77 void *DiagContext) {
78 pImpl->InlineAsmDiagHandler = DiagHandler;
79 pImpl->InlineAsmDiagContext = DiagContext;
7980 }
8081
81 /// getDiagnosticHandler - Return the diagnostic handler set by
82 /// setDiagnosticHandler.
83 LLVMContext::DiagHandlerTy LLVMContext::getDiagnosticHandler() const {
84 return pImpl->DiagHandler;
82 /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by
83 /// setInlineAsmDiagnosticHandler.
84 LLVMContext::InlineAsmDiagHandlerTy
85 LLVMContext::getInlineAsmDiagnosticHandler() const {
86 return pImpl->InlineAsmDiagHandler;
8587 }
8688
87 /// getDiagnosticContext - Return the diagnostic context set by
88 /// setDiagnosticHandler.
89 void *LLVMContext::getDiagnosticContext() const {
90 return pImpl->DiagContext;
89 /// getInlineAsmDiagnosticContext - Return the diagnostic context set by
90 /// setInlineAsmDiagnosticHandler.
91 void *LLVMContext::getInlineAsmDiagnosticContext() const {
92 return pImpl->InlineAsmDiagContext;
9193 }
9294
9395 void LLVMContext::emitError(const Twine &ErrorStr) {
106108
107109 void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) {
108110 // If there is no error handler installed, just print the error and exit.
109 if (pImpl->DiagHandler == 0) {
111 if (pImpl->InlineAsmDiagHandler == 0) {
110112 errs() << "error: " << ErrorStr << "\n";
111113 exit(1);
112114 }
114116 // If we do have an error handler, we can report the error and keep going.
115117 SMDiagnostic Diag("", SourceMgr::DK_Error, ErrorStr.str());
116118
117 pImpl->DiagHandler(Diag, pImpl->DiagContext, LocCookie);
119 pImpl->InlineAsmDiagHandler(Diag, pImpl->InlineAsmDiagContext, LocCookie);
118120 }
119121
120122 //===----------------------------------------------------------------------===//
3434 Int16Ty(C, 16),
3535 Int32Ty(C, 32),
3636 Int64Ty(C, 64) {
37 DiagHandler = 0;
38 DiagContext = 0;
37 InlineAsmDiagHandler = 0;
38 InlineAsmDiagContext = 0;
3939 NamedStructTypesUniqueID = 0;
4040 }
4141
235235 /// will be automatically deleted if this context is deleted.
236236 SmallPtrSet OwnedModules;
237237
238 LLVMContext::DiagHandlerTy DiagHandler;
239 void *DiagContext;
238 LLVMContext::InlineAsmDiagHandlerTy InlineAsmDiagHandler;
239 void *InlineAsmDiagContext;
240240
241241 typedef DenseMap
242242 DenseMapAPIntKeyInfo> IntMapTy;