Kotlin: Improve error handling

Each compilation, and each file within a cmopilation, now gets a
"result" indicating whether it had recoverable or non-recoverable
errors.
This commit is contained in:
Ian Lynagh
2022-01-25 15:42:04 +00:00
parent 4c68b583de
commit 89eae2407b
4 changed files with 116 additions and 12 deletions

View File

@@ -75,6 +75,24 @@ compilation_compiling_files(
int file : @file ref
);
/**
* For each file recorded in `compilation_compiling_files`,
* there will be a corresponding row in
* `compilation_compiling_files_completed` once extraction
* of that file is complete. The `result` will indicate the
* extraction result:
*
* 0: Successfully extracted
* 1: Errors were encountered, but extraction recovered
* 2: Errors were encountered, and extraction could not recover
*/
#keyset[id, num]
compilation_compiling_files_completed(
int id : @compilation ref,
int num : int ref,
int result : int ref
);
/**
* The time taken by the extractor for a compiler invocation.
*
@@ -131,11 +149,17 @@ compilation_compiler_times(
* If extraction was successful, then `cpu_seconds` and
* `elapsed_seconds` are the CPU time and elapsed time (respectively)
* that extraction took for compiler invocation `id`.
* The `result` will indicate the extraction result:
*
* 0: Successfully extracted
* 1: Errors were encountered, but extraction recovered
* 2: Errors were encountered, and extraction could not recover
*/
compilation_finished(
unique int id : @compilation ref,
float cpu_seconds : float ref,
float elapsed_seconds : float ref
float elapsed_seconds : float ref,
int result : int ref
);
diagnostics(

View File

@@ -33,9 +33,18 @@ class Compilation extends @compilation {
/** Gets a file compiled during this invocation. */
File getAFileCompiled() { result = getFileCompiled(_) }
/** Gets the `i`th file compiled during this invocation */
/** Gets the `i`th file compiled during this invocation. */
File getFileCompiled(int i) { compilation_compiling_files(this, i, result) }
/** Holds if the `i`th file during this invocation was successfully extracted. */
predicate fileCompiledSuccessful(int i) { compilation_compiling_files_completed(this, i, 0) }
/** Holds if the `i`th file during this invocation had recoverable extraction errors. */
predicate fileCompiledRecoverableErrors(int i) { compilation_compiling_files_completed(this, i, 1) }
/** Holds if the `i`th file during this invocation had non-recoverable extraction errors. */
predicate fileCompiledNonRecoverableErrors(int i) { compilation_compiling_files_completed(this, i, 2) }
/**
* Gets the amount of CPU time spent processing file number `i` in the
* front-end.
@@ -86,13 +95,13 @@ class Compilation extends @compilation {
* Gets the total amount of CPU time spent processing all the files in the
* front-end and extractor.
*/
float getTotalCpuSeconds() { compilation_finished(this, result, _) }
float getTotalCpuSeconds() { compilation_finished(this, result, _, _) }
/**
* Gets the total amount of elapsed time while processing all the files in
* the front-end and extractor.
*/
float getTotalElapsedSeconds() { compilation_finished(this, _, result) }
float getTotalElapsedSeconds() { compilation_finished(this, _, result, _) }
/**
* Holds if this is a compilation of Java code.
@@ -114,5 +123,20 @@ class Compilation extends @compilation {
* code indicating that an error occurred is considered normal
* termination, but crashing due to something like a segfault is not.
*/
predicate normalTermination() { compilation_finished(this, _, _) }
predicate normalTermination() { compilation_finished(this, _, _, _) }
/**
* Holds if the extractor succeeded without error.
*/
predicate extractionSuccessful() { compilation_finished(this, _, _, 0) }
/**
* Holds if the extractor encountered recoverable errors.
*/
predicate recoverableErrors() { compilation_finished(this, _, _, 1) }
/**
* Holds if the extractor encountered non-recoverable errors.
*/
predicate nonRecoverableErrors() { compilation_finished(this, _, _, 2) }
}