mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: Use macro call location as fall back in macro expansions
This commit is contained in:
@@ -46,11 +46,25 @@ module Impl {
|
||||
predicate fromSource() { exists(this.getFile().getRelativePath()) }
|
||||
}
|
||||
|
||||
/** Gets the non-synthesized location of `l`, if any. */
|
||||
LocationImpl::LocationDefault getLocationDefault(Locatable l) {
|
||||
exists(@location_default location |
|
||||
result = LocationImpl::TLocationDefault(location) and
|
||||
locatable_locations(Synth::convertLocatableToRaw(l), location)
|
||||
private @location_default getDbLocation(Locatable l) {
|
||||
locatable_locations(Synth::convertLocatableToRaw(l), result)
|
||||
}
|
||||
|
||||
private MacroCall getImmediatelyEnclosingMacroCall(AstNode n) {
|
||||
result = n.getParentNode()
|
||||
or
|
||||
exists(AstNode mid |
|
||||
result = getImmediatelyEnclosingMacroCall(mid) and
|
||||
n.getParentNode() = mid and
|
||||
not mid instanceof MacroCall
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the non-synthesized location of `l`, if any. */
|
||||
LocationImpl::LocationDefault getLocationDefault(Locatable l) {
|
||||
result = LocationImpl::TLocationDefault(getDbLocation(l))
|
||||
or
|
||||
not exists(getDbLocation(l)) and
|
||||
result = getLocationDefault(getImmediatelyEnclosingMacroCall(l))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,8 @@ query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) >
|
||||
* Holds if `e` does not have a `Location`.
|
||||
*/
|
||||
query predicate noLocation(Locatable e) {
|
||||
not exists(e.getLocation()) and not e.(AstNode).getParentNode*() = any(Crate c).getModule()
|
||||
not exists(e.getLocation()) and
|
||||
not e.(AstNode).getParentNode*() = any(Crate c).getModule()
|
||||
}
|
||||
|
||||
private predicate multiplePrimaryQlClasses(Element e) {
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
noLocation
|
||||
| file://:0:0:0:0 | ... .unwrap() |
|
||||
| file://:0:0:0:0 | ...: ... |
|
||||
| file://:0:0:0:0 | ...::Path |
|
||||
| file://:0:0:0:0 | ...::Path |
|
||||
| file://:0:0:0:0 | ...::path |
|
||||
| file://:0:0:0:0 | ArgList |
|
||||
| file://:0:0:0:0 | ArgList |
|
||||
| file://:0:0:0:0 | ParamList |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | Path |
|
||||
| file://:0:0:0:0 | RefTypeRepr |
|
||||
| file://:0:0:0:0 | RefTypeRepr |
|
||||
| file://:0:0:0:0 | RetTypeRepr |
|
||||
| file://:0:0:0:0 | StmtList |
|
||||
| file://:0:0:0:0 | fn get_parent |
|
||||
| file://:0:0:0:0 | get_parent |
|
||||
| file://:0:0:0:0 | parent |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path |
|
||||
| file://:0:0:0:0 | path.parent() |
|
||||
| file://:0:0:0:0 | std |
|
||||
| file://:0:0:0:0 | std |
|
||||
| file://:0:0:0:0 | std |
|
||||
| file://:0:0:0:0 | unwrap |
|
||||
| file://:0:0:0:0 | use ...::Path |
|
||||
| file://:0:0:0:0 | { ... } |
|
||||
@@ -1,2 +1,2 @@
|
||||
| gen_macro_items.rs:5:5:5:38 | MacroItems | 0 | file://:0:0:0:0 | use ...::Path |
|
||||
| gen_macro_items.rs:5:5:5:38 | MacroItems | 1 | file://:0:0:0:0 | fn get_parent |
|
||||
| gen_macro_items.rs:5:5:5:38 | MacroItems | 0 | gen_macro_items.rs:5:5:5:38 | use ...::Path |
|
||||
| gen_macro_items.rs:5:5:5:38 | MacroItems | 1 | gen_macro_items.rs:5:5:5:38 | fn get_parent |
|
||||
|
||||
Reference in New Issue
Block a user