This also removes the TODO about using `absl::StrJoin` to dump the environment because we can't easily get a range from a null-terminated `envp`. It also doesn't suffer from the usual awkwardness around inserting a separator *between* elements but not after the last one, so a for loop is clear enough.
It's not much cleaner due to arithmetic to convert truncating division to a ceiling, but has two advantages:
1. It doesn't suffer from rounding issues with large TRAP labels. This is largely theoretical, but does let us handle `undefined` uniformly.
2. It should be much faster (using LZCNT/BSR instead of floating point arithmetic). This is probably not a performance bottleneck, so *shrug*.
It turns out mangled names can sometimes be too long. While this code
will eventually be replaced by our own mangling, we need to use hashing
to cut down the names.
Module and decl names are preserved in the trap file names for
debuggability.
In case the extractor is run in isolation for debugging/testing, this
will avoid littering the current working directory with artifacts, and
instead having a single `extractor-out` directory to inspect or clean
up.
Also extractor logs have been nested into a `swift` directory, as the
log directory provided by the `codeql` cli is actually shared between
languages.
Assertions before fetching a non optional label are not needed as
the dispatcher will replace those with unspecified elements (and
properly log those instances).
WMO stands for whole module optimization. It's a compilation mode where
all sources of a module are compiled together, e.g.
```
swift-frontend -emit-module A.swift B.swift -o Module.swiftmodule
```
This is opposed to incremental mode, where one would do something like
```
swift-frontend -emit-module -primary-file A.swift B.swift -module-name Module -o Module~A.swiftmodule
swift-frontend -emit-module A.swift -primary-file B.swift -module-name Module -o Module~B.swiftmodule
swift-frontend -merge-modules Module~A.swiftmodule Module~B.swiftmodule -o Module.swiftmodule
```
In WMO mode we were skipping extraction of all files after the first
one, because we were filtering in only files with an associated output,
and internally swift only assigns the output to the first input file in
WMO mode (which is just an implementation detail).
This patch refines that filter, by getting all input source files in
case there are no primary inputs.
This is done by adding a `isSuccessfullyExtracted` predicate that is
filled for primary files at the very end of the extractor invocation if
the frontend was performed successfully. If for example the extractor
crashes this will therefore not be filled.
The upgrade script is written so that `SuccessfullyExtractedFiles.ql`
on an upgraded script will give exactly the same results as before it.
As discussed [in this accepted proposal][1], parameter labels do not
take part any more in making up a function type, so we need to not
extract them any more to avoid DB inconsistencies.
These were unused in the library, which makes the upgrade and downgrade
scripts have full compatibility.
[1]: 9c53790a13/proposals/0111-remove-arg-label-type-significance.md