X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Ftypes%2Fdecl.c;h=2d974808b7bd8ee3d7cf735632ba22ad8f878876;hb=ad2c22df5e451fffecc7b7ebdc9c5a4bb36e543e;hp=df04656a8d41bab720b53a362ed018aa12701f94;hpb=c5b2de8ed1d92dd42f910d4347d9175f27e3acbb;p=m6w6%2Fext-psi diff --git a/src/types/decl.c b/src/types/decl.c index df04656..2d97480 100644 --- a/src/types/decl.c +++ b/src/types/decl.c @@ -25,7 +25,11 @@ #include "php_psi_stdinc.h" +#include "php_psi.h" + #include +#include + #include "data.h" #define PSI_FUNC_REDIRS @@ -85,9 +89,8 @@ static inline bool psi_decl_validate_func(struct psi_data *data, { struct psi_func_redir *redir; - if (!strcmp(func->var->name, "dlsym")) { - data->error(data, func->token, PSI_WARNING, - "Cannot dlsym dlsym (sic!)"); + if (!func->var->name) { + data->error(data, func->token, PSI_WARNING, "Cannot load anonymous decl"); return false; } @@ -114,9 +117,10 @@ static inline bool psi_decl_validate_func(struct psi_data *data, return true; } -bool psi_decl_validate(struct psi_data *data, struct psi_decl *decl, void *dl) +bool psi_decl_validate(struct psi_data *data, struct psi_decl *decl, void *dl, + struct psi_validate_stack *type_stack) { - if (!psi_decl_validate_nodl(data, decl)) { + if (!psi_decl_validate_nodl(data, decl, type_stack)) { return false; } if (!psi_decl_validate_func(data, decl, decl->func, dl)) { @@ -126,7 +130,8 @@ bool psi_decl_validate(struct psi_data *data, struct psi_decl *decl, void *dl) return true; } -bool psi_decl_validate_nodl(struct psi_data *data, struct psi_decl *decl) +bool psi_decl_validate_nodl(struct psi_data *data, struct psi_decl *decl, + struct psi_validate_stack *type_stack) { if (!decl->abi) { decl->abi = psi_decl_abi_init("default"); @@ -135,7 +140,7 @@ bool psi_decl_validate_nodl(struct psi_data *data, struct psi_decl *decl) "Invalid calling convention: '%s'", decl->abi->token->text); return false; } - if (!psi_decl_arg_validate(data, decl->func)) { + if (!psi_decl_arg_validate(data, decl->func, type_stack)) { return false; } if (decl->args) { @@ -143,7 +148,12 @@ bool psi_decl_validate_nodl(struct psi_data *data, struct psi_decl *decl) struct psi_decl_arg *arg; while (psi_plist_get(decl->args, i++, &arg)) { - if (!psi_decl_arg_validate(data, arg)) { + if (!arg->var->name) { + arg->var->name = malloc(7); + snprintf(arg->var->name, 6, "arg%zu", i); + arg->var->fqn = strdup(arg->var->name); + } + if (!psi_decl_arg_validate(data, arg, type_stack)) { return false; } } @@ -151,3 +161,17 @@ bool psi_decl_validate_nodl(struct psi_data *data, struct psi_decl *decl) return true; } + +bool psi_decl_is_blacklisted(const char *name) +{ + char *blacklisted; + size_t i = 0; + + while (psi_plist_get(PSI_G(blacklist).decls, i++, &blacklisted)) { + if (!fnmatch(blacklisted, name, 0)) { + return true; + } + } + return false; +} +