summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;