11import cpp
22
3+ /*
4+ * A note about how the C/C++ extractor emits diagnostics:
5+ * When the extractor frontend encounters an error, it emits a diagnostic message,
6+ * that includes a message, location and severity.
7+ * However, that process is best-effort and may fail (e.g. due to lack of memory).
8+ * Thus, if the extractor emitted at least one diagnostic of severity discretionary
9+ * error (or higher), it *also* emits a simple "There was an error during this compilation"
10+ * error diagnostic, without location information.
11+ * In the common case, this means that a file with one (or more) errors also gets
12+ * the catch-all diagnostic.
13+ * This diagnostic has the empty string as file path.
14+ * We filter out these useless diagnostics if there is at least one error-level diagnostic
15+ * for the affected compilation in the database.
16+ * Otherwise, we show it to, to indicate that something went wrong, and we
17+ * don't know what exactly happened.
18+ */
19+
320/**
4- * The class of errors upon we mark a file as non-successfully extracted.
21+ * An error that, if present, leads to a file being marked as non-successfully extracted.
522 */
623class ReportableError extends Diagnostic {
724 ReportableError ( ) {
@@ -10,13 +27,7 @@ class ReportableError extends Diagnostic {
1027 this instanceof CompilerError or
1128 this instanceof CompilerCatastrophe
1229 ) and
13- // If the extractor encounters an error in a compilation, it always emits a
14- // catch-all diagnostic "There was an error during this compilation", to ensure
15- // that the error makes it to the database.
16- // This error doesn't have a file path attached to it, and is thus
17- // useless for us to report. Furthermore, in the common case, we will have a
18- // proper diagnostic for this error we can show.
19- // Instead, we synthesize `TUnknownError` if this is the only error that we can show to the user.
30+ // Filter for the catch-all diagnostic, see note above.
2031 not this .getFile ( ) .getAbsolutePath ( ) = ""
2132 }
2233}
@@ -26,8 +37,11 @@ private newtype TExtractionError =
2637 TCompilationFailed ( Compilation c , File f ) {
2738 f = c .getAFileCompiled ( ) and not c .normalTermination ( )
2839 } or
29- // Report generic extractor errors only if we haven't seen any other error-level diagnostic
30- TUnknownError ( CompilerError err ) { not exists ( ReportableError e ) }
40+ // Show the catch-all diagnostic (see note above) only if we haven't seen any other error-level diagnostic
41+ // for that compilation
42+ TUnknownError ( CompilerError err ) {
43+ not exists ( ReportableError e | e .getCompilation ( ) = err .getCompilation ( ) )
44+ }
3145
3246/**
3347 * Superclass for the extraction error hierarchy.
@@ -53,26 +67,26 @@ class ExtractionError extends TExtractionError {
5367}
5468
5569/**
56- * An irrecoverable extraction failure , where extraction was unable to finish.
70+ * An unrecoverable extraction error , where extraction was unable to finish.
5771 * This can be caused by a multitude of reasons, for example:
5872 * - hitting a frontend assertion
5973 * - crashing due to dereferencing an invalid pointer
6074 * - stack overflow
6175 * - out of memory
6276 */
63- class ExtractionIrrecoverableError extends ExtractionError , TCompilationFailed {
77+ class ExtractionUnrecoverableError extends ExtractionError , TCompilationFailed {
6478 Compilation c ;
6579 File f ;
6680
67- ExtractionIrrecoverableError ( ) { this = TCompilationFailed ( c , f ) }
81+ ExtractionUnrecoverableError ( ) { this = TCompilationFailed ( c , f ) }
6882
6983 override string toString ( ) {
70- result = "Irrecoverable extraction error while compiling " + f .toString ( )
84+ result = "Unrecoverable extraction error while compiling " + f .toString ( )
7185 }
7286
7387 override string getErrorMessage ( ) {
7488 result =
75- "Irrecoverable compilation failure, check logs/build-tracer.log in the database directory for more information."
89+ "Unrecoverable compilation failure; check logs/build-tracer.log in the database directory for more information."
7690 }
7791
7892 override File getFile ( ) { result = f }
0 commit comments