mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
This adds the possibility to add a special `proc_macro.rs` source file to QL tests, which will be generated into a `proc_macro` crate the usual `lib` crate depends on. This allow to define procedural macros in QL tests, and is here used to move the `macro-expansion` integration test to be a language test instead. As the generated manifests involved were starting to get a bit complex, they are now generated from a `mustache` template.
19 lines
564 B
Plaintext
19 lines
564 B
Plaintext
import rust
|
|
import codeql.rust.Diagnostics
|
|
|
|
query predicate attribute_macros(Item i, int index, Item expanded) {
|
|
i.fromSource() and expanded = i.getAttributeMacroExpansion().getItem(index)
|
|
}
|
|
|
|
query predicate macro_calls(MacroCall c, AstNode expansion) {
|
|
c.fromSource() and
|
|
not c.getLocation().getFile().getAbsolutePath().matches("%proc_macro.rs") and
|
|
expansion = c.getMacroCallExpansion()
|
|
}
|
|
|
|
query predicate unexpanded_macro_calls(MacroCall c) {
|
|
c.fromSource() and not c.hasMacroCallExpansion()
|
|
}
|
|
|
|
query predicate warnings(ExtractionWarning w) { any() }
|