8000 Rust: Take derive macros into account in `is{In,From}MacroExpansion` · github/codeql@7350196 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7350196

Browse files
committed
Rust: Take derive macros into account in is{In,From}MacroExpansion
1 parent 13bc0d2 commit 7350196

File tree

3 files changed

+8
-1099
lines changed

3 files changed

+8
-1099
lines changed

rust/ql/lib/codeql/rust/elements/internal/AstNodeImpl.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ module Impl {
7070
*/
7171
pragma[nomagic]
7272
predicate isFromMacroExpansion() {
73-
exists(MacroCall mc |
74-
MacroCallImpl::isInMacroExpansion(mc, this) and
75-
not this = mc.getATokenTreeNode()
73+
exists(AstNode root |
74+
MacroCallImpl::isInMacroExpansion(root, this) and
75+
not this = root.(MacroCall).getATokenTreeNode()
7676
)
7777
}
7878

rust/ql/lib/codeql/rust/elements/internal/MacroCallImpl.qll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ module Impl {
1414
private import rust
1515

1616
pragma[nomagic]
17-
predicate isInMacroExpansion(MacroCall mc, AstNode n) {
18-
n = mc.getMacroCallExpansion()
17+
predicate isInMacroExpansion(AstNode root, AstNode n) {
18+
n = root.(MacroCall).getMacroCallExpansion()
1919
or
20-
isInMacroExpansion(mc, n.getParentNode())
20+
n = root.(Adt).getDeriveMacroExpansion(_)
21+
or
22+
isInMacroExpansion(root, n.getParentNode())
2123
}
2224

2325
// the following QLdoc is generated: if you need to edit it, do it in the schema file

0 commit comments

Comments
 (0)
0