]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Support time_t args in clang plugin
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 8 Apr 2017 08:56:09 +0000 (09:56 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 8 Apr 2017 08:56:09 +0000 (09:56 +0100)
clang-plugin/printf_check.cc

index d8aeee82842d8e402d5828265e74c15b5673aa78..f42d487b2372fe664499261dea0e208e0239560c 100644 (file)
@@ -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);
@@ -627,6 +633,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)
        {