summaryrefslogtreecommitdiffstats
path: root/clang-plugin
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-11 17:22:47 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-11 17:22:47 +0000
commite1bc656430d0f68a6676b39e6e08d58903dafe40 (patch)
treeba1e8e535df9603fe457288c405a643da35104fe /clang-plugin
parentc76507403484fe3598d781edb48664a59f34a03a (diff)
downloadrspamd-e1bc656430d0f68a6676b39e6e08d58903dafe40.tar.gz
rspamd-e1bc656430d0f68a6676b39e6e08d58903dafe40.zip
Improve fixed integers processing
Diffstat (limited to 'clang-plugin')
-rw-r--r--clang-plugin/printf_check.cc54
1 files changed, 40 insertions, 14 deletions
diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc
index 1cee49cd7..5d0411ab4 100644
--- a/clang-plugin/printf_check.cc
+++ b/clang-plugin/printf_check.cc
@@ -72,6 +72,9 @@ namespace rspamd {
static bool int64_arg_handler (const Expr *arg,
struct PrintfArgChecker *ctx);
+ static bool int32_arg_handler (const Expr *arg,
+ struct PrintfArgChecker *ctx);
+
static bool tok_arg_handler (const Expr *arg,
struct PrintfArgChecker *ctx);
@@ -181,6 +184,9 @@ namespace rspamd {
case 'L':
return llvm::make_unique<PrintfArgChecker> (int64_arg_handler,
this->pcontext, this->ci);
+ case 'D':
+ return llvm::make_unique<PrintfArgChecker> (int32_arg_handler,
+ this->pcontext, this->ci);
case 'T':
return llvm::make_unique<PrintfArgChecker> (tok_arg_handler,
this->pcontext, this->ci);
@@ -286,7 +292,7 @@ namespace rspamd {
if (isalpha (c)) {
flags.push_back (c);
}
-
+
auto handler = parseFlags (flags, e);
if (handler) {
@@ -627,24 +633,44 @@ namespace rspamd {
static bool
int64_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
{
+ std::vector <BuiltinType::Kind> check;
+
if (sizeof (int64_t) == sizeof (long long)) {
- return check_builtin_type (arg,
- ctx,
- {BuiltinType::Kind::ULongLong,
- BuiltinType::Kind::LongLong},
- "%L");
+ check.push_back (BuiltinType::Kind::ULongLong);
+ check.push_back (BuiltinType::Kind::LongLong);
}
- else if (sizeof (int64_t) == sizeof (long)) {
- return check_builtin_type (arg,
- ctx,
- {BuiltinType::Kind::ULong,
- BuiltinType::Kind::Long},
- "%z");
+ if (sizeof (int64_t) == sizeof (long)) {
+ check.push_back (BuiltinType::Kind::ULong);
+ check.push_back (BuiltinType::Kind::Long);
}
- else {
- assert (0);
+
+ return check_builtin_type (arg,
+ ctx,
+ check,
+ "%L");
+
+ return true;
+ }
+
+ static bool
+ int32_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
+ {
+ std::vector < BuiltinType::Kind> check;
+
+ if (sizeof (int32_t) == sizeof (long)) {
+ check.push_back (BuiltinType::Kind::ULong);
+ check.push_back (BuiltinType::Kind::Long);
+ }
+ if (sizeof (int32_t) == sizeof (int)) {
+ check.push_back (BuiltinType::Kind::UInt);
+ check.push_back (BuiltinType::Kind::Int);
}
+ return check_builtin_type (arg,
+ ctx,
+ check,
+ "%D");
+
return true;
}