Skip to content

Commit 2d3e3aa

Browse files
committed
Add C++ query to extract the number of errors due to include file resolution failure
1 parent 975881c commit 2d3e3aa

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* @name Count of includes that failed to be resolved as well as compilation error due to undefined token
3+
* @description A count of all failed includes and compilation errors due to undefined tokens.
4+
* @kind table
5+
* @tags summary telemetry include resolution
6+
* @id cpp/telemetry/incliude-resolution-status
7+
*/
8+
9+
import cpp
10+
/**
11+
* A cannot open file error.
12+
* Typically this is due to a missing include.
13+
*/
14+
class CannotOpenFileError extends CompilerError {
15+
CannotOpenFileError() { this.hasTag(["cannot_open_file", "cannot_open_file_reason"]) }
16+
}
17+
18+
/**
19+
* A compiler error happening in a project file.
20+
*/
21+
predicate local_compiler_error(CompilerError e) { exists (e.getFile().getRelativePath()) }
22+
23+
24+
/**
25+
* A compiler error happening in a project file, where the error is due to a token being undefined.
26+
*/
27+
predicate undefined_token_error(CompilerError e) {
28+
// The following is a non-exaustive list of tags that indicate that a token
29+
// is undefined.
30+
e.hasTag("not_a_member") or
31+
e.hasTag("undefined_identifier") or
32+
e.hasTag("no_matching_function") or
33+
e.hasTag("too_many_arguments") or
34+
e.hasTag("not_a_class_or_struct_name") or
35+
e.hasTag("not_a_class_template")
36+
}
37+
38+
select
39+
count(CannotOpenFileError e) as failed_includes,
40+
count() as total_files,
41+
count(Include i) as successful_includes,
42+
count(Include i) + count (CannotOpenFileError e) as total_includes,
43+
count(CompilerError e | local_compiler_error(e) and undefined_token_error(e)) as local_undefined_token_errors,
44+
count(CompilerError e | local_compiler_error(e)) as local_errors

0 commit comments

Comments
 (0)