llvm.org GIT mirror llvm / 70c2f2c
Apply r142132: PR11143: Save the old diagnostic handler and call it when munging diagnostics for #line directives. This reenables proper inline asm diagnostics in clang git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_30@142169 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
2 changed file(s) with 18 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7676 DiagHandler = DH;
7777 DiagContext = Ctx;
7878 }
79
80 DiagHandlerTy getDiagHandler() const { return DiagHandler; }
81 void *getDiagContext() const { return DiagContext; }
7982
8083 const SrcBuffer &getBufferInfo(unsigned i) const {
8184 assert(i < Buffers.size() && "Invalid Buffer ID!");
8686 MCStreamer &Out;
8787 const MCAsmInfo &MAI;
8888 SourceMgr &SrcMgr;
89 SourceMgr::DiagHandlerTy SavedDiagHandler;
90 void *SavedDiagContext;
8991 MCAsmParserExtension *GenericParser;
9092 MCAsmParserExtension *PlatformParser;
9193
350352 : Lexer(_MAI), Ctx(_Ctx), Out(_Out), MAI(_MAI), SrcMgr(_SM),
351353 GenericParser(new GenericAsmParser), PlatformParser(0),
352354 CurBuffer(0), MacrosEnabled(true), CppHashLineNumber(0) {
355 // Save the old handler.
356 SavedDiagHandler = SrcMgr.getDiagHandler();
357 SavedDiagContext = SrcMgr.getDiagContext();
358 // Set our own handler which calls the saved handler.
353359 SrcMgr.setDiagHandler(DiagHandler, this);
354360 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));
355361
12721278 // Like SourceMgr::PrintMessage() we need to print the include stack if any
12731279 // before printing the message.
12741280 int DiagCurBuffer = DiagSrcMgr.FindBufferContainingLoc(DiagLoc);
1275 if (DiagCurBuffer > 0) {
1281 if (!Parser->SavedDiagHandler && DiagCurBuffer > 0) {
12761282 SMLoc ParentIncludeLoc = DiagSrcMgr.getParentIncludeLoc(DiagCurBuffer);
12771283 DiagSrcMgr.PrintIncludeStack(ParentIncludeLoc, OS);
12781284 }
12831289 if (!Parser->CppHashLineNumber ||
12841290 &DiagSrcMgr != &Parser->SrcMgr ||
12851291 DiagBuf != CppHashBuf) {
1286 Diag.Print(0, OS);
1292 if (Parser->SavedDiagHandler)
1293 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext);
1294 else
1295 Diag.Print(0, OS);
12871296 return;
12881297 }
12891298
13071316 Diag.getLineContents(),
13081317 Diag.getShowLine());
13091318
1310 NewDiag.Print(0, OS);
1319 if (Parser->SavedDiagHandler)
1320 Parser->SavedDiagHandler(NewDiag, Parser->SavedDiagContext);
1321 else
1322 NewDiag.Print(0, OS);
13111323 }
13121324
13131325 bool AsmParser::expandMacro(SmallString<256> &Buf, StringRef Body,