commit 5f453d2: [Minor] Another try to workaround the clang bug
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Oct 17 17:56:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-17 18:49:31 +0100
URL: https://github.com/rspamd/rspamd/commit/5f453d2a9e92fafe1f3b043f640c0c589e193750 (HEAD -> master)
[Minor] Another try to workaround the clang bug
---
clang-plugin/printf_check.cc | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc
index 76b306b51..9589f8d9c 100644
--- a/clang-plugin/printf_check.cc
+++ b/clang-plugin/printf_check.cc
@@ -84,7 +84,7 @@ namespace rspamd {
using arg_parser_t = bool (*) (const Expr *, struct PrintfArgChecker *);
static void
- print_error (const std::string &err, const Expr *e, const ASTContext *ast,
+ print_error (const char *err, const Expr *e, const ASTContext *ast,
CompilerInstance *ci)
{
auto loc = e->getExprLoc ();
@@ -95,7 +95,7 @@ namespace rspamd {
}
static void
- print_warning (const std::string &err, const Expr *e, const ASTContext *ast,
+ print_warning (const char *err, const Expr *e, const ASTContext *ast,
CompilerInstance *ci)
{
auto loc = e->getExprLoc ();
@@ -105,6 +105,17 @@ namespace rspamd {
diag.Report (loc, id) << err;
}
+ static void
+ print_remark (const char *err, const Expr *e, const ASTContext *ast,
+ CompilerInstance *ci)
+ {
+ auto loc = e->getExprLoc ();
+ auto &diag = ci->getDiagnostics ();
+ auto id = diag.getCustomDiagID (DiagnosticsEngine::Remark,
+ "format query warning: %0");
+ diag.Report (loc, id) << err;
+ }
+
struct PrintfArgChecker {
private:
arg_parser_t parser;
@@ -390,7 +401,7 @@ namespace rspamd {
auto query = args[pos];
if (!query->isEvaluatable (*pcontext)) {
- print_warning (std::string ("cannot evaluate query"),
+ print_remark ("cannot evaluate query",
E, this->pcontext, this->ci);
/* It is not assumed to be an error */
return true;
@@ -399,7 +410,7 @@ namespace rspamd {
clang::Expr::EvalResult r;
if (!query->EvaluateAsRValue (r, *pcontext)) {
- print_warning (std::string ("cannot evaluate rvalue of query"),
+ print_warning ("cannot evaluate rvalue of query",
E, this->pcontext, this->ci);
return false;
}
@@ -407,7 +418,7 @@ namespace rspamd {
auto qval = dyn_cast<StringLiteral> (
r.Val.getLValueBase ().get<const Expr *> ());
if (!qval) {
- print_warning (std::string ("bad or absent query string"),
+ print_warning ("bad or absent query string",
E, this->pcontext, this->ci);
return false;
}
@@ -425,7 +436,7 @@ namespace rspamd {
<< ", got " <<
(E->getNumArgs () - (pos + 1))
<< " args";
- print_error (err_buf.str (), E, this->pcontext, this->ci);
+ print_error (err_buf.str(), E, this->pcontext, this->ci);
return false;
}
More information about the Commits
mailing list