llvm.org GIT mirror llvm / 341149a
Switch the LLVM error reporting on the new diagnostic system. The LLVM diagnostic are now wired-up in clang (since r200931), thus the user experience will not be impacted by this change anymore. Related to <rdar://problem/15886697> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201915 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 6 years ago
1 changed file(s) with 4 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
114114 }
115115
116116 void LLVMContext::emitError(const Twine &ErrorStr) {
117 emitError(0U, ErrorStr);
117 diagnose(DiagnosticInfoInlineAsm(ErrorStr));
118118 }
119119
120120 void LLVMContext::emitError(const Instruction *I, const Twine &ErrorStr) {
121 unsigned LocCookie = 0;
122 if (const MDNode *SrcLoc = I->getMetadata("srcloc")) {
123 if (SrcLoc->getNumOperands() != 0)
124 if (const ConstantInt *CI = dyn_cast(SrcLoc->getOperand(0)))
125 LocCookie = CI->getZExtValue();
126 }
127 return emitError(LocCookie, ErrorStr);
121 assert (I && "Invalid instruction");
122 diagnose(DiagnosticInfoInlineAsm(*I, ErrorStr));
128123 }
129124
130125 void LLVMContext::diagnose(const DiagnosticInfo &DI) {
153148 }
154149
155150 void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) {
156 // If there is no error handler installed, just print the error and exit.
157 if (pImpl->InlineAsmDiagHandler == 0) {
158 errs() << "error: " << ErrorStr << "\n";
159 exit(1);
160 }
161
162 // If we do have an error handler, we can report the error and keep going.
163 SMDiagnostic Diag("", SourceMgr::DK_Error, ErrorStr.str());
164
165 pImpl->InlineAsmDiagHandler(Diag, pImpl->InlineAsmDiagContext, LocCookie);
151 diagnose(DiagnosticInfoInlineAsm(LocCookie, ErrorStr));
166152 }
167153
168154 //===----------------------------------------------------------------------===//