mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-15 15:48:38 +00:00
PR11143: Save the old diagnostic handler and call it when munging diagnostics for #line directives.
This reenables proper inline asm diagnostics in clang llvm-svn: 142132
This commit is contained in:
parent
a733f43137
commit
8f3fa2bc50
@ -82,6 +82,9 @@ public:
|
||||
DiagContext = Ctx;
|
||||
}
|
||||
|
||||
DiagHandlerTy getDiagHandler() const { return DiagHandler; }
|
||||
void *getDiagContext() const { return DiagContext; }
|
||||
|
||||
const SrcBuffer &getBufferInfo(unsigned i) const {
|
||||
assert(i < Buffers.size() && "Invalid Buffer ID!");
|
||||
return Buffers[i];
|
||||
|
@ -87,6 +87,8 @@ private:
|
||||
MCStreamer &Out;
|
||||
const MCAsmInfo &MAI;
|
||||
SourceMgr &SrcMgr;
|
||||
SourceMgr::DiagHandlerTy SavedDiagHandler;
|
||||
void *SavedDiagContext;
|
||||
MCAsmParserExtension *GenericParser;
|
||||
MCAsmParserExtension *PlatformParser;
|
||||
|
||||
@ -353,6 +355,10 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx,
|
||||
: Lexer(_MAI), Ctx(_Ctx), Out(_Out), MAI(_MAI), SrcMgr(_SM),
|
||||
GenericParser(new GenericAsmParser), PlatformParser(0),
|
||||
CurBuffer(0), MacrosEnabled(true), CppHashLineNumber(0) {
|
||||
// Save the old handler.
|
||||
SavedDiagHandler = SrcMgr.getDiagHandler();
|
||||
SavedDiagContext = SrcMgr.getDiagContext();
|
||||
// Set our own handler which calls the saved handler.
|
||||
SrcMgr.setDiagHandler(DiagHandler, this);
|
||||
Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
|
||||
|
||||
@ -1276,7 +1282,7 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
|
||||
// Like SourceMgr::PrintMessage() we need to print the include stack if any
|
||||
// before printing the message.
|
||||
int DiagCurBuffer = DiagSrcMgr.FindBufferContainingLoc(DiagLoc);
|
||||
if (DiagCurBuffer > 0) {
|
||||
if (!Parser->SavedDiagHandler && DiagCurBuffer > 0) {
|
||||
SMLoc ParentIncludeLoc = DiagSrcMgr.getParentIncludeLoc(DiagCurBuffer);
|
||||
DiagSrcMgr.PrintIncludeStack(ParentIncludeLoc, OS);
|
||||
}
|
||||
@ -1287,7 +1293,10 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
|
||||
if (!Parser->CppHashLineNumber ||
|
||||
&DiagSrcMgr != &Parser->SrcMgr ||
|
||||
DiagBuf != CppHashBuf) {
|
||||
Diag.print(0, OS);
|
||||
if (Parser->SavedDiagHandler)
|
||||
Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
|
||||
else
|
||||
Diag.print(0, OS);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1307,7 +1316,10 @@ void AsmParser::DiagHandler(const SMDiagnostic &Diag, void *Context) {
|
||||
Diag.getKind(), Diag.getMessage(),
|
||||
Diag.getLineContents(), Diag.getRanges());
|
||||
|
||||
NewDiag.print(0, OS);
|
||||
if (Parser->SavedDiagHandler)
|
||||
Parser->SavedDiagHandler(NewDiag, Parser->SavedDiagContext);
|
||||
else
|
||||
NewDiag.print(0, OS);
|
||||
}
|
||||
|
||||
bool AsmParser::expandMacro(SmallString<256> &Buf, StringRef Body,
|
||||
|
Loading…
Reference in New Issue
Block a user