#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include <unordered_map>
+#include <unordered_set>
#include <vector>
#include <sstream>
#include <ctype.h>
class PrintfCheckVisitor::impl {
std::unordered_map<std::string, unsigned int> printf_functions;
+ std::unordered_set<char> format_specs;
ASTContext *pcontext;
CompilerInstance *ci;
}
break;
case read_arg:
- if (!isalpha (c)) {
+ auto found = format_specs.find (c);
+ if (found != format_specs.end () || !isalpha (c)) {
+
+ if (isalpha (c)) {
+ flags.push_back (c);
+ }
+
auto handler = parseFlags (flags, e);
if (handler) {
{"rspamd_snprintf", 2},
{"rspamd_fprintf", 1}
};
+
+ format_specs = {
+ 's', 'd', 'l', 'L', 'v', 'V', 'f', 'F', 'g', 'G',
+ 'T', 'z', 'D', 'c', 'p', 'P', 'e'
+ };
};
bool VisitCallExpr (CallExpr *E)