-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15381 from geoffw0/cppfiles
C++: Report any extracted file as successfully extracted
- Loading branch information
Showing
17 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
9 changes: 3 additions & 6 deletions
9
...Diagnostics/SuccessfullyExtractedFiles.ql → cpp/ql/src/Diagnostics/ExtractedFiles.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
/** | ||
* @name Successfully extracted files | ||
* @description Lists all files in the source code directory that were extracted without encountering a problem in the file. | ||
* @name Extracted files | ||
* @description Lists all files in the source code directory that were extracted. | ||
* @kind diagnostic | ||
* @id cpp/diagnostics/successfully-extracted-files | ||
* @tags successfully-extracted-files | ||
*/ | ||
|
||
import cpp | ||
import ExtractionProblems | ||
|
||
from File f | ||
where | ||
not exists(ExtractionProblem e | e.getFile() = f) and | ||
exists(f.getRelativePath()) | ||
where exists(f.getRelativePath()) and f.fromSource() | ||
select f, "File successfully extracted." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* The diagnostic query `cpp/diagnostics/successfully-extracted-files` now considers any C/C++ file seen during extraction, even one with some errors, to be extracted / scanned. This affects the Code Scanning UI measure of scanned C/C++ files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
| containserror.cpp:0:0:0:0 | containserror.cpp | File successfully extracted. | | ||
| containswarning.cpp:0:0:0:0 | containswarning.cpp | File successfully extracted. | | ||
| doesnotcompile.cpp:0:0:0:0 | doesnotcompile.cpp | File successfully extracted. | | ||
| header.h:0:0:0:0 | header.h | File successfully extracted. | | ||
| successful.cpp:0:0:0:0 | successful.cpp | File successfully extracted. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Diagnostics/ExtractedFiles.ql |
2 changes: 2 additions & 0 deletions
2
cpp/ql/test/query-tests/Diagnostics/ExtractionErrors.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| doesnotcompile.cpp:4:2:4:2 | Recoverable extraction error: identifier 'This' is undefined | Extraction failed in doesnotcompile.cpp with error "doesnotcompile.cpp", line 4: error: identifier "This" is undefined\n \tThis is not correct C/C++ code.\n \t^\n\n | 2 | | ||
| doesnotcompile.cpp:4:10:4:10 | Recoverable extraction error: expected a ';' | Extraction failed in doesnotcompile.cpp with error "doesnotcompile.cpp", line 4: error: expected a ";"\n \tThis is not correct C/C++ code.\n \t ^\n\n | 2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Diagnostics/Internal/ExtractionErrors.ql |
2 changes: 2 additions & 0 deletions
2
cpp/ql/test/query-tests/Diagnostics/ExtractionWarnings.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| doesnotcompile.cpp:4:2:4:2 | Recoverable extraction error: identifier 'This' is undefined | Extraction failed in doesnotcompile.cpp with warning "doesnotcompile.cpp", line 4: error: identifier "This" is undefined\n \tThis is not correct C/C++ code.\n \t^\n\n | 1 | | ||
| doesnotcompile.cpp:4:10:4:10 | Recoverable extraction error: expected a ';' | Extraction failed in doesnotcompile.cpp with warning "doesnotcompile.cpp", line 4: error: expected a ";"\n \tThis is not correct C/C++ code.\n \t ^\n\n | 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Diagnostics/ExtractionWarnings.ql |
Empty file.
1 change: 1 addition & 0 deletions
1
cpp/ql/test/query-tests/Diagnostics/FailedExtractorInvocations.qlref
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Diagnostics/FailedExtractorInvocations.ql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
| containserror.cpp:0:0:0:0 | containserror.cpp | query-tests/Diagnostics/containserror.cpp | fromSource, normalTermination | | ||
| containswarning.cpp:0:0:0:0 | containswarning.cpp | query-tests/Diagnostics/containswarning.cpp | fromSource, normalTermination | | ||
| doesnotcompile.cpp:0:0:0:0 | doesnotcompile.cpp | query-tests/Diagnostics/doesnotcompile.cpp | ExtractionProblem (severity 1), fromSource, normalTermination | | ||
| file://:0:0:0:0 | | | | | ||
| header.h:0:0:0:0 | header.h | query-tests/Diagnostics/header.h | fromSource | | ||
| successful.cpp:0:0:0:0 | successful.cpp | query-tests/Diagnostics/successful.cpp | fromSource, normalTermination | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import cpp | ||
import Diagnostics.ExtractionProblems | ||
|
||
string describe(File f) { | ||
exists(ExtractionProblem e | e.getFile() = f | | ||
result = "ExtractionProblem (severity " + e.getSeverity().toString() + ")" | ||
) | ||
or | ||
f.fromSource() and result = "fromSource" | ||
or | ||
exists(Compilation c | c.getAFileCompiled() = f | | ||
(c.normalTermination() and result = "normalTermination") | ||
) | ||
} | ||
|
||
from File f | ||
select f, concat(f.getRelativePath(), ", "), concat(describe(f), ", ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// semmle-extractor-options: --expect_errors | ||
|
||
void containserror() { | ||
#error An error! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
void containswarning() { | ||
#warning A warning. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// semmle-extractor-options: --expect_errors | ||
|
||
void doesnotcompile() { | ||
This is not correct C/C++ code. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
// a header file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#include "header.h" | ||
|
||
void successful() { | ||
} |