|
@@ -14,6 +14,7 @@
|
|
#include "clang/AST/ASTContext.h"
|
|
#include "clang/AST/ASTContext.h"
|
|
#include "clang/AST/DeclCXX.h"
|
|
#include "clang/AST/DeclCXX.h"
|
|
#include "clang/AST/DeclGroup.h"
|
|
#include "clang/AST/DeclGroup.h"
|
|
|
|
+#include "clang/Basic/DiagnosticFrontend.h"
|
|
#include "clang/Basic/FileManager.h"
|
|
#include "clang/Basic/FileManager.h"
|
|
#include "clang/Basic/LangStandard.h"
|
|
#include "clang/Basic/LangStandard.h"
|
|
#include "clang/Basic/SourceManager.h"
|
|
#include "clang/Basic/SourceManager.h"
|
|
@@ -365,6 +366,9 @@ namespace clang {
|
|
bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
|
|
bool StackSizeDiagHandler(const llvm::DiagnosticInfoStackSize &D);
|
|
/// Specialized handler for unsupported backend feature diagnostic.
|
|
/// Specialized handler for unsupported backend feature diagnostic.
|
|
void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D);
|
|
void UnsupportedDiagHandler(const llvm::DiagnosticInfoUnsupported &D);
|
|
|
|
+ /// Specialized handler for misexpect warnings.
|
|
|
|
+ /// Note that misexpect remarks are emitted through ORE
|
|
|
|
+ void MisExpectDiagHandler(const llvm::DiagnosticInfoMisExpect &D);
|
|
/// Specialized handlers for optimization remarks.
|
|
/// Specialized handlers for optimization remarks.
|
|
/// Note that these handlers only accept remarks and they always handle
|
|
/// Note that these handlers only accept remarks and they always handle
|
|
/// them.
|
|
/// them.
|
|
@@ -617,6 +621,25 @@ void BackendConsumer::UnsupportedDiagHandler(
|
|
<< Filename << Line << Column;
|
|
<< Filename << Line << Column;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void BackendConsumer::MisExpectDiagHandler(
|
|
|
|
+ const llvm::DiagnosticInfoMisExpect &D) {
|
|
|
|
+ StringRef Filename;
|
|
|
|
+ unsigned Line, Column;
|
|
|
|
+ bool BadDebugInfo = false;
|
|
|
|
+ FullSourceLoc Loc =
|
|
|
|
+ getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);
|
|
|
|
+
|
|
|
|
+ Diags.Report(Loc, diag::warn_profile_data_misexpect) << D.getMsg().str();
|
|
|
|
+
|
|
|
|
+ if (BadDebugInfo)
|
|
|
|
+ // If we were not able to translate the file:line:col information
|
|
|
|
+ // back to a SourceLocation, at least emit a note stating that
|
|
|
|
+ // we could not translate this location. This can happen in the
|
|
|
|
+ // case of #line directives.
|
|
|
|
+ Diags.Report(Loc, diag::note_fe_backend_invalid_loc)
|
|
|
|
+ << Filename << Line << Column;
|
|
|
|
+}
|
|
|
|
+
|
|
void BackendConsumer::EmitOptimizationMessage(
|
|
void BackendConsumer::EmitOptimizationMessage(
|
|
const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
|
|
const llvm::DiagnosticInfoOptimizationBase &D, unsigned DiagID) {
|
|
// We only support warnings and remarks.
|
|
// We only support warnings and remarks.
|
|
@@ -787,6 +810,9 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
|
|
case llvm::DK_Unsupported:
|
|
case llvm::DK_Unsupported:
|
|
UnsupportedDiagHandler(cast<DiagnosticInfoUnsupported>(DI));
|
|
UnsupportedDiagHandler(cast<DiagnosticInfoUnsupported>(DI));
|
|
return;
|
|
return;
|
|
|
|
+ case llvm::DK_MisExpect:
|
|
|
|
+ MisExpectDiagHandler(cast<DiagnosticInfoMisExpect>(DI));
|
|
|
|
+ return;
|
|
default:
|
|
default:
|
|
// Plugin IDs are not bound to any value as they are set dynamically.
|
|
// Plugin IDs are not bound to any value as they are set dynamically.
|
|
ComputeDiagRemarkID(Severity, backend_plugin, DiagID);
|
|
ComputeDiagRemarkID(Severity, backend_plugin, DiagID);
|