summaryrefslogtreecommitdiffstats
path: root/clang-plugin
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-08 09:56:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-04-08 09:56:09 +0100
commitae03a259fee413faf1540cd81087b3d08fad2c40 (patch)
tree34fcf981d11cffec9f24effd3479bab570ef84e4 /clang-plugin
parente409d221019f1127537d449273b7bf4c72085c55 (diff)
downloadrspamd-ae03a259fee413faf1540cd81087b3d08fad2c40.tar.gz
rspamd-ae03a259fee413faf1540cd81087b3d08fad2c40.zip
[Minor] Support time_t args in clang plugin
Diffstat (limited to 'clang-plugin')
-rw-r--r--clang-plugin/printf_check.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc
index d8aeee828..f42d487b2 100644
--- a/clang-plugin/printf_check.cc
+++ b/clang-plugin/printf_check.cc
@@ -60,6 +60,9 @@ namespace rspamd {
static bool pid_arg_handler (const Expr *arg,
struct PrintfArgChecker *ctx);
+ static bool time_arg_handler (const Expr *arg,
+ struct PrintfArgChecker *ctx);
+
static bool int64_arg_handler (const Expr *arg,
struct PrintfArgChecker *ctx);
@@ -175,6 +178,9 @@ namespace rspamd {
case 'P':
return llvm::make_unique<PrintfArgChecker> (pid_arg_handler,
this->pcontext, this->ci);
+ case 't':
+ return llvm::make_unique<PrintfArgChecker> (time_arg_handler,
+ this->pcontext, this->ci);
case 'L':
return llvm::make_unique<PrintfArgChecker> (int64_arg_handler,
this->pcontext, this->ci);
@@ -628,6 +634,28 @@ namespace rspamd {
}
static bool
+ time_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
+ {
+ if (sizeof (time_t) == sizeof (long)) {
+ return check_builtin_type (arg,
+ ctx,
+ {BuiltinType::Kind::ULong,
+ BuiltinType::Kind::Long},
+ "%t");
+ }
+ else if (sizeof (time_t) == sizeof (int)) {
+ return check_builtin_type (arg,
+ ctx,
+ {BuiltinType::Kind::UInt,
+ BuiltinType::Kind::Int},
+ "%t");
+ }
+ else {
+ assert (0);
+ }
+ }
+
+ static bool
pointer_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
{
auto type = arg->getType ().split ().Ty;