|
14 | 14 | #include "clang/AST/ASTContext.h"
|
15 | 15 | #include "clang/AST/DeclCXX.h"
|
16 | 16 | #include "clang/AST/DeclGroup.h"
|
| 17 | +#include "clang/Basic/DiagnosticFrontend.h" |
17 | 18 | #include "clang/Basic/FileManager.h"
|
18 | 19 | #include "clang/Basic/LangStandard.h"
|
19 | 20 | #include "clang/Basic/SourceManager.h"
|
@@ -365,6 +366,9 @@ namespace clang {
|
365 | 366 | bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
|
366 | 367 | /// Specialized handler for unsupported backend feature diagnostic.
|
367 | 368 | void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D);
|
| 369 | + /// Specialized handler for misexpect warnings. |
| 370 | + /// Note that misexpect remarks are emitted through ORE |
| 371 | + void MisExpectDiagHandler(const llvm::DiagnosticInfoMisExpect &D); |
368 | 372 | /// Specialized handlers for optimization remarks.
|
369 | 373 | /// Note that these handlers only accept remarks and they always handle
|
370 | 374 | /// them.
|
@@ -617,6 +621,25 @@ void BackendConsumer::UnsupportedDiagHandler(
|
617 | 621 | << Filename << Line << Column;
|
618 | 622 | }
|
619 | 623 |
|
| 624 | +void BackendConsumer::MisExpectDiagHandler( |
| 625 | + const llvm::DiagnosticInfoMisExpect &D) { |
| 626 | + StringRef Filename; |
| 627 | + unsigned Line, Column; |
| 628 | + bool BadDebugInfo = false; |
| 629 | + FullSourceLoc Loc = |
| 630 | + getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column); |
| 631 | + |
| 632 | + Diags.Report(Loc, diag::warn_profile_data_misexpect) << D.getMsg().str(); |
| 633 | + |
| 634 | + if (BadDebugInfo) |
| 635 | + // If we were not able to translate the file:line:col information |
| 636 | + // back to a SourceLocation, at least emit a note stating that |
| 637 | + // we could not translate this location. This can happen in the |
| 638 | + // case of #line directives. |
| 639 | + Diags.Report(Loc, diag::note_fe_backend_invalid_loc) |
| 640 | + << Filename << Line << Column; |
| 641 | +} |
| 642 | + |
620 | 643 | void BackendConsumer::EmitOptimizationMessage(
|
621 | 644 | const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
|
622 | 645 | // We only support warnings and remarks.
|
@@ -787,6 +810,9 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
|
787 | 810 | case llvm::DK_Unsupported:
|
788 | 811 | UnsupportedDiagHandler(cast<DiagnosticInfoUnsupported>(DI));
|
789 | 812 | return;
|
| 813 | + case llvm::DK_MisExpect: |
| 814 | + MisExpectDiagHandler(cast<DiagnosticInfoMisExpect>(DI)); |
| 815 | + return; |
790 | 816 | default:
|
791 | 817 | // Plugin IDs are not bound to any value as they are set dynamically.
|
792 | 818 | ComputeDiagRemarkID(Severity, backend_plugin, DiagID);
|
|
0 commit comments