[MCParser] Bring back srcmanager diagnostics in AsmParser

AsmParser may have no LLVMContext attached to it, which means after
5de2d189e6 everything goes to stderr.
Restore the old behavior.
This commit is contained in:
Benjamin Kramer 2021-03-02 13:41:50 +01:00
parent caa5144d56
commit 955365524a
1 changed files with 8 additions and 2 deletions

View File

@ -2370,6 +2370,9 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
// manager changed or buffer changed (like in a nested include) then just
// print the normal diagnostic using its Filename and LineNo.
if (!Parser->CppHashInfo.LineNumber || DiagBuf != CppHashBuf) {
if (Parser->SavedDiagHandler)
Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
else
Parser->getContext().diagnose(Diag);
return;
}
@ -2389,6 +2392,9 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
Diag.getColumnNo(), Diag.getKind(), Diag.getMessage(),
Diag.getLineContents(), Diag.getRanges());
if (Parser->SavedDiagHandler)
Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
else
Parser->getContext().diagnose(NewDiag);
}