Skip to content

Commit 9553655

Browse files
committed
[MCParser] Bring back srcmanager diagnostics in AsmParser
AsmParser may have no LLVMContext attached to it, which means after 5de2d18 everything goes to stderr. Restore the old behavior.
1 parent caa5144 commit 9553655

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,10 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
23702370
// manager changed or buffer changed (like in a nested include) then just
23712371
// print the normal diagnostic using its Filename and LineNo.
23722372
if (!Parser->CppHashInfo.LineNumber || DiagBuf != CppHashBuf) {
2373-
Parser->getContext().diagnose(Diag);
2373+
if (Parser->SavedDiagHandler)
2374+
Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2375+
else
2376+
Parser->getContext().diagnose(Diag);
23742377
return;
23752378
}
23762379

@@ -2389,7 +2392,10 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
23892392
Diag.getColumnNo(), Diag.getKind(), Diag.getMessage(),
23902393
Diag.getLineContents(), Diag.getRanges());
23912394

2392-
Parser->getContext().diagnose(NewDiag);
2395+
if (Parser->SavedDiagHandler)
2396+
Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
2397+
else
2398+
Parser->getContext().diagnose(NewDiag);
23932399
}
23942400

23952401
// FIXME: This is mostly duplicated from the function in AsmLexer.cpp. The

0 commit comments

Comments
 (0)