Skip to content

Commit

Permalink
Detect Asio\join calls while scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Apr 25, 2024
1 parent 1802209 commit 7fc6f61
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/code_info/functionlike_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ pub struct FunctionLikeInfo {

pub is_async: bool,

pub has_asio_join: bool,

pub must_use: bool,

pub mutation_free: bool,
Expand Down Expand Up @@ -179,6 +181,7 @@ impl FunctionLikeInfo {
attributes: Vec::new(),
method_info: None,
is_async: false,
has_asio_join: false,
must_use: false,
ignore_taint_path: false,
dynamically_callable: false,
Expand Down
20 changes: 20 additions & 0 deletions src/code_info_builder/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct Context {
function_name: Option<StrId>,
member_name: Option<StrId>,
has_yield: bool,
has_asio_join: bool,
has_static_field_access: bool,
uses_position: Option<(usize, usize)>,
namespace_position: Option<(usize, usize)>,
Expand Down Expand Up @@ -478,6 +479,15 @@ impl<'ast> Visitor<'ast> for Scanner<'_> {
c.has_yield = false;
}

if c.has_asio_join {
self.codebase
.functionlike_infos
.get_mut(&(*c.classlike_name.as_ref().unwrap(), method_name))
.unwrap()
.has_asio_join = true;
c.has_asio_join = false;
}

if !c.has_static_field_access && m.static_ {
self.codebase
.functionlike_infos
Expand Down Expand Up @@ -566,6 +576,15 @@ impl<'ast> Visitor<'ast> for Scanner<'_> {
c.has_static_field_access = true;
}
}
aast::Expr_::Call(boxed) => {
if let aast::Expr_::Id(boxed_id) = &boxed.func.2 {
if let Some(&StrId::ASIO_JOIN) =
self.resolved_names.get(&(boxed_id.0.start_offset() as u32))
{
c.has_asio_join = true;
}
}
}
_ => (),
}

Expand Down Expand Up @@ -838,6 +857,7 @@ pub fn collect_info_for_aast(
function_name: None,
member_name: None,
has_yield: false,
has_asio_join: false,
has_static_field_access: false,
uses_position: None,
namespace_position: None,
Expand Down

0 comments on commit 7fc6f61

Please sign in to comment.