diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 789c06a..6e1d7f3 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -27,6 +27,7 @@ #include "clang/Lex/Preprocessor.h" #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" +#include "llvm/Demangle/Demangle.h" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/DiagnosticPrinter.h" @@ -760,30 +761,18 @@ void BackendConsumer::OptimizationFailureHandler( } void BackendConsumer::DontCallDiagHandler(const DiagnosticInfoDontCall &D) { - if (const Decl *DE = Gen->GetDeclForMangledName(D.getFunctionName())) - if (const auto *FD = dyn_cast<FunctionDecl>(DE)) { - assert(FD->hasAttr<ErrorAttr>() && - "expected error or warning function attribute"); - - if (const auto *EA = FD->getAttr<ErrorAttr>()) { - assert((EA->isError() || EA->isWarning()) && - "ErrorAttr neither error or warning"); - - SourceLocation LocCookie = - SourceLocation::getFromRawEncoding(D.getLocCookie()); - - // FIXME: we can't yet diagnose indirect calls. When/if we can, we - // should instead assert that LocCookie.isValid(). - if (!LocCookie.isValid()) - return; - - Diags.Report(LocCookie, EA->isError() - ? diag::err_fe_backend_error_attr - : diag::warn_fe_backend_warning_attr) - << FD << EA->getUserDiagnostic(); - } - } - // TODO: assert if DE or FD were nullptr? + SourceLocation LocCookie = + SourceLocation::getFromRawEncoding(D.getLocCookie()); + + // FIXME: we can't yet diagnose indirect calls. When/if we can, we + // should instead assert that LocCookie.isValid(). + if (!LocCookie.isValid()) + return; + + Diags.Report(LocCookie, D.getSeverity() == DiagnosticSeverity::DS_Error + ? diag::err_fe_backend_error_attr + : diag::warn_fe_backend_warning_attr) + << llvm::demangle(D.getFunctionName().str()) << D.getNote(); } /// This function is invoked when the backend needs |