diff options
author | Arthur Eubanks <aeubanks@google.com> | 2021-09-28 14:49:27 -0700 |
---|---|---|
committer | Arthur Eubanks <aeubanks@google.com> | 2021-09-28 14:49:27 -0700 |
commit | 7833d20f1fd575fac89ce76822ffd561a40552e5 (patch) | |
tree | 1a22ff11531048dd1f3467f8a4cacd33897e4d1f /clang/lib/CodeGen/CodeGenAction.cpp | |
parent | b69a2c8eeca1fee26283ca4c2f99c787aabba067 (diff) | |
download | llvm-7833d20f1fd575fac89ce76822ffd561a40552e5.zip llvm-7833d20f1fd575fac89ce76822ffd561a40552e5.tar.gz llvm-7833d20f1fd575fac89ce76822ffd561a40552e5.tar.bz2 |
Revert "[clang] Rework dontcall attributes"
This reverts commit 2943071e2ee0c7f31f34062a44d12aeb0e3a66fd.
Breaks bots
Diffstat (limited to 'clang/lib/CodeGen/CodeGenAction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenAction.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 6e1d7f3..789c06a 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -27,7 +27,6 @@ #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" @@ -761,18 +760,30 @@ void BackendConsumer::OptimizationFailureHandler( } void BackendConsumer::DontCallDiagHandler(const DiagnosticInfoDontCall &D) { - 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(); + 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? } /// This function is invoked when the backend needs |