Commit Graph

33 Commits

Author SHA1 Message Date
Henrik G. Olsson 71f3acdbde Merge pull request #87725 from hnrklssn/uvt-ignore-unrelated
[UVT] support -verify-ignore-unrelated
2026-03-07 16:42:05 -08:00
Henrik G. Olsson d22fafd164 [UVT] support -verify-ignore-unrelated
swift-frontend -verify -verify-ignore-unrelated does not expect matchers
for files in unchecked files, but it still emits diagnostic output like
this:
```
/path/to/sdk/file.h:19:29: remark: diagnostic produced elsewhere: did not add safe interop wrapper
struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};
```

update-verify-tests errors on unexpected input to ensure nothing is
accidentally missed. This adds the pattern above to the set of expected
inputs.
2026-03-07 11:46:46 -08:00
Henrik G. Olsson 74ec8386a5 Merge pull request #87685 from hnrklssn/unrelated-expansions
[UVT] support expansions with unrelated prefix in same file
2026-03-06 11:21:46 -08:00
Henrik G. Olsson 34e721c7ac [UVT] support expansions with unrelated prefix in same file
This parses existing expected diagnostics in the source file even if
they have a mismatching prefix. This lets the script know that the }}
closing an unrelated expected-expansion block is not due to a mistake in
parsing. Unrelated diagnostics are otherwise left as they are.
2026-03-04 13:39:33 -08:00
Henrik G. Olsson b0df0c70c5 [utils] don't call unavailable functions 2026-02-28 11:38:24 -08:00
Henrik G. Olsson 9a64df890a [utils] remove open from free functions 2026-02-28 11:30:03 -08:00
Henrik G. Olsson 189e1f49c3 [utils] print #if statements
This prevents decls from the two branches from clashing.
2026-02-28 11:22:40 -08:00
Henrik G. Olsson b9d74ce1a8 [utils] make functions public and compile with lifetime support
The functions never ended up in the module interface because they
weren't public. Fixing this revealed that the swift-frontend -verify
invocation didn't enable lifetimes. It also revealed that
swift-function-caller-generator emits both an @lifetime and an
@_lifetime version for functions annotated with @_lifetime. This will be
fixed in the next commit.
2026-02-28 11:20:46 -08:00
Henrik G. Olsson af86e04bd7 [utils] diff output file
compile.swift turned out to be broken and passing by compiling an almost
empty file. This will make the changes in the next following commits
easier to follow along.
2026-02-28 11:17:42 -08:00
Henrik G. Olsson 8220e2b88a Merge pull request #87559 from hnrklssn/method-caller-generator
[utils] support methods in swift-function-caller-generator
2026-02-28 00:35:47 -08:00
Henrik G. Olsson 75876bfb43 fix whitespace 2026-02-27 14:49:21 -08:00
Henrik G. Olsson 5d4bf01974 Merge pull request #87528 from hnrklssn/lit-generated-by
[utils] add `GENERATED-BY:` to lit
2026-02-27 13:35:41 -08:00
Henrik G. Olsson 17da8285e3 [utils] move unsafe keyword before self for method call 2026-02-26 20:34:34 -08:00
Henrik G. Olsson c4af98cd5e [utils] don't add trailing comma after self if only param 2026-02-26 20:34:34 -08:00
Henrik G. Olsson f25d7aa525 [utils] remove mutating from signature when generating call to method
Free functions can't be `mutating` because there is not `self`.
2026-02-26 20:34:32 -08:00
Henrik G. Olsson e68829e055 [utils] don't copy comments when generating callers 2026-02-25 22:45:17 -08:00
Henrik G. Olsson 1fa1af4410 [utils] save hash of GENERATED-BY output
By hashing the output, the test updater won't trigger for failures
unrelated to the test file being outdated. That is, if the generated
test output hasn't changed, then regenerating the test surely won't fix
it. This serves two purposes:
 - it allows someone to make edits to the output (e.g. add comments) and
   not have them overwritten all the time
 - only one test updater is allowed to make updates each test failure,
   so if the generated file hasn't changed, it shouldn't prevent other
   test updaters from executing
2026-02-25 20:25:10 -08:00
Henrik G. Olsson 2eb5c22b39 [utils] add GENERATED-BY: automatic test file generation
This adds an automatic test updater that checks for GENERATED-BY:
comments containing a command whose stdout is used to populate a file,
or a split-file slice in a file.

The test updater applies the same lit substitutions as would be applied
in a RUN: line, allowing Swift tool usage in the run line.
2026-02-25 19:47:48 -08:00
Henrik G. Olsson 3373903794 match windows file separator 2025-12-17 12:58:41 -08:00
Henrik G. Olsson 357c298940 [utils] escape backslashes in diagnostics strings
DiagnosticVerifier lexes the contents of expected diagnostics the same
way Swift parses string literals, to allow for escape codes. This makes
for problems when backslashes are followed by something that makes for a
valid escape. In particular, it reaches an llvm_unreachable if it
encounters `\(`, which would create a string interpolation in a string
literal.
2025-12-16 15:01:27 -08:00
Henrik G. Olsson 9c989971af [utils] fix off-by-one line number bug
When folding up lines of nested expansions, the line number would be off
by 1, which would lead to lines being shuffled around.
2025-12-16 15:01:27 -08:00
Henrik G. Olsson b99945fdb3 [utils] handle diagnostics from unparsed files
Don't try to add expected lines in files that aren't parsed for them -
it will just lead to duplicated expected lines if run over and over.
Because we don't know whether the right choice is to add
-verify-additional-file or -verify-ignore-unrelated, we do nothing.
2025-12-16 15:01:27 -08:00
Henrik G. Olsson 5db7926e09 [utils] add support for expected-remarks to update-verify-tests.py 2025-11-11 16:35:00 -08:00
Henrik G. Olsson c246140d7f [utils] remove trailing whitespace after removing diag 2025-11-11 16:34:59 -08:00
Henrik G. Olsson 4d5844b723 [utils] only steal 1 diagnostic
This fixes a bug in the diagnostic stealing logic when multiple
diagnostics target the same line, which would trigger an assert.
2025-11-11 16:34:59 -08:00
Henrik G. Olsson 4af20b25d5 [utils] fix bug in diagnostic stealing logic
When replacing expected diagnostic content, we should consider
expected diagnostics targeting the same target, not targeting the line
the expected diagnostic is on.
2025-11-11 16:34:55 -08:00
Henrik G. Olsson 32fd1c0dda Merge pull request #85390 from hnrklssn/update-verify-tests-continuted
[utils] add support for expected-expansion to update-verify-tests
2025-11-11 23:24:55 +00:00
Henrik G. Olsson 3891080750 [utils] add support for expected-expansion to update-verify-tests
`expected-expansion` can be a bit unergonomic to use, because it requires
pointing out not only the line, but also the column (which is not always
obvious), and the nested diagnostics have to refer to absolute lines
that aren't present in the source file. This makes both creating and
updating these test cases easier through automation.
2025-11-07 13:34:39 -08:00
Henrik G. Olsson 88d19e59d9 [utils] mark update-verify-tests tests unsupported with old Python
This utility uses the walrus operator introduced in Python 3.8, but this
causes tests to fail in Amazon Linux 2 CI, which uses Python 3.7. Since
this is not a shipped product, that doesn't really matter, and 3.7 is an
ancient EOL version anyways. The premerge CI uses Python 3.9 and later,
so use that as a basis, just to avoid the same issue in the future in
case some Python 3.9 feature sneaks in.

rdar://164151931
2025-11-07 12:41:00 -08:00
Henrik G. Olsson 8bff12a580 [utils] port update-verify-tests to Swift's -verify
This ports clang's test suite for update-verify-tests from C to Swift,
and adjusts update-verify-tests as needed. The main differences are the
Swift -verify output format being quite different, as well as Swift's
'-verify-additional-prefix foo' working differently than clang's
'-verify=foo'.
2025-11-05 16:02:06 -08:00
Henrik G. Olsson b624318e4c add REQUIRES swift features 2025-10-17 15:13:59 -07:00
Henrik G. Olsson 7960cf80cf [Utils] test swift-function-caller-generator w/ strict safety 2025-10-17 15:13:58 -07:00
Henrik G. Olsson 99c8fc33fd [Utils] add test cases for swift-function-caller-generator 2025-10-17 15:13:58 -07:00