Skip to content

Commit 480ce39

Browse files
committed
C#: Exclude jump-to-def information for elements with too many locations
In databases which include multiple duplicated files, we can get an explosion of definition locations that can cause this query to produce too many results for the CodeQL toolchain. This commit restricts the definitions.ql query to producing definition/uses for definitions with fewer than 10 locations. This replicates the logic used in the C++ definitions.qll library which faces similar problems.
1 parent 34e2562 commit 480ce39

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

csharp/ql/src/definitions.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,11 @@ cached
187187
Declaration definitionOf(Use use, string kind) {
188188
result = use.getDefinition() and
189189
result.fromSource() and
190-
kind = use.getUseType()
190+
kind = use.getUseType() and
191+
// Some entities have many locations. This can arise for files that
192+
// are duplicated multiple times in the database at different
193+
// locations. Rather than letting the result set explode, we just
194+
// exclude results that are "too ambiguous" -- we could also arbitrarily
195+
// pick one location later on.
196+
strictcount(result.getLocation()) < 10
191197
}

0 commit comments

Comments
 (0)