mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: adapt BadCtorInitialization.ql to attribute macro expansion
This commit is contained in:
@@ -44,9 +44,18 @@ class PathElement = AstNode;
|
||||
* reachable from a source.
|
||||
*/
|
||||
predicate edgesFwd(PathElement pred, PathElement succ) {
|
||||
// attribute (source) -> callable
|
||||
pred.(CtorAttr) = succ.(Callable).getAnAttr()
|
||||
// attribute (source) -> function in macro expansion
|
||||
exists(Function f |
|
||||
pred.(CtorAttr) = f.getAnAttr() and
|
||||
(
|
||||
f.getAttributeMacroExpansion().getAnItem() = succ.(Callable)
|
||||
or
|
||||
// if for some reason the ctor/dtor macro expansion failed, fall back to looking into the unexpanded item
|
||||
not f.hasAttributeMacroExpansion() and f = succ.(Callable)
|
||||
)
|
||||
)
|
||||
or
|
||||
// callable -> callable attribute macro expansion
|
||||
// [forwards reachable] callable -> enclosed call
|
||||
edgesFwd(_, pred) and
|
||||
pred = succ.(CallExprBase).getEnclosingCallable()
|
||||
|
||||
Reference in New Issue
Block a user