Squashed 'third_party/allwpilib/' changes from 83f1860047..f1a82828fe

f1a82828fe [wpiutil] Add DataLog and DataLogManager Stop() (#5860)
2a04e12c6f [apriltag] AprilTagFieldLayout: Add accessors for origin and field dimensions (#5869)
33e0089afb Cleanup usages of std::function<void(void)> (#5864)
d06fa633d5 [build] Fix protobuf generation when building with make (#5867)
049732afb8 [cscore] Make camera connection logging clearer (#5866)
87f7c19f90 [wpimath] Make InterpolatingDoubleTreeMap constructor public (#5865)
6b53ef47cf [wpimath] Don't recreate TrapezoidProfile in ProfiledPIDController calculate() (#5863)
8a3a268ae6 [commands] Add finallyDo with zero-arg lambda (#5862)
1c35d42cd0 [wpilib] Pop diagnostic for deprecated function use (#5859)
ddc8db6c26 [wpimath] Add feedforward constant constructor to ElevatorSim (#5823)
c6aff2c431 [upstream_utils] Update to LLVM 17.0.4 (#5855)
a9c5b18a39 [build] Update OpenCV to 2024-4.8.0-2 (#5854)
9540b6922d [hal] Add CAN IDs for AndyMark and Vivid Hosting (#5852)
83a7d33c47 [glass] Improve display of protobuf/struct type strings (#5850)
a4a8ad9c75 [commands] Make Java SelectCommand generic (#5849)
9eecf2a456 [build] Add CMake option to build Java sources jars (#5768)
9536a311cb [wpilib] Add support for the PS5 DualSense controller (#5257)
8d5e6737fc [wpilibc] SolenoidSim: Add virtual destructor (#5848)
07e13d60a2 [ntcore] Fix write_impl (#5847)
1713386869 [wpiutil] ProtobufMessageDatabase: Fix out-of-order Add() rebuild (#5845)
35472f5fc9 [ntcore] Fix a use-after-free in client close (#5844)
ed168b522c [ntcore] Disable buf pool when asan is enabled (#5843)
3e7ba2cc6f [wpinet] WebSocket: Fix write behavior (#5841)
80c47da237 [sim] Disable the robot program when DS disconnects (#5818)
abe1cec90c [wpilib] Update Usage Reporting ResourceType from NI Libraries (#5842)
cdf981abba [glass] Fix position of data type in NT view (#5840)
04dcd80adb [build] Publish unit tests for examples (#5838)
49920234ac [build] Fix checkstyle rules to allow Windows paths (#5839)
366b715942 [wpilib] Fix SendableChooser test (#5835)
3ba501f947 [commands] Java: Fix CommandXboxController.leftTrigger() parameter order (#5831)
ec569a58ef [wpimath] Make KalmanTypeFilter interface public (#5830)
b91317fd36 [wpiutil] DataLog.addSchema(): Don't add into a set view (#5829)
2ab4fcbc24 [wpiutil] ProtobufMessageDatabase: Clear messages first (#5827)
98c14f1692 [wpimath] Add EKF/UKF u-y-R correct overload (#5832)
60bcdeded9 [ci] Disable java in sanitizer builds (#5833)
c87f8fd538 [commands] Add DeferredCommand (#5566)
ad80eb3a0b [ci] Update actions for comment-command (#5824)
c7d6ad5a0b [ntcore] WebSocketConnection: Use weak capture (#5822)
8a8e220792 [simgui] Add 'Invalid' option for AllianceStation (#5820)
cfc6a47f76 [sim] DS plugin: Fix off-by-one error when setting alliance station (#5819)
8efa586ace [ntcore] Don't check type string on publishing an entry (#5816)
23ea188e60 [glass] Add protobuf decode error log message (#5812)
928e87b4f4 [build] Add combined test meta-task (#5813)
63ef585d4b [wpiutil] Fix compilation of MathExtras.h on Windows with /sdl (#5809)
b03a7668f9 [build] Windows CMake/vcpkg fixes (#5807)
3f08bcde54 [hal] Fix HAL AllianceStation on rio (#5811)
196d963dc4 [ntcore] Fix off-by-one error in stream write (#5810)
f4cbcbc984 Fix typos (NFC) (#5804)
ec0f7fefb0 [myrobot] Update the myRobot JRE (#5805)
3d618bdbfd [wpiutil] Fix Java struct array unpacking (#5801)
1fa7445667 [ntcore] Check for valid client in incoming text and binary (#5799)
269b9647da [ci] Update JDK for combine step (#5794)
bee32f080e [docs] Add wpiunits to JavaDocs (#5793)
25dad5a531 [wpinet] TCPConnector_parallel: Don't use thread_local (#5791)
4a93581f1a [build] cmake: use default library type for libglassnt, libglass, wpigui, and imgui (#5797)
abb2857e03 [wpilib] Counter: Fix default distance per pulse, add distance and rate to C++ (#5796)
b14a61e1c0 [readme] Add link to QuickBuffers release page (#5795)
cf54d9ccb7 [wpiutil, ntcore] Add structured data support (#5391)
ecb7cfa9ef [wpimath] Add Exponential motion profile (#5720)
7c6fe56cf2 [ntcore] Fix crash on disconnect (#5788)
85147bf69e [wpinet] WebSocketSerializer: Fix UB (#5787)
244163acad [wpinet] uv::Stream::TryWrite(): Return 0 on EAGAIN (#5784)
820728503d [hal] Remove extra semicolon in RoboRioData (#5786)
45f307d87e [upstream_utils] Upgrade to LLVM 17.0.3 (#5785)
4ce4d63efc [wpilibj] Fix RobotBase.isSimulation() (#5783)
579007ceb3 [commands] Add requirements parameter to Commands.idle() (#5774)
3f3a169149 [wpilib] Make physics sim setState() functions public (#5779)
7501e4ac88 [wpilib] Close sim device in ADIS IMUs (#5776)
99630d2e78 [wpimath] Upgrade to EJML 0.43.1 (#5778)
02cbbc997d [wpimath] Make Vector-Vector binary operators return Vector (#5772)
ed93889e17 [examples] Fix typo in TimesliceRobot example name (#5773)
da70e4c262 [docs] Add jinja2 to CMake prerequisites (#5771)
e814595ea7 [wpimath] Add ChassisSpeeds.fromRobotRelativeSpeeds() (#5744)
f98c943445 [wpimath] LinearSystemId: Add DCMotorSystem overload (#5770)
b3eb64b0f7 [wpiutil] ct_string: Use inline namespace for literals (#5767)
7d9ba256c2 Revert "[build] Add CMake option to build Java source jars (#5756)" (#5766)
1f6492e3d8 [sysid] Update JSON library usage (#5765)
638f04f626 [wpiutil] Add protobuf to thirdparty sources (#5746)
210255bfff [wpiutil] Update json to 3.11.2 (#5680)
896772c750 [wpimath] Add DCMotor functions for Kraken X60 and Neo Vortex (#5759)
fd427f6c82 [wpimath] Fix hardcoded module count in SwerveDriveKinematics.resetHeading() (#5762)
c0b4c6cce6 [wpimath] Add overloads for Transform2d and Transform3d (#5757)
9a0aafd8ab [examples] Make swerve examples multiply desired module speeds by cosine of heading error (#5758)
1c724884ca [build] Add CMake option to build Java source jars (#5756)
5b0db6b93e [ci] Forward CI as well (#5755)
f8cbbbac12 [ci] Take 2 on passing GITHUB_REF (#5754)
b9944be09c [ci] Pass GITHUB_REF to docker container (#5753)
de5e4eda6c [build] Update apriltag, libssh, googletest for 2024 (#5752)
227e660e20 [upstream_utils] Upgrade to LLVM 17.0.2 (#5750)
36f94c9f21 [commands,romi,xrp] Add frcYear to vendordep (#5747)
741d166457 [glass] NT view: enhance array support (#5732)
1d23513945 [ntcore] Fix string array value comparison (#5745)
ff1849052e [commands] Make command scheduling order consistent (#5470)
58e8474368 [build] Disable armsimulation unit test (#5739)
fb07b0da49 [examples] Add XRP C++ Examples and Templates (#5743)
81893ad73d Run wpiformat with clang-format 17 (#5740)
faa1e665ba [wpimath] Add ElevatorFeedforward.calculate(currentV, nextV) overload (#5715)
a789632052 [build] Update to native utils 2024.3.1 (#5738)
8f60ab5182 [build] Update OpenCV to 2024-4.8.0-1 (#5737)
33243f982b [wpimath] Expand Quaternion class with additional operators (#5600)
420f2f7c80 [ntcore] Add RTT-only subprotocol (#5731)
2b63e35ded [ntcore] Fix moving outgoing queue to new period (#5735)
be939cb636 [ntcore] Fix notification of SetDefaultEntryValue (#5733)
69a54de202 [build] Update enterprise plugin (#5730)
fef03a3ff5 [commands] Clean up C++ includes after Requirements was added (#5719)
8b7c6852cf [ntcore] Networking improvements (#5659)
1d19e09ca9 [wpiutil] Set WPI_{UN}IGNORE_DEPRECATED to empty when all else fails (#5728)
58141d6eb5 [wpilib] Make BooleanEvent more consistent (#5436)
6576d9b474 [wpilib] SendableChooser: implement Sendable instead of NTSendable (#5718)
a4030c670f [build] Update to gradle 8.4, enable win arm builds (#5727)
0960f11eba [wpinet] Revert removal of uv_clock_gettime() (#5723)
cb1bd0a3be [wpiutil] Get more precise system time on Windows (#5722)
4831277ffe [wpigui] Fix loading a maximized window on second monitor (#5721)
3eb372c25a [wpiutil] SendableBuilder: Add PublishConst methods (#5158)
1fec8596a4 [ci] Fix -dirty version (#5716)
f7e47d03f3 [build] Remove unnecessary CMake config installs (#5714)
a331ed2374 [sysid] Add SysId (#5672)
8d2cbfce16 [wpiutil] DataLog: Stop logging if insufficient free space (#5699)
48facb9cef [ntcoreffi] Add DataLogManager (#5702)
aecbcb08fc [ntcore] Correctly start DataLog for existing publishers (#5703)
5e295dfbda [wpiutil] DataLog: Limit total buffer allocation (#5700)
c7c7e05d9d [ci] Unbreak combiner (#5698)
c92bad52cb [wpilib] DataLogManager: Use system time valid function (#5697)
d404af5f24 [wpilib] RobotController: Add isSystemTimeValid() (#5696)
e56f1a3632 [ci] Run combine but skip all steps (#5695)
8f5bcad244 [ci] Use sccache for cmake builds (#5692)
703dedc4a6 [ci] Upgrade get-cmake action to fix node12 deprecation warning (#5694)
c69a0d7504 [ci] Don't run example unit test that segfaults (#5693)
66358d103e Add menu items for online docs to GUI tools (#5689)
4be8384a76 [ci] Disable combine on PR builds (#5691)
90288f06a6 [ci] Fix Gradle disk space issues (#5688)
9e9583412e [wpigui] Make wpi::gui::OpenURL() fork the process first (#5687)
d4fcd80b7b [ci] Gradle: Use container only for build step (#5684)
7b70e66772 [outlineviewer] Fix thirdparty library include sorting (#5683)
5f651df5d5 [build] Clean up Gradle configs (#5685)
65b26738d5 Add CMakeSettings.json to gitignore (#5682)
d0305951ad Fix GitHub inline warnings (#5681)
e8d4a20331 [build][cmake] Fix windows tests and re-enable CI tests (#5674)
2b58bbde0b [xrp] Add Reflectance sensor and rangefinder classes (#5673)
dd5612fbee [json] Add forward definition header (#5676)
eab44534c3 [wpimath] Remove unused SmallString include (#5677)
5ab54ff760 Replace wpi::raw_istream with wpi::MemoryBuffer (#5675)
1b6ec5a95d [wpiutil] Upgrade to LLVM 17.0.1 (#5482)
07a0d22fe6 [build] Build examples in CMake CI (#5667)
97021f074a [build] Upgrade imgui and implot (#5668)
87ce1e3761 [build] Fix wpilibNewCommands CMake install (#5671)
6ef94de9b5 [wpimath] Add tests for ArmFeedforward and ElevatorFeedforward (#5663)
c395b29fb4 [wpinet] Add WebSocket::TrySendFrames() (#5607)
c4643ba047 [romi/xrp] Fix version typo in vendordep json (#5664)
51dcb8b55a [examples] Make Romi/XRP Examples use appropriate vendordeps (#5665)
daf7702007 [build] Test each example in a new environment (#5662)
e67df8c180 [wpilib] Const-qualify EncoderSim getters (#5660)
7be290147c [wpiutil] Refactor SpanMatcher and TestPrinters from ntcore (#5658)
9fe258427a [commands] Add proxy factory to Commands (#5603)
633c5a8a22 [commands] Add C++ Requirements struct (#5504)
b265a68eea [commands] Add interruptor parameter to onCommandInterrupt callbacks (#5461)
e93c233d60 [ntcore] Compute Value memory size when creating value (#5657)
5383589f99 [wpinet] uv::Request: Return shared_ptr from Release() (#5656)
40b552be4a [wpinet] uv::Stream: Return error from TryWrite() (#5655)
202a75fe08 [wpinet] RequestImpl: Avoid infinite loop in shared_from_this() (#5654)
8896515eb7 [wpinet] uv::Buffer: Add bytes() accessor (#5653)
ae59a2fba2 [wpinet] uv::Error: Change default error to 0 (#5652)
3b51ecc35b [wpiutil] SpanExtras: Add take_back and take_front (#5651)
17f1062885 Replace std::snprintf() with wpi::format_to_n_c_str() (#5645)
bb39900353 [romi/xrp] Add Romi and XRP Vendordeps (#5644)
cb99517838 [build] cmake: Use default install location on windows for dlls (#5580)
25b0622d4c [build] Add Windows CMake CI (#5516)
34e7849605 Add warning to development builds instructions (NFC) (#5646)
e9e611c9d8 [cameraserver] Remove CameraServer.SetSize() (#5650)
94f58cc536 [wpilib] Remove Compressor.Enabled() (#5649)
4da5aee88a [wpimath] Remove SlewRateLimiter 2 argument constructor (#5648)
2e3ddf5502 Update versions in development builds instructions to 2024 (#5647)
19a8850fb1 [examples] Add TimesliceRobot templates (#3683)
9047682202 [sim] Add XRP-specific plugin (#5631)
575348b81c [wpilib] Use IsSimulation() consistently (#3534)
12e2043b77 [wpilib] Clean up Notifier (#5630)
4bac4dd0f4 [wpimath] Move PIDController from frc2 to frc namespace (#5640)
494cfd78c1 [wpiutil] Fix deprecation warning in LLVM for C++23 (#5642)
43a727e868 [apriltag] Make loadAprilTagFieldLayout throw an unchecked exception instead (#5629)
ad4b017321 [ci] Use Ninja for faster builds (#5626)
4f2114d6f5 Fix warnings from GCC 13 release build (#5637)
e7e927fe26 [build] Also compress debug info for CMake RelWithDebInfo build type (#5638)
205a40c895 [build] Specify zlib for debug info compression (#5636)
707444f000 [apriltag] Suppress -Wtype-limits warning in asserts from GCC 13 (#5635)
3b79cb6ed3 [commands] Revert SubsystemBase deprecation/removal (#5634)
bc7f23a632 [build] Compress Linux debug info (#5633)
57b2d6f254 [build] Update to image 2024 v1.0 (#5625)
339ef1ea39 [wpilib] DataLogManager: Warn user if logging to RoboRIO 1 internal storage (#5617)
7a9a901a73 [build] Fix cmake config files (#5624)
298f8a6e33 [wpilib] Add Mechanism2d tests and make Java impl match C++ (#5527)
d7ef817bae [apriltag] Update apriltag library (#5619)
c3fb31fd0e [docs] Switch to Java 17 api docs (#5613)
bd64f81cf9 [build] Run Google tests in release mode in CI (#5615)
66e6bd81ea [wpimath] Cleanup wpimath/algorithms.md (NFC) (#5621)
4fa56fd884 [build] Add missing find_dependency call (#5623)
f63d958995 [build] Update to native utils 2024.2.0 (#5601)
a9ab08f48b [wpimath] Rename ChassisSpeeds.fromDiscreteSpeeds() to discretize() (#5616)
8e05983a4a [wpimath] Add math docs to plant inversion feedforward internals (NFC) (#5618)
3a33ce918b [ntcore] Add missing StringMap include (#5620)
a6157f184d [wpiutil] timestamp: Add ShutdownNowRio (#5610)
e9f612f581 [build] Guard policy setting for CMake versions below 3.24 (#5612)
1a6df6fec6 [wpimath] Fix DARE Q decomposition (#5611)
9b3f7fb548 [build] Exclude IntelliJ folders from spotless XML (#5602)
814f18c7f5 [wpimath] Fix computation of C for DARE (A, C) detectability check (#5609)
ac23f92451 [hal] Add GetTeamNumber (#5596)
a750bee54d [wpimath] Use std::norm() in IsStabilizable() (#5599)
8e2465f8a0 [wpimath] Add arithmetic functions to wheel speeds classes (#5465)
10d4f5b5df [wpimath] Clean up notation in DARE precondition docs (#5595)
b2dd59450b [hal] Fix unfinished/incorrect GetCPUTemp functions (#5598)
99f66b1e24 [wpimath] Replace frc/EigenCore.h typedefs with Eigen's where possible (#5597)
383289bc4b [build] Make custom CMake macros use lowercase (#5594)
45e7720ec1 [build] Add error message when downloading files in CMake (#5593)
4e0d785356 [wpimath] ChassisSpeeds: document that values aren't relative to the robot (NFC) (#5551)
3c04580a57 [commands] ProxyCommand: Use inner command name in unique_ptr constructor (#5570)
cf19102c4a [commands] SelectCommand: Fix leakage and multiple composition bug (#5571)
171375f440 [ntcoreffi] Link to NI libraries (#5589)
89add5d05b Disable flaky tests (#5591)
a8d4b162ab [ntcore] Remove RPC manual tests (#5590)
39a73b5b58 [commands] C++: Add CommandPtr supplier constructor to ProxyCommand (#5572)
36d514eae7 [commands] Refactor C++ ScheduleCommand to use SmallSet (#5568)
52297ffe29 [commands] Add idle command (#5555)
67043a8eeb [wpimath] Add angular jerk unit (#5582)
51b0fb1492 [wpimath] Fix incorrect header inclusion in angular_acceleration.h (#5587)
b7657a8e28 [wpimath] Split WPIMathJNI into logical chunks (#5552)
ea17f90f87 [build] Fix tool builds with multiple arm platforms installed (#5586)
f1d7b05723 [wpimath] Clean up unit formatter (#5584)
d7264ff597 Replace wpi::errs() usage with fmtlib (#5560)
ab3bf39e0e [wpiutil] Upgrade to fmt 10.1.1 (#5585)
165ebe4c79 Upgrade to fmt 10.1.0 (#5326)
8e2a7fd306 Include thirdparty libraries with angle brackets (#5578)
e322ab8e46 [wpimath] Fix docs for DARE ABQRN stabilizability check (NFC) (#5579)
360fb835f4 [upstream_utils] Handle edge case in filename matches (#5576)
9d86624c00 [build] Fix CMake configure warnings (#5577)
969979d6c7 [wpiutil] Update to foonathan memory 0.7-3 (#5573)
0d2d989e84 [wpimath] Update to gcem 1.17.0 (#5575)
cf86af7166 [wpiutil] Update to mpack 1.1.1 (#5574)
a0c029a35b [commands] Fix dangling SelectCommand documentation (NFC) (#5567)
349141b91b [upstream_utils] Document adding a patch (NFC) (#5432)
7889b35b67 [wpimath] Add RamseteController comparison to LTV controller docs (NFC) (#5559)
b3ef536677 [build] Ignore nt/sim json files in spotless (#5565)
ed895815b5 [build] Compile Java with UTF-8 encoding (#5564)
2e4ad35e36 [wpiutil] jni_util: Add JSpan and CriticalJSpan (#5554)
8f3d6a1d4b [wpimath] Remove discretizeAQTaylor() (#5562)
7c20fa1b18 [wpimath] Refactor DARE tests to reduce RAM usage at compile time (#5557)
89e738262c [ntcore] Limit buffer pool size to 64KB per connection (#5485)
96f7fa662e Upgrade Maven dependencies (#5553)
7a2d336d52 [wpinet] Leak multicast handles during windows shutdown (#5550)
f9e2757d8f [wpimath] Use JDoubleArrayRef in all JNI functions (#5546)
0cf6e37dc1 [wpimath] Make LTV controller constructors use faster DARE solver (#5543)
6953a303b3 [build] Fix the windows build with fmt (#5544)
7a37e3a496 [wpimath] Correct Rotation3d::RotateBy doc comment (NFC) (#5541)
186b409e16 [wpimath] Remove internal Eigen header include (#5539)
03764dfe93 [wpimath] Add static matrix support to DARE solver (#5536)
394cfeadbd [wpimath] Use SDA algorithm instead of SSCA for DARE solver (#5526)
a4b7fde767 [wpilib] Add mechanism specific SetState overloads to physics sims (#5534)
8121566258 [wpimath] Fix CoordinateSystem.convert() Transform3d overload (#5532)
b542e01a0b [glass] Fix array crash when clearing existing workspace (#5535)
e2e1b763b2 [wpigui] Fix PFD file dialogs not closing after window closing (#5530)
86d7bbc4e4 [examples] Add Java Examples and Templates for the XRP (#5529)
e8b5d44752 [wpimath] Make Java Quaternion use doubles instead of Vector (#5525)
38c198fa64 [myRobot] Add apriltags to myRobot build (#5528)
00450c3548 [wpimath] Upgrade to EJML 0.42 (#5531)
faf3cecd83 [wpimath] Don't copy Matrix and underlying storage in VecBuilder (#5524)
6b896a38dc [build] Don't enforce WITH_FLAT_INSTALL with MSVC (part 2) (#5517)
c01814b80e [wpiutil] Add C API for DataLog (#5509)
b5bd0771eb [wpimath] Document extrinsic vs intrinsic rotations (NFC) (#5508)
84ed8aec05 [build] Don't enforce WITH_FLAT_INSTALL with MSVC (#5515)
999f677d8c [ntcoreffi] Add WPI_Impl_SetupNowRio to exported symbols (#5510)
338f37d302 Fix header sorting of libssh (#5507)
75cbd9d6d0 [glass] Add background color selector to glass plots (#5506)
e2c190487b [examples] Add flywheel bang-bang controller example (#4071)
c52dad609e [wpinet] WebSocket: Send pong in response to ping (#5498)
e2d17a24a6 [hal] Expose power rail disable and cpu temp functionality (#5477)
3ad5d2e42d [hal,wpiutil] Use HMB for FPGA Timestamps (#5499)
b46a872494 [ntcore] Remove pImpl from implementation (#5480)
d8c59ccc71 [wpimath] Add tests for MathUtil clamp() and interpolate() (#5501)
0552c8621d [glass,ov] Improve Glass and OutlineViewer title bar message (#5502)
90e37a129f [wpiutil,wpimath] Add generic InterpolatingTreeMap (#5372)
d83a6edc20 [wpilib] Update GetMatchTime docs and units (#5232)
6db2c42966 [wpimath] Trajectory: Throw on empty lists of States (#5497)
21439b606c [wpimath] Disallow LTV controller max velocities above 15 m/s (#5495)
7496e0d208 [ntcore] Value: More efficiently store arrays (#5484)
0c93aded8a [wpimath] Change kinematics.ToTwist2d(end - start) to kinematics.ToTwist2d(start, end) (#5493)
815a8403e5 [wpimath] Give infeasible trajectory constraints a better exception message (#5492)
35a8b129d9 [wpimath] Add RotateBy() function to pose classes (#5491)
26d6e68c8f [upstream_utils] Add GCEM to CI (#5483)
6aa469ae45 [wpilib] Document how to create LinearSystem object for physics sim classes (NFC) (#5488)
a01b6467d3 [wpimath] Link to docs on LQR and KF tolerances (#5486)
d814f1d123 [wpimath] Fix copy-paste error from Pose2d docs (NFC) (#5490)
98f074b072 [wpimath] Add folder prefix to geometry includes (#5489)
e9858c10e9 [glass] Add tooltips for NT settings (#5476)
12dda24f06 [examples] Fix C robot template not correctly looping (#5474)
fc75d31755 [apriltag] Update apriltaglib (#5475)
a95994fff6 [wpiutil] timestamp: Call FPGA functions directly (#5235)
2ba8fbb6f4 [wpimath] Improve documentation for SwerveModulePosition::operator- (#5468)
b8cdf97621 [build] Prepare for Windows arm64 builds (#5390)
552f4b76b5 [wpimath] Add FOC-enabled Falcon constants to the DCMotor class (#5469)
1938251436 [examples] Add Feedforward to ElevatorProfiledPid (#5300)
873c2a6c10 [examples] Update ElevatorTrapezoidProfile example (#5466)
99b88be4f3 [wpilib] Reduce usage of NTSendable (#5434)
d125711023 [hal] Fix Java REVPH faults bitfield (take 2) (#5464)
c3fab7f1f2 [ntcore] Don't update timestamp when value is unchanged (#5356)
5ec7f18bdc [wpilib] EventLoop docs: Remove BooleanEvent references (NFC) (#5463)
c065ae1fcf [wpiunits] Add subproject for a Java typesafe unit system (#5371)
44acca7c00 [wpiutil] Add ClassPreloader (#5365)
88b11832ec [hal] Fix Java REVPH faults bitfield (#5148)
fb57d82e52 [ntcore] Enhance Java raw value support
3a6e40a44b [wpiutil] Enhance DataLog Java raw value support
8dae5af271 [wpiutil] Add compile-time string utilities (ct_string) (#5462)
fc56f8049a [wpilib] DriverStation: Change alliance station to use optional (#5229)
ef155438bd [build] Consume libuv via cmake config instead of via pkg-config (#5438)
86e91e6724 [wpimath] Refactor TrapezoidProfile API (#5457)
72a4543493 [wpilib] DutyCycleEncoderSim: Expand API (#5443)
657338715d [wpimath] Add ChassisSpeeds method to fix drifting during compound swerve drive maneuvers (#5425)
1af224c21b Add missing <functional> includes (#5459)
0b91ca6d5a [wpilib] SendableChooser: Add onChange listener (#5458)
6f7cdd460e [wpimath] Pose3d: Switch to JNI for exp and log (#5444)
c69e34c80c [wpimath] ChassisSpeeds: Add arithmetic functions (#5293)
335e7dd89d [wpilib] Simulation: Add ctor parameter to set starting state of mechanism sims (#5288)
14f30752ab [wpilib] Deprecate Accelerometer and Gyro interfaces (#5445)
70b60e3a74 [commands] Trigger: Fix method names in requireNonNullParam (#5454)
593767c8c7 [wpimath] Improve Euler angle calculations in gimbal lock (#5437)
daf022d3da [build] Make devImplementation inherit from implementation (#5450)
9b8d90b852 [examples] Convert the unitless joystick inputs to actual physical units (#5451)
1f6428ab63 [ntcore] Fix undefined comparison behavior when array is empty (#5448)
17eb9161cd Update code owners for removal of old commands (#5447)
3c4b58ae1e [wpinet] Upgrade to libuv 1.46.0 (#5446)
aaea85ff16 [commands] Merge CommandBase into Command and SubsystemBase into Subsystem (#5392)
7ac932996a [ci] Use PAT for workflow dispatch (#5442)
efe1987e8b [ci] Trigger pages repo workflow (#5441)
828bc5276f [wpiutil] Upgrade to LLVM 16.0.6 (#5435)
701df9eb87 [ci] Change documentation publish to single-commit (#5440)
e5452e3f69 [wpiutil] Add WPICleaner and an example how to use it (#4850)
7a099cb02a [commands] Remove deprecated classes and functions (#5409)
b250a03944 [wpilib] Add function to wait for DS Connection (#5230)
a6463ed761 [wpiutil] Fix unused variable warning in release build (#5430)
f031513470 [ntcore] NetworkTable::GetSubTables(): Remove duplicates (#5076)
f8e74e2f7c [hal] Unify PWM simulation Speed, Position, and Raw (#5277)
fd5699b240 Remove references to Drake (#5427)
e2d385d80a [build] cmake: Respect USE_SYSTEM_FMTLIB (#5429)
d37f990ce3 [hal] Fix HAL Relay/Main doc module (NFC) (#5422)
a7a8b874ac [docs] Expand HAL_ENUM in doxygen docs (#5421)
3a61deedde [wpimath] Rotation2d: Only use gcem::hypot when constexpr evaluated (#5419)
96145de7db [examples] Fix formatting (NFC) (#5420)
fffe6a7b9a [examples] Improve Pneumatics example coverage in Solenoid and RapidReactCmdBot examples (#4998)
6b5817836d [wpimath] Add tolerance for some tests (#5416)
3233883f3e [cscore] Fix warnings on macos arm (#5415)
c4fc21838f [commands] Add ConditionalCommand getInterruptionBehavior (#5161)
89fc51f0d4 Add tests for SendableChooser and Command Sendable functionality (#5179)
663bf25aaf [docs] Generate docs for symbols in __cplusplus (#5412)
fe32127ea8 [command] Clean up Command doc comments (NFC) (#5321)
c1a01569b4 [wpilib][hal] PWM Raw using microseconds (#5283)
1fca519fb4 [wpiutil] Remove remnants of ghc fs and tcb_span libraries (#5411)
90602cc135 [github] Update issue template to collect more project info (#5090)
34412ac57e [build] Exclude files in bin from Spotless (#5410)
61aa60f0e3 [wpilib] Add robot callback that is called when the DS is initially connected (#5231)
ebae341a91 [commands] Add test for subsystem registration and periodic (#5408)
5d3a133f9f Remove spaces in NOLINT comments (#5407)
3a0e484691 [wpimath] Fix clang-tidy warnings (#5403)
eb3810c765 [wpiutil] Fix clang-tidy warnings (#5406)
c4dc697192 [hal] WS Simulation: Add message filtering capability (#5395)
0eccc3f247 [ntcore] Fix clang-tidy warnings (#5405)
f4dda4bac0 [hal] Add javadocs for JNI (NFC) (#5298)
1c20c69793 [cscore] Fix clang-tidy warnings (#5404)
1501607e48 [commands] Fix clang-tidy warnings (#5402)
991f4b0f62 [wpimath] PIDController: Add IZone (#5315)
f5b0d1484b [wpimath] Add isNear method to MathUtil (#5353)
2ce248f66c [hal] Fix clang-tidy warnings (#5401)
5fc4aee2d2 [wpimath] SwerveDriveKinematics: Rename currentChassisSpeed to desiredChassisSpeed (#5393)
50b90ceb54 [wpimath] SwerveDriveKinematics: Add reset method (#5398)
316cd2a453 [commands] Notify DriverStationSim in CommandTestBaseWithParam (#5400)
d4ea5fa902 [cscore] VideoMode: Add equals override (Java) (#5397)
d6bd72d738 [wpimath] ProfiledPIDController: Add getConstraints (#5399)
25ad5017a9 [wpimath] Refactor kinematics, odometry, and pose estimator (#5355)
5c2addda0f [doc] Add missing pneumatics docs (NFC) (#5389)
c3e04a6ea2 Fix loading tests on macos 12 (#5388)
d5ed9fb859 [wpimath] Create separate archive with just units headers (#5383)
901ab693d4 [wpimath] Use UtilityClassTest for more utility classes (#5384)
9d53231b01 [wpilib] DataLogManager: Add warning for low storage space (#5364)
d466933963 [wpiutil] Group doxygen into MPack module (#5380)
652d1c44e3 [wpiutil] Upgrade to macOS 12 to remove concept shims (#5379)
6414be0e5d [wpimath] Group units doxygen modules (#5382)
7ab5800487 [wpiutil] Fix docs typo in SmallVector (#5381)
59905ea721 Replace WPI_DEPRECATED() macro with [[deprecated]] attribute (#5373)
753cb49a5e [ntcore] Fix doxygen module in generated C types (NFC) (#5374)
1c00a52b67 [hal] Expose CAN timestamp base clock (#5357)
91cbcea841 Replace SFINAE with concepts (#5361)
d57d1a4598 [wpimath] Remove unnecessary template argument from unit formatter (#5367)
5acc5e22aa [wpimath] Only compute eigenvalues with EigenSolvers (#5369)
d3c9316a97 extend shuffleboard test timeout (#5377)
1ea868081a [ci] Fix /format command (#5376)
5fac18ff4a Update formatting to clang-format 16 (#5370)
a94a998002 [wpimath] Generalize Eigen formatter (#5360)
125f6ea101 [wpimath] Make SwerveDriveKinematics::ToChassisSpeeds() take const-ref argument (#5363)
51066a5a8a [wpimath] Move unit formatters into units library (#5358)
282c032b60 [wpilibc] Add unit-aware Joystick.GetDirection() (#5319)
073d19cb69 [build] Fix CMake warning (#5359)
01490fc77b [wpiutil] DataLog: Add documentation for append methods (NFC) (#5348)
c9b612c986 [wpilibcExamples] Make C++ state-space elevator KF and LQR match Java (#5346)
eed1e6e3cb [wpimath] Replace DiscretizeAQTaylor() with DiscretizeAQ() (#5344)
c976f40364 [readme] Document how to run examples in simulation (#5340)
4d28bdc19e [ci] Update Github Pages deploy action parameters (#5343)
e0f851871f [ci] Fix github pages deploy version (#5342)
063c8cbedc Run wpiformat (NFC) (#5341)
96e41c0447 [ci] Update deploy and sshagent actions (#5338)
fd294bdd71 [build] Fix compilation with GCC 13 (#5322)
d223e4040b [dlt] Add delete without download functionality (#5329)
abc19bcb43 [upstream_utils] Zero out commit hashes and show 40 digits in index hashes (#5336)
e909f2e687 [build] Update gradle cache repo name (#5334)
52bd5b972d [wpimath] Rewrite DARE solver (#5328)
3876a2523a [wpimath] Remove unused MatrixImpl() function (#5330)
c82fcb1975 [wpiutil] Add reflection based cleanup helper (#4919)
15ba95df7e [wpiutil] Use std::filesystem (#4941)
77c2124fc5 [wpimath] Remove Eigen's custom STL types (#4945)
27fb47ab10 [glass] Field2D: Embed standard field images (#5159)
102e4f2566 [wpilib] Remove deprecated and broken SPI methods (#5249)
463a90f1df [wpilib, hal] Add function to read the RSL state (#5312)
7a90475eec [wpilib] Update RobotBase documentation (NFC) (#5320)
218cfea16b [wpilib] DutyCycleEncoder: Fix reset behavior (#5287)
91392823ff [build] Update to gradle 8.1 (#5303)
258b7cc48b [wpilibj] Filesystem.getDeployDirectory(): Strip JNI path from user.dir (#5317)
26cc43bee1 [wpilib] Add documentation to SPI mode enum (NFC) (#5324)
ac4da9b1cb [hal] Add HAL docs for Addressable LED (NFC) (#5304)
21d4244cf7 [wpimath] Fix DCMotor docs (NFC) (#5309)
1dff81bea7 [hal] Miscellaneous HAL doc fixes (NFC) (#5306)
7ce75574bf [wpimath] Upgrade to Drake v1.15.0 (#5310)
576bd646ae [hal] Add CANManufacturer for Redux Robotics (#5305)
ee3b4621e5 [commands] Add onlyWhile and onlyIf (#5291)
40ca094686 [commands] Fix RepeatCommand calling end() twice (#5261)
9cbeb841f5 [rtns] Match imaging tool capitalization (#5265)
a63d06ff77 [examples] Add constants to java gearsbot example (#5248)
b6c43322a3 [wpilibc] XboxController: Add return tag to docs (NFC) (#5246)
5162d0001c [hal] Fix and document addressable LED timings (#5272)
90fabe9651 [wpilibj] Use method references in drive class initSendable() (#5251)
24828afd11 [wpimath] Fix desaturateWheelSpeeds to account for negative speeds (#5269)
e099948a77 [wpimath] Clean up rank notation in docs (NFC) (#5274)
fd2d8cb9c1 [hal] Use std::log2() for base-2 logarithm (#5278)
ba8c64bcff [wpimath] Fix misspelled Javadoc parameters in pose estimators (NFC) (#5292)
f53c6813d5 [wpimath] Patch Eigen warnings (#5290)
663703d370 [gitattributes] Mark json files as lf text files (#5256)
aa34aacf6e [wpilib] Shuffleboard: Keep duplicates on SelectTab() (#5198)
63512bbbb8 [wpimath] Fix potential divide-by-zero in RKDP (#5242)
9227b2166e [wpilibj] DriverStation: Fix joystick data logs (#5240)
fbf92e9190 [wpinet] ParallelTcpConnector: don't connect to duplicate addresses (#5169)
2108a61362 [ntcore] NT4 client: close timed-out connections (#5175)
0a66479693 [ntcore] Optimize scan of outgoing messages (#5227)
b510c17ef6 [hal] Fix RobotController.getComments() mishandling quotes inside the comments string (#5197)
e7a7eb2e93 [commands] WaitCommand: Remove subclass doc note (NFC) (#5200)
a465f2d8f0 [examples] Shuffleboard: Correct parameter order (#5204)
a3364422fa LICENSE.md: Bump year to 2023 (#5195)
df3242a40a [wpimath] Fix NaN in C++ MakeCostMatrix() that takes an array (#5194)
00abb8c1e0 [commands] RamseteCommand: default-initialize m_prevSpeeds (#5188)
c886273fd7 [wpilibj] DutyCycleEncoder.setDistancePerRotation(): fix simulation (#5147)
53b5fd2ace [ntcore] Use int64 for datalog type string (#5186)
56b758320f [wpilib] DataLogManager: increase time for datetime to be valid (#5185)
08f298e4cd [wpimath] Fix Pose3d log returning Twist3d NaN for theta between 1E-8 and 1E-7 (#5168)
6d0c5b19db [commands] CommandScheduler.isComposed: Remove incorrect throws clause (NFC) (#5183)
0d22cf5ff7 [wpilib] Fix enableLiveWindowInTest crashing in disabled (#5173)
32ec5b3f75 [wpilib] Add isTestEnabled and minor docs cleanup (#5172)
e5c4c6b1a7 [wpimath] Fix invalid iterator access in TimeInterpolatableBuffer (#5138)
099d048d9e [wpimath] Fix Pose3d log returning Twist3d NaN for theta between 1E-9 and 1E-8 (#5143)
4af84a1c12 Fix Typos (NFC) (#5137)
ce3686b80d [wpimath] Check LTV controller max velocity precondition (#5142)
4b0eecaee0 [commands] Subsystem: Add default command removal method (#5064)
edf4ded412 [wpilib] PH: Revert to 5V rail being fixed 5V (#5122)
4c46b6aff9 [wpilibc] Fix DataLogManager crash on exit in sim (#5125)
490ca4a68a [wpilibc] Fix XboxController::GetBackButton doc (NFC) (#5131)
cbb5b0b802 [hal] Simulation: Fix REV PH solenoids 8+ (#5132)
bb7053d9ee [hal] Fix HAL_GetRuntimeType being slow on the roboRIO (#5130)
9efed9a533 Update .clang-format to c++20 (#5121)
dbbfe1aed2 [wpilib] Use PH voltage to calc Analog pressure switch threshold (#5115)
de65a135c3 [wpilib] DutyCycleEncoderSim: Add channel number constructor (#5118)
3e9788cdff [docs] Strip path from generated NT docs (#5119)
ecb072724d [ntcore] Client::Disconnect(): actually close connection (#5113)
0d462a4561 [glass] NT view: Change string/string array to quoted (#5111)
ba37986561 [ntcore] NetworkClient::Disconnect: Add null check (#5112)
25ab9cda92 [glass,ov] Provide menu item to create topic from root (#5110)
2f6251d4a6 [glass] Set default value when publishing new topic (#5109)
e9a7bed988 [wpimath] Add timestamp getter to MathShared (#5091)
9cc14bbb43 [ntcore] Add stress test to dev executable (#5107)
8068369542 [wpinet] uv: Stop creating handles when closing loop (#5102)
805c837a42 [ntcore] Fix use-after-free in server (#5101)
fd18577ba0 [commands] Improve documentation of addRequirements (NFC) (#5103)
74dea9f05e [wpimath] Fix exception for empty pose buffer in pose estimators (#5106)
9eef79d638 [wpilib] PneumaticHub: Document range of enableCompressorAnalog (NFC) (#5099)
843574a810 [ntcore] Use wpi::Now instead of loop time for transmit time
226ef35212 [wpinet] WebSocket: Reduce server send frame overhead
b30664d630 [ntcore] Reduce initial connection overhead
804e5ce236 [examples] MecanumDrive: Fix axis comment in C++ example (NFC) (#5096)
49af88f2bb [examples] ArmSimulation: Fix flaky test (#5093)
d56314f866 [wpiutil] Disable mock time on the Rio (#5092)
43975ac7cc [examples] ArmSimulation, ElevatorSimulation: Extract mechanism to class (#5052)
5483464158 [examples, templates] Improve descriptions (NFC) (#5051)
785e7dd85c [wpilibc] SendableChooser: static_assert copy- and default-constructibility (#5078)
e57ded8c39 [ntcore] Improve disconnect error reporting (#5085)
01f0394419 [wpinet] Revert WebSocket: When Close() is called, call closed immediately (#5084)
59be120982 [wpimath] Fix Pose3d exp()/log() and add rotation vector constructor to Rotation3d (#5072)
37f065032f [wpilib] Refactor TimedRobot tests (#5068)
22a170bee7 [wpilib] Add Notifier test (#5070)
2f310a748c [wpimath] Fix DCMotor.getSpeed() (#5061)
b43ec87f57 [wpilib] ElevatorSim: Fix WouldHitLimit methods (#5057)
19267bef0c [ntcore] Output warning on property set on unpublished topic (#5059)
84cbd48d84 [ntcore] Handle excludeSelf on SetDefault (#5058)
1f35750865 [cameraserver] Add GetInstance() to all functions (#5054)
8230fc631d [wpilib] Revert throw on nonexistent SimDevice name in SimDeviceSim (#5053)
b879a6f8c6 [wpinet] WebSocket: When Close() is called, call closed immediately (#5047)
49459d3e45 [ntcore] Change wire timeout to fixed 1 second (#5048)
4079eabe9b [wpimath] Discard stale pose estimates (#5045)
fe5d226a19 [glass] Fix option for debug-level NT logging (#5049)
b7535252c2 [ntcore] Don't leak buffers in rare WS shutdown case (#5046)
b61ac6db33 [ntcore] Add client disconnect function (#5022)
7b828ce84f [wpimath] Add nearest to Pose2d and Translation2d (#4882)
08a536291b [examples] Improvements to Elevator Simulation Example (#4937)
193a10d020 [wpigui] Limit frame rate to 120 fps by default (#5030)
7867bbde0e [wpilib] Clarify DS functions provided by FMS (NFC) (#5043)
fa7c01b598 [glass] Add option for debug-level NT logging (#5007)
2b81610248 [wpiutil] Add msgpack to datalog Python example (#5032)
a4a369b8da CONTRIBUTING.md: Add unicodeit CLI to math docs guidelines (#5031)
d991f6e435 [wpilib] Throw on nonexistent SimDevice name in SimDeviceSim constructor (#5041)
a27a047ae8 [hal] Check for null in getSimDeviceName JNI (#5038)
2f96cae31a [examples] Hatchbots: Add telemetry (#5011)
83ef8f9658 [simulation] GUI: Fix buffer overflow in joystick axes copy (#5036)
4054893669 [commands] Fix C++ Select() factory (#5024)
f75acd11ce [commands] Use Timer.restart() (#5023)
8bf67b1b33 [wpimath] PIDController::Calculate(double, double): update setpoint flag (#5021)
49bb1358d8 [wpiutil] MemoryBuffer: Fix GetMemoryBufferForStream (#5017)
9c4c07c0f9 [wpiutil] Remove NDEBUG check for debug-level logging (#5018)
1a47cc2e86 [ntcore] Use full handle when subscribing (#5013)
7cd30cffbc Ignore networktables.json (#5006)
92aecab2ef [commands] Command controllers are not subclasses (NFC) (#5000)
8785bba080 [ntcore] Special-case default timestamps (#5003)
9e5b7b8040 [ntcore] Handle topicsonly followed by value subscribe (#4991)
917906530a [wpilib] Add Timer::Restart() (#4963)
00aa66e4fd [wpimath] Remove extraneous assignments from DiscretizeAB() (#4967)
893320544a [examples] C++ RamseteCommand: Fix units (#4954)
b95d0e060d [wpilib] XboxController: Fix docs discrepancy (NFC) (#4993)
008232b43c [ntcore] Write empty persistent file if none found (#4996)
522be348f4 [examples] Rewrite tags (NFC) (#4961)
d48a83dee2 [wpimath] Update Wikipedia links for quaternion to Euler angle conversion (NFC) (#4995)
504fa22143 [wpimath] Workaround intellisense Eigen issue (#4992)
b2b25bf09f [commands] Fix docs inconsistency for toggleOnFalse(Command) (NFC) (#4978)
ce3dc4eb3b [hal] Properly use control word that is in sync with DS data (#4989)
1ea48caa7d [wpilib] Fix C++ ADXRS450 and Java SPI gyro defs (#4988)
fb101925a7 [build] Include wpimathjni in commands binaries (#4981)
657951f6dd [starter] Add a process starter for use by the installer for launching tools (#4931)
a60ca9d71c [examples] Update AprilTag field load API usage (#4975)
f8a45f1558 [wpimath] Remove print statements from tests (#4977)
ecba8b99a8 [examples] Fix swapped arguments in MecanumControllerCommand example (#4976)
e95e88fdf9 [examples] Add comment to drivedistanceoffboard example (#4877)
371d15dec3 [examples] Add Computer Vision Pose Estimation and Latency Compensation Example (#4901)
cb9b8938af [sim] Enable docking in the GUI (#4960)
3b084ecbe0 [apriltag] AprilTagFieldLayout: Improve API shape for loading builtin JSONs (#4949)
27ba096ea1 [wpilib] Fix MOI calculation error in SingleJointedArmSim (#4968)
42c997a3c4 [wpimath] Fix Pose3d exponential and clean up Pose3d logarithm (#4970)
5f1a025f27 [wpilibj] Fix typo in MecanumDrive docs (NFC) (#4969)
0ebf79b54c [wpimath] Fix typo in Pose3d::Exp() docs (NFC) (#4966)
a8c465f3fb [wpimath] HolonomicDriveController: Add getters for the controllers (#4948)
a7b1ab683d [wpilibc] Add unit test for fast deconstruction of GenericHID (#4953)
bd6479dc29 [build] Add Spotless for JSON (#4956)
5cb0340a8c [hal, wpilib] Load joystick values upon code initialization (#4950)
ab0e8c37a7 [readme] Update build requirements (NFC) (#4947)
b74ac1c645 [build] Add apriltag to C++ cmake example builds (#4944)
cf1a411acf [examples] Add example programs for AprilTags detection (#4932)
1e05b21ab5 [wpimath] Fix PID atSetpoint to not return true prematurely (#4906)
e5a6197633 [wpimath] Fix SwerveDriveKinematics not initializing a new array each time (#4942)
039edcc23f [ntcore] Queue current value on subscriber creation (#4938)
f7f19207e0 [wpimath] Allow multiple vision measurements from same timestamp (#4917)
befd12911c [commands] Delete UB-causing rvalue variants of CommandPtr methods (#4923)
34519de60a [commands] Fix spacing in command composition exception (#4924)
dc4355c031 [hal] Add handle constructor and name getters for sim devices (#4925)
53d8d33bca [hal, wpilibj] Add missing distance per pulse functions to EncoderSim (#4928)
530ae40614 [apriltag] Explain what April tag poses represent (NFC) (#4930)
79f565191e [examples] DigitalCommunication, I2CCommunication: Add tests (#4865)
2cd9be413f [wpilib, examples] Cleanup PotentiometerPID, Ultrasonic, UltrasonicPID examples (#4893)
babb0c1fcf [apriltag] Add 2023 field layout JSON (#4912)
330ba45f9c [wpimath] Fix swerve kinematics util classes equals function (#4907)
51272ef6b3 [fieldImages] Add 2023 field (#4915)
0d105ab771 [commands] Deduplicate command test utils (#4897)
cf4235ea36 [wpiutil] Guard MSVC pragma in SymbolExports.h (#4911)
2d4b7b9147 [build] Update opencv version in opencv.gradle (#4909)
aec6f3d506 [ntcore] Fix client flush behavior (#4903)
bfe346c76a [build] Fix cmake java resources (#4898)

Change-Id: Ia1dd90fe42c6cd5df281b8a5b710e136f54355f4
git-subtree-dir: third_party/allwpilib
git-subtree-split: f1a82828fed8950f9a3f1586c44327027627a0c8
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch
new file mode 100644
index 0000000..48327f8
--- /dev/null
+++ b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch
@@ -0,0 +1,2034 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: PJ Reiniger <pj.reiniger@gmail.com>
+Date: Sat, 7 May 2022 22:09:18 -0400
+Subject: [PATCH 01/31] Remove StringRef, ArrayRef, and Optional
+
+---
+ llvm/include/llvm/ADT/PointerUnion.h          |  1 -
+ llvm/include/llvm/ADT/SmallSet.h              |  2 +-
+ llvm/include/llvm/ADT/SmallString.h           | 77 ++++++++++---------
+ llvm/include/llvm/ADT/SmallVector.h           |  7 +-
+ llvm/include/llvm/ADT/StringMap.h             | 38 ++++-----
+ llvm/include/llvm/ADT/StringMapEntry.h        | 20 ++---
+ llvm/include/llvm/Support/Chrono.h            | 10 +--
+ llvm/include/llvm/Support/Compiler.h          |  2 +-
+ llvm/include/llvm/Support/ConvertUTF.h        | 31 ++++----
+ llvm/include/llvm/Support/ErrorHandling.h     |  9 +--
+ .../llvm/Support/SmallVectorMemoryBuffer.h    |  6 +-
+ llvm/include/llvm/Support/VersionTuple.h      |  6 --
+ .../llvm/Support/Windows/WindowsSupport.h     |  4 +-
+ llvm/include/llvm/Support/raw_ostream.h       | 46 ++++++-----
+ llvm/include/llvm/Support/xxhash.h            | 16 ++--
+ llvm/lib/Support/ConvertUTFWrapper.cpp        | 38 ++++-----
+ llvm/lib/Support/ErrorHandling.cpp            | 13 ++--
+ llvm/lib/Support/SmallVector.cpp              |  5 +-
+ llvm/lib/Support/StringMap.cpp                | 12 +--
+ llvm/lib/Support/raw_ostream.cpp              | 25 +++---
+ llvm/lib/Support/xxhash.cpp                   | 10 +--
+ llvm/unittests/ADT/DenseMapTest.cpp           | 29 +------
+ llvm/unittests/ADT/FunctionExtrasTest.cpp     | 12 +--
+ llvm/unittests/ADT/HashingTest.cpp            |  2 +-
+ llvm/unittests/ADT/SmallPtrSetTest.cpp        |  1 -
+ llvm/unittests/ADT/SmallStringTest.cpp        | 50 ++++++------
+ llvm/unittests/ADT/SmallVectorTest.cpp        | 30 ++------
+ llvm/unittests/ADT/StringMapTest.cpp          | 32 ++++----
+ llvm/unittests/Support/ConvertUTFTest.cpp     | 41 +++++-----
+ llvm/unittests/Support/xxhashTest.cpp         |  4 +-
+ 30 files changed, 264 insertions(+), 315 deletions(-)
+
+diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
+index 7d4ed02b622626bb8043acb57b8ce7ed97a5f949..8ac68dbc0a791b8ac0e0ca865e69024cb642aa70 100644
+--- a/llvm/include/llvm/ADT/PointerUnion.h
++++ b/llvm/include/llvm/ADT/PointerUnion.h
+@@ -17,7 +17,6 @@
+ 
+ #include "llvm/ADT/DenseMapInfo.h"
+ #include "llvm/ADT/PointerIntPair.h"
+-#include "llvm/ADT/STLExtras.h"
+ #include "llvm/Support/Casting.h"
+ #include "llvm/Support/PointerLikeTypeTraits.h"
+ #include <algorithm>
+diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h
+index a16e8ac6f07552d98250e808190b00ee270f12b3..aeee5f97799aea7e7588d7afba1e47b4fa3d8c7b 100644
+--- a/llvm/include/llvm/ADT/SmallSet.h
++++ b/llvm/include/llvm/ADT/SmallSet.h
+@@ -16,12 +16,12 @@
+ 
+ #include "llvm/ADT/SmallPtrSet.h"
+ #include "llvm/ADT/SmallVector.h"
+-#include "llvm/ADT/STLExtras.h"
+ #include "llvm/ADT/iterator.h"
+ #include "llvm/Support/Compiler.h"
+ #include "llvm/Support/type_traits.h"
+ #include <cstddef>
+ #include <functional>
++#include <optional>
+ #include <set>
+ #include <type_traits>
+ #include <utility>
+diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h
+index 0052c86fb37b82dcdf577a7acf06e3a47f54da61..4d673cc8b1c49cf8a3f19653de53881cd12662ee 100644
+--- a/llvm/include/llvm/ADT/SmallString.h
++++ b/llvm/include/llvm/ADT/SmallString.h
+@@ -15,8 +15,9 @@
+ #define LLVM_ADT_SMALLSTRING_H
+ 
+ #include "llvm/ADT/SmallVector.h"
+-#include "llvm/ADT/StringRef.h"
+ #include <cstddef>
++#include <string>
++#include <string_view>
+ 
+ namespace llvm {
+ 
+@@ -28,11 +29,11 @@ public:
+   /// Default ctor - Initialize to empty.
+   SmallString() = default;
+ 
+-  /// Initialize from a StringRef.
+-  SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {}
++  /// Initialize from a std::string_view.
++  SmallString(std::string_view S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {}
+ 
+-  /// Initialize by concatenating a list of StringRefs.
+-  SmallString(std::initializer_list<StringRef> Refs)
++  /// Initialize by concatenating a list of std::string_views.
++  SmallString(std::initializer_list<std::string_view> Refs)
+       : SmallVector<char, InternalLen>() {
+     this->append(Refs);
+   }
+@@ -47,13 +48,13 @@ public:
+ 
+   using SmallVector<char, InternalLen>::assign;
+ 
+-  /// Assign from a StringRef.
+-  void assign(StringRef RHS) {
++  /// Assign from a std::string_view.
++  void assign(std::string_view RHS) {
+     SmallVectorImpl<char>::assign(RHS.begin(), RHS.end());
+   }
+ 
+-  /// Assign from a list of StringRefs.
+-  void assign(std::initializer_list<StringRef> Refs) {
++  /// Assign from a list of std::string_views.
++  void assign(std::initializer_list<std::string_view> Refs) {
+     this->clear();
+     append(Refs);
+   }
+@@ -64,19 +65,19 @@ public:
+ 
+   using SmallVector<char, InternalLen>::append;
+ 
+-  /// Append from a StringRef.
+-  void append(StringRef RHS) {
++  /// Append from a std::string_view.
++  void append(std::string_view RHS) {
+     SmallVectorImpl<char>::append(RHS.begin(), RHS.end());
+   }
+ 
+-  /// Append from a list of StringRefs.
+-  void append(std::initializer_list<StringRef> Refs) {
++  /// Append from a list of std::string_views.
++  void append(std::initializer_list<std::string_view> Refs) {
+     size_t CurrentSize = this->size();
+     size_t SizeNeeded = CurrentSize;
+-    for (const StringRef &Ref : Refs)
++    for (const std::string_view &Ref : Refs)
+       SizeNeeded += Ref.size();
+     this->resize_for_overwrite(SizeNeeded);
+-    for (const StringRef &Ref : Refs) {
++    for (const std::string_view &Ref : Refs) {
+       std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize);
+       CurrentSize += Ref.size();
+     }
+@@ -89,30 +90,30 @@ public:
+ 
+   /// Check for string equality.  This is more efficient than compare() when
+   /// the relative ordering of inequal strings isn't needed.
+-  bool equals(StringRef RHS) const {
++  bool equals(std::string_view RHS) const {
+     return str().equals(RHS);
+   }
+ 
+   /// Check for string equality, ignoring case.
+-  bool equals_insensitive(StringRef RHS) const {
++  bool equals_insensitive(std::string_view RHS) const {
+     return str().equals_insensitive(RHS);
+   }
+ 
+   /// compare - Compare two strings; the result is negative, zero, or positive
+   /// if this string is lexicographically less than, equal to, or greater than
+   /// the \p RHS.
+-  int compare(StringRef RHS) const {
++  int compare(std::string_view RHS) const {
+     return str().compare(RHS);
+   }
+ 
+   /// compare_insensitive - Compare two strings, ignoring case.
+-  int compare_insensitive(StringRef RHS) const {
++  int compare_insensitive(std::string_view RHS) const {
+     return str().compare_insensitive(RHS);
+   }
+ 
+   /// compare_numeric - Compare two strings, treating sequences of digits as
+   /// numbers.
+-  int compare_numeric(StringRef RHS) const {
++  int compare_numeric(std::string_view RHS) const {
+     return str().compare_numeric(RHS);
+   }
+ 
+@@ -121,12 +122,12 @@ public:
+   /// @{
+ 
+   /// startswith - Check if this string starts with the given \p Prefix.
+-  bool startswith(StringRef Prefix) const {
++  bool startswith(std::string_view Prefix) const {
+     return str().startswith(Prefix);
+   }
+ 
+   /// endswith - Check if this string ends with the given \p Suffix.
+-  bool endswith(StringRef Suffix) const {
++  bool endswith(std::string_view Suffix) const {
+     return str().endswith(Suffix);
+   }
+ 
+@@ -146,7 +147,7 @@ public:
+   ///
+   /// \returns The index of the first occurrence of \p Str, or npos if not
+   /// found.
+-  size_t find(StringRef Str, size_t From = 0) const {
++  size_t find(std::string_view Str, size_t From = 0) const {
+     return str().find(Str, From);
+   }
+ 
+@@ -154,7 +155,7 @@ public:
+   ///
+   /// \returns The index of the last occurrence of \p C, or npos if not
+   /// found.
+-  size_t rfind(char C, size_t From = StringRef::npos) const {
++  size_t rfind(char C, size_t From = std::string_view::npos) const {
+     return str().rfind(C, From);
+   }
+ 
+@@ -162,7 +163,7 @@ public:
+   ///
+   /// \returns The index of the last occurrence of \p Str, or npos if not
+   /// found.
+-  size_t rfind(StringRef Str) const {
++  size_t rfind(std::string_view Str) const {
+     return str().rfind(Str);
+   }
+ 
+@@ -176,7 +177,7 @@ public:
+   /// not found.
+   ///
+   /// Complexity: O(size() + Chars.size())
+-  size_t find_first_of(StringRef Chars, size_t From = 0) const {
++  size_t find_first_of(std::string_view Chars, size_t From = 0) const {
+     return str().find_first_of(Chars, From);
+   }
+ 
+@@ -190,13 +191,13 @@ public:
+   /// \p Chars, or npos if not found.
+   ///
+   /// Complexity: O(size() + Chars.size())
+-  size_t find_first_not_of(StringRef Chars, size_t From = 0) const {
++  size_t find_first_not_of(std::string_view Chars, size_t From = 0) const {
+     return str().find_first_not_of(Chars, From);
+   }
+ 
+   /// Find the last character in the string that is \p C, or npos if not
+   /// found.
+-  size_t find_last_of(char C, size_t From = StringRef::npos) const {
++  size_t find_last_of(char C, size_t From = std::string_view::npos) const {
+     return str().find_last_of(C, From);
+   }
+ 
+@@ -205,7 +206,7 @@ public:
+   ///
+   /// Complexity: O(size() + Chars.size())
+   size_t find_last_of(
+-      StringRef Chars, size_t From = StringRef::npos) const {
++      std::string_view Chars, size_t From = std::string_view::npos) const {
+     return str().find_last_of(Chars, From);
+   }
+ 
+@@ -220,7 +221,7 @@ public:
+ 
+   /// Return the number of non-overlapped occurrences of \p Str in the
+   /// string.
+-  size_t count(StringRef Str) const {
++  size_t count(std::string_view Str) const {
+     return str().count(Str);
+   }
+ 
+@@ -237,7 +238,7 @@ public:
+   /// \param N The number of characters to included in the substring. If \p N
+   /// exceeds the number of characters remaining in the string, the string
+   /// suffix (starting with \p Start) will be returned.
+-  StringRef substr(size_t Start, size_t N = StringRef::npos) const {
++  std::string_view substr(size_t Start, size_t N = std::string_view::npos) const {
+     return str().substr(Start, N);
+   }
+ 
+@@ -251,14 +252,14 @@ public:
+   /// substring. If this is npos, or less than \p Start, or exceeds the
+   /// number of characters remaining in the string, the string suffix
+   /// (starting with \p Start) will be returned.
+-  StringRef slice(size_t Start, size_t End) const {
++  std::string_view slice(size_t Start, size_t End) const {
+     return str().slice(Start, End);
+   }
+ 
+   // Extra methods.
+ 
+-  /// Explicit conversion to StringRef.
+-  StringRef str() const { return StringRef(this->data(), this->size()); }
++  /// Explicit conversion to std::string_view.
++  std::string_view str() const { return std::string_view(this->begin(), this->size()); }
+ 
+   // TODO: Make this const, if it's safe...
+   const char* c_str() {
+@@ -267,20 +268,20 @@ public:
+     return this->data();
+   }
+ 
+-  /// Implicit conversion to StringRef.
+-  operator StringRef() const { return str(); }
++  /// Implicit conversion to std::string_view.
++  operator std::string_view() const { return str(); }
+ 
+   explicit operator std::string() const {
+     return std::string(this->data(), this->size());
+   }
+ 
+   // Extra operators.
+-  SmallString &operator=(StringRef RHS) {
++  SmallString &operator=(std::string_view RHS) {
+     this->assign(RHS);
+     return *this;
+   }
+ 
+-  SmallString &operator+=(StringRef RHS) {
++  SmallString &operator+=(std::string_view RHS) {
+     this->append(RHS.begin(), RHS.end());
+     return *this;
+   }
+diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
+index 53a107b1574c6a35c66c7fe3c61deb2ffc84b991..4559864ed231206b098936dae4fc378bfa986371 100644
+--- a/llvm/include/llvm/ADT/SmallVector.h
++++ b/llvm/include/llvm/ADT/SmallVector.h
+@@ -27,13 +27,12 @@
+ #include <limits>
+ #include <memory>
+ #include <new>
++#include <span>
+ #include <type_traits>
+ #include <utility>
+ 
+ namespace llvm {
+ 
+-template <typename T> class ArrayRef;
+-
+ template <typename IteratorT> class iterator_range;
+ 
+ template <class Iterator>
+@@ -117,7 +116,7 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
+ };
+ 
+ /// This is the part of SmallVectorTemplateBase which does not depend on whether
+-/// the type T is a POD. The extra dummy template argument is used by ArrayRef
++/// the type T is a POD. The extra dummy template argument is used by span
+ /// to avoid unnecessarily requiring T to be complete.
+ template <typename T, typename = void>
+ class SmallVectorTemplateCommon
+@@ -1233,7 +1232,7 @@ public:
+ 
+   template <typename U,
+             typename = std::enable_if_t<std::is_convertible<U, T>::value>>
+-  explicit SmallVector(ArrayRef<U> A) : SmallVectorImpl<T>(N) {
++  explicit SmallVector(span<const U> A) : SmallVectorImpl<T>(N) {
+     this->append(A.begin(), A.end());
+   }
+ 
+diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h
+index 466f95254d102e98343290b211f317f749d7692b..34dfbf83c681f4e81a9dadd9382ddca6ef8d6c1d 100644
+--- a/llvm/include/llvm/ADT/StringMap.h
++++ b/llvm/include/llvm/ADT/StringMap.h
+@@ -60,12 +60,12 @@ protected:
+   /// specified bucket will be non-null.  Otherwise, it will be null.  In either
+   /// case, the FullHashValue field of the bucket will be set to the hash value
+   /// of the string.
+-  unsigned LookupBucketFor(StringRef Key);
++  unsigned LookupBucketFor(std::string_view Key);
+ 
+   /// FindKey - Look up the bucket that contains the specified key. If it exists
+   /// in the map, return the bucket number of the key.  Otherwise return -1.
+   /// This does not modify the map.
+-  int FindKey(StringRef Key) const;
++  int FindKey(std::string_view Key) const;
+ 
+   /// RemoveKey - Remove the specified StringMapEntry from the table, but do not
+   /// delete it.  This aborts if the value isn't in the table.
+@@ -73,7 +73,7 @@ protected:
+ 
+   /// RemoveKey - Remove the StringMapEntry for the specified key from the
+   /// table, returning it.  If the key is not in the table, this returns null.
+-  StringMapEntryBase *RemoveKey(StringRef Key);
++  StringMapEntryBase *RemoveKey(std::string_view Key);
+ 
+   /// Allocate the table with the specified number of buckets and otherwise
+   /// setup the map as empty.
+@@ -127,7 +127,7 @@ public:
+       : StringMapImpl(InitialSize, static_cast<unsigned>(sizeof(MapEntryTy))),
+         AllocTy(A) {}
+ 
+-  StringMap(std::initializer_list<std::pair<StringRef, ValueTy>> List)
++  StringMap(std::initializer_list<std::pair<std::string_view, ValueTy>> List)
+       : StringMapImpl(List.size(), static_cast<unsigned>(sizeof(MapEntryTy))) {
+     insert(List);
+   }
+@@ -215,14 +215,14 @@ public:
+                       StringMapKeyIterator<ValueTy>(end()));
+   }
+ 
+-  iterator find(StringRef Key) {
++  iterator find(std::string_view Key) {
+     int Bucket = FindKey(Key);
+     if (Bucket == -1)
+       return end();
+     return iterator(TheTable + Bucket, true);
+   }
+ 
+-  const_iterator find(StringRef Key) const {
++  const_iterator find(std::string_view Key) const {
+     int Bucket = FindKey(Key);
+     if (Bucket == -1)
+       return end();
+@@ -231,7 +231,7 @@ public:
+ 
+   /// lookup - Return the entry for the specified key, or a default
+   /// constructed value if no such entry exists.
+-  ValueTy lookup(StringRef Key) const {
++  ValueTy lookup(std::string_view Key) const {
+     const_iterator Iter = find(Key);
+     if (Iter != end())
+       return Iter->second;
+@@ -240,7 +240,7 @@ public:
+ 
+   /// at - Return the entry for the specified key, or abort if no such
+   /// entry exists.
+-  const ValueTy &at(StringRef Val) const {
++  const ValueTy &at(std::string_view Val) const {
+     auto Iter = this->find(std::move(Val));
+     assert(Iter != this->end() && "StringMap::at failed due to a missing key");
+     return Iter->second;
+@@ -248,13 +248,13 @@ public:
+ 
+   /// Lookup the ValueTy for the \p Key, or create a default constructed value
+   /// if the key is not in the map.
+-  ValueTy &operator[](StringRef Key) { return try_emplace(Key).first->second; }
++  ValueTy &operator[](std::string_view Key) { return try_emplace(Key).first->second; }
+ 
+   /// contains - Return true if the element is in the map, false otherwise.
+-  bool contains(StringRef Key) const { return find(Key) != end(); }
++  bool contains(std::string_view Key) const { return find(Key) != end(); }
+ 
+   /// count - Return 1 if the element is in the map, 0 otherwise.
+-  size_type count(StringRef Key) const { return contains(Key) ? 1 : 0; }
++  size_type count(std::string_view Key) const { return contains(Key) ? 1 : 0; }
+ 
+   template <typename InputTy>
+   size_type count(const StringMapEntry<InputTy> &MapEntry) const {
+@@ -304,7 +304,7 @@ public:
+   /// isn't already in the map. The bool component of the returned pair is true
+   /// if and only if the insertion takes place, and the iterator component of
+   /// the pair points to the element with key equivalent to the key of the pair.
+-  std::pair<iterator, bool> insert(std::pair<StringRef, ValueTy> KV) {
++  std::pair<iterator, bool> insert(std::pair<std::string_view, ValueTy> KV) {
+     return try_emplace(KV.first, std::move(KV.second));
+   }
+ 
+@@ -319,14 +319,14 @@ public:
+   ///  Inserts elements from initializer list ilist. If multiple elements in
+   /// the range have keys that compare equivalent, it is unspecified which
+   /// element is inserted
+-  void insert(std::initializer_list<std::pair<StringRef, ValueTy>> List) {
++  void insert(std::initializer_list<std::pair<std::string_view, ValueTy>> List) {
+     insert(List.begin(), List.end());
+   }
+ 
+   /// Inserts an element or assigns to the current element if the key already
+   /// exists. The return type is the same as try_emplace.
+   template <typename V>
+-  std::pair<iterator, bool> insert_or_assign(StringRef Key, V &&Val) {
++  std::pair<iterator, bool> insert_or_assign(std::string_view Key, V &&Val) {
+     auto Ret = try_emplace(Key, std::forward<V>(Val));
+     if (!Ret.second)
+       Ret.first->second = std::forward<V>(Val);
+@@ -338,7 +338,7 @@ public:
+   /// if and only if the insertion takes place, and the iterator component of
+   /// the pair points to the element with key equivalent to the key of the pair.
+   template <typename... ArgsTy>
+-  std::pair<iterator, bool> try_emplace(StringRef Key, ArgsTy &&...Args) {
++  std::pair<iterator, bool> try_emplace(std::string_view Key, ArgsTy &&...Args) {
+     unsigned BucketNo = LookupBucketFor(Key);
+     StringMapEntryBase *&Bucket = TheTable[BucketNo];
+     if (Bucket && Bucket != getTombstoneVal())
+@@ -385,7 +385,7 @@ public:
+     V.Destroy(getAllocator());
+   }
+ 
+-  bool erase(StringRef Key) {
++  bool erase(std::string_view Key) {
+     iterator I = find(Key);
+     if (I == end())
+       return false;
+@@ -482,17 +482,17 @@ template <typename ValueTy>
+ class StringMapKeyIterator
+     : public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
+                                    StringMapConstIterator<ValueTy>,
+-                                   std::forward_iterator_tag, StringRef> {
++                                   std::forward_iterator_tag, std::string_view> {
+   using base = iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
+                                      StringMapConstIterator<ValueTy>,
+-                                     std::forward_iterator_tag, StringRef>;
++                                     std::forward_iterator_tag, std::string_view>;
+ 
+ public:
+   StringMapKeyIterator() = default;
+   explicit StringMapKeyIterator(StringMapConstIterator<ValueTy> Iter)
+       : base(std::move(Iter)) {}
+ 
+-  StringRef operator*() const { return this->wrapped()->getKey(); }
++  std::string_view operator*() const { return this->wrapped()->getKey(); }
+ };
+ 
+ } // end namespace llvm
+diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h
+index 98b51cc1aebd59eba20076e6d8a4eebc0eebb982..388e81c361642113937f7d5680de73a50635b07d 100644
+--- a/llvm/include/llvm/ADT/StringMapEntry.h
++++ b/llvm/include/llvm/ADT/StringMapEntry.h
+@@ -16,8 +16,8 @@
+ #ifndef LLVM_ADT_STRINGMAPENTRY_H
+ #define LLVM_ADT_STRINGMAPENTRY_H
+ 
+-#include "llvm/ADT/StringRef.h"
+ #include <optional>
++#include <string_view>
+ 
+ namespace llvm {
+ 
+@@ -36,13 +36,13 @@ protected:
+   /// type-erase the allocator and put it in a source file.
+   template <typename AllocatorTy>
+   static void *allocateWithKey(size_t EntrySize, size_t EntryAlign,
+-                               StringRef Key, AllocatorTy &Allocator);
++                               std::string_view Key, AllocatorTy &Allocator);
+ };
+ 
+ // Define out-of-line to dissuade inlining.
+ template <typename AllocatorTy>
+ void *StringMapEntryBase::allocateWithKey(size_t EntrySize, size_t EntryAlign,
+-                                          StringRef Key,
++                                          std::string_view Key,
+                                           AllocatorTy &Allocator) {
+   size_t KeyLength = Key.size();
+ 
+@@ -105,8 +105,8 @@ public:
+ 
+   using ValueType = ValueTy;
+ 
+-  StringRef getKey() const {
+-    return StringRef(getKeyData(), this->getKeyLength());
++  std::string_view getKey() const {
++    return std::string_view(getKeyData(), this->getKeyLength());
+   }
+ 
+   /// getKeyData - Return the start of the string data that is the key for this
+@@ -116,15 +116,15 @@ public:
+     return reinterpret_cast<const char *>(this + 1);
+   }
+ 
+-  StringRef first() const {
+-    return StringRef(getKeyData(), this->getKeyLength());
++  std::string_view first() const {
++    return std::string_view(getKeyData(), this->getKeyLength());
+   }
+ 
+   /// Create a StringMapEntry for the specified key construct the value using
+   /// \p InitiVals.
+   template <typename AllocatorTy, typename... InitTy>
+-  static StringMapEntry *create(StringRef key, AllocatorTy &allocator,
+-                                InitTy &&...initVals) {
++  static StringMapEntry *create(std::string_view key, AllocatorTy &allocator,
++                                InitTy &&... initVals) {
+     return new (StringMapEntryBase::allocateWithKey(
+         sizeof(StringMapEntry), alignof(StringMapEntry), key, allocator))
+         StringMapEntry(key.size(), std::forward<InitTy>(initVals)...);
+@@ -167,7 +167,7 @@ struct tuple_size<llvm::StringMapEntry<ValueTy>>
+ 
+ template <std::size_t I, typename ValueTy>
+ struct tuple_element<I, llvm::StringMapEntry<ValueTy>>
+-    : std::conditional<I == 0, llvm::StringRef, ValueTy> {};
++    : std::conditional<I == 0, std::string_view, ValueTy> {};
+ } // namespace std
+ 
+ #endif // LLVM_ADT_STRINGMAPENTRY_H
+diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h
+index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2bc7b64af 100644
+--- a/llvm/include/llvm/Support/Chrono.h
++++ b/llvm/include/llvm/Support/Chrono.h
+@@ -70,7 +70,7 @@ raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP);
+ template <>
+ struct format_provider<sys::TimePoint<>> {
+   static void format(const sys::TimePoint<> &TP, llvm::raw_ostream &OS,
+-                     StringRef Style);
++                     std::string_view Style);
+ };
+ 
+ namespace detail {
+@@ -122,7 +122,7 @@ private:
+     return duration_cast<duration<InternalRep, AsPeriod>>(D).count();
+   }
+ 
+-  static std::pair<InternalRep, StringRef> consumeUnit(StringRef &Style,
++  static std::pair<InternalRep, std::string_view> consumeUnit(std::string_view &Style,
+                                                         const Dur &D) {
+     using namespace std::chrono;
+     if (Style.consume_front("ns"))
+@@ -140,7 +140,7 @@ private:
+     return {D.count(), detail::unit<Period>::value};
+   }
+ 
+-  static bool consumeShowUnit(StringRef &Style) {
++  static bool consumeShowUnit(std::string_view &Style) {
+     if (Style.empty())
+       return true;
+     if (Style.consume_front("-"))
+@@ -152,9 +152,9 @@ private:
+   }
+ 
+ public:
+-  static void format(const Dur &D, llvm::raw_ostream &Stream, StringRef Style) {
++  static void format(const Dur &D, llvm::raw_ostream &Stream, std::string_view Style) {
+     InternalRep count;
+-    StringRef unit;
++    std::string_view unit;
+     std::tie(count, unit) = consumeUnit(Style, D);
+     bool show_unit = consumeShowUnit(Style);
+ 
+diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
+index 10d5cec231a523c943c37a5464cb3943627239a9..92376629c607461061bc60597a47aed1e535af52 100644
+--- a/llvm/include/llvm/Support/Compiler.h
++++ b/llvm/include/llvm/Support/Compiler.h
+@@ -300,7 +300,7 @@
+ #endif
+ 
+ /// LLVM_GSL_POINTER - Apply this to non-owning classes like
+-/// StringRef to enable lifetime warnings.
++/// std::string_view to enable lifetime warnings.
+ #if LLVM_HAS_CPP_ATTRIBUTE(gsl::Pointer)
+ #define LLVM_GSL_POINTER [[gsl::Pointer]]
+ #else
+diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h
+index c892bb3c03cb569994429649bdbb96e4118dcef1..5c0e3009c25446a34882fb98329b1d955231bb39 100644
+--- a/llvm/include/llvm/Support/ConvertUTF.h
++++ b/llvm/include/llvm/Support/ConvertUTF.h
+@@ -107,10 +107,9 @@
+ 
+ #include <cstddef>
+ #include <string>
+-
+-#if defined(_WIN32)
++#include <span>
++#include <string_view>
+ #include <system_error>
+-#endif
+ 
+ // Wrap everything in namespace llvm so that programs can link with llvm and
+ // their own version of the unicode libraries.
+@@ -204,12 +203,10 @@ unsigned getNumBytesForUTF8(UTF8 firstByte);
+ /*************************************************************************/
+ /* Below are LLVM-specific wrappers of the functions above. */
+ 
+-template <typename T> class ArrayRef;
+ template <typename T> class SmallVectorImpl;
+-class StringRef;
+ 
+ /**
+- * Convert an UTF8 StringRef to UTF8, UTF16, or UTF32 depending on
++ * Convert an UTF8 string_view to UTF8, UTF16, or UTF32 depending on
+  * WideCharWidth. The converted data is written to ResultPtr, which needs to
+  * point to at least WideCharWidth * (Source.Size() + 1) bytes. On success,
+  * ResultPtr will point one after the end of the copied string. On failure,
+@@ -217,14 +214,14 @@ class StringRef;
+  * the first character which could not be converted.
+  * \return true on success.
+  */
+-bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source,
++bool ConvertUTF8toWide(unsigned WideCharWidth, std::string_view Source,
+                        char *&ResultPtr, const UTF8 *&ErrorPtr);
+ 
+ /**
+-* Converts a UTF-8 StringRef to a std::wstring.
++* Converts a UTF-8 string_view to a std::wstring.
+ * \return true on success.
+ */
+-bool ConvertUTF8toWide(llvm::StringRef Source, std::wstring &Result);
++bool ConvertUTF8toWide(std::string_view Source, std::wstring &Result);
+ 
+ /**
+ * Converts a UTF-8 C-string to a std::wstring.
+@@ -282,7 +279,7 @@ inline ConversionResult convertUTF8Sequence(const UTF8 **source,
+  * Returns true if a blob of text starts with a UTF-16 big or little endian byte
+  * order mark.
+  */
+-bool hasUTF16ByteOrderMark(ArrayRef<char> SrcBytes);
++bool hasUTF16ByteOrderMark(span<const char> SrcBytes);
+ 
+ /**
+  * Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
+@@ -291,7 +288,7 @@ bool hasUTF16ByteOrderMark(ArrayRef<char> SrcBytes);
+  * \param [out] Out Converted UTF-8 is stored here on success.
+  * \returns true on success
+  */
+-bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
++bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out);
+ 
+ /**
+ * Converts a UTF16 string into a UTF8 std::string.
+@@ -300,7 +297,7 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+-bool convertUTF16ToUTF8String(ArrayRef<UTF16> Src, std::string &Out);
++bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out);
+ 
+ /**
+  * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+@@ -309,7 +306,7 @@ bool convertUTF16ToUTF8String(ArrayRef<UTF16> Src, std::string &Out);
+  * \param [out] Out Converted UTF-8 is stored here on success.
+  * \returns true on success
+  */
+-bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
++bool convertUTF32ToUTF8String(span<const char> SrcBytes, std::string &Out);
+ 
+ /**
+  * Converts a UTF32 string into a UTF8 std::string.
+@@ -318,22 +315,22 @@ bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out);
+  * \param [out] Out Converted UTF-8 is stored here on success.
+  * \returns true on success
+  */
+-bool convertUTF32ToUTF8String(ArrayRef<UTF32> Src, std::string &Out);
++bool convertUTF32ToUTF8String(span<const UTF32> Src, std::string &Out);
+ 
+ /**
+  * Converts a UTF-8 string into a UTF-16 string with native endianness.
+  *
+  * \returns true on success
+  */
+-bool convertUTF8ToUTF16String(StringRef SrcUTF8,
++bool convertUTF8ToUTF16String(std::string_view SrcUTF8,
+                               SmallVectorImpl<UTF16> &DstUTF16);
+ 
+ #if defined(_WIN32)
+ namespace sys {
+ namespace windows {
+-std::error_code UTF8ToUTF16(StringRef utf8, SmallVectorImpl<wchar_t> &utf16);
++std::error_code UTF8ToUTF16(std::string_view utf8, SmallVectorImpl<wchar_t> &utf16);
+ /// Convert to UTF16 from the current code page used in the system
+-std::error_code CurCPToUTF16(StringRef utf8, SmallVectorImpl<wchar_t> &utf16);
++std::error_code CurCPToUTF16(std::string_view utf8, SmallVectorImpl<wchar_t> &utf16);
+ std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
+                             SmallVectorImpl<char> &utf8);
+ /// Convert from UTF16 to the current code page used in the system
+diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h
+index 9c8e3448f3a03e3540adb8b9dd730c77dd9b20ba..68c27a8c67c4f378b92cfa726659ef7824b56dea 100644
+--- a/llvm/include/llvm/Support/ErrorHandling.h
++++ b/llvm/include/llvm/Support/ErrorHandling.h
+@@ -15,10 +15,10 @@
+ #define LLVM_SUPPORT_ERRORHANDLING_H
+ 
+ #include "llvm/Support/Compiler.h"
++#include <string>
++#include <string_view>
+ 
+ namespace llvm {
+-  class StringRef;
+-  class Twine;
+ 
+   /// An error handler callback.
+   typedef void (*fatal_error_handler_t)(void *user_data,
+@@ -67,12 +67,11 @@ namespace llvm {
+ /// standard error, followed by a newline.
+ /// After the error handler is called this function will call abort(), it
+ /// does not return.
+-/// NOTE: The std::string variant was removed to avoid a <string> dependency.
+ [[noreturn]] void report_fatal_error(const char *reason,
+                                      bool gen_crash_diag = true);
+-[[noreturn]] void report_fatal_error(StringRef reason,
++[[noreturn]] void report_fatal_error(const std::string &reason,
+                                      bool gen_crash_diag = true);
+-[[noreturn]] void report_fatal_error(const Twine &reason,
++[[noreturn]] void report_fatal_error(std::string_view reason,
+                                      bool gen_crash_diag = true);
+ 
+ /// Installs a new bad alloc error handler that should be used whenever a
+diff --git a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
+index f7f2d4e54e705d6f29812dc93d1fb0a3ca2dee12..b5e321b5f74ce35940649b9d1342b3cdf0c4931f 100644
+--- a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
++++ b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h
+@@ -35,8 +35,8 @@ public:
+                                 RequiresNullTerminator) {}
+ 
+   /// Construct a named SmallVectorMemoryBuffer from the given SmallVector
+-  /// r-value and StringRef.
+-  SmallVectorMemoryBuffer(SmallVectorImpl<char> &&SV, StringRef Name,
++  /// r-value and std::string_view.
++  SmallVectorMemoryBuffer(SmallVectorImpl<char> &&SV, std::string_view Name,
+                           bool RequiresNullTerminator = true)
+       : SV(std::move(SV)), BufferName(std::string(Name)) {
+     if (RequiresNullTerminator) {
+@@ -49,7 +49,7 @@ public:
+   // Key function.
+   ~SmallVectorMemoryBuffer() override;
+ 
+-  StringRef getBufferIdentifier() const override { return BufferName; }
++  std::string_view getBufferIdentifier() const override { return BufferName; }
+ 
+   BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }
+ 
+diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
+index 828a6db54708dfa9a1a4b4456a92945a92ad80cb..953b40701dc934c1a356b5413c9c6c692d5f5679 100644
+--- a/llvm/include/llvm/Support/VersionTuple.h
++++ b/llvm/include/llvm/Support/VersionTuple.h
+@@ -25,7 +25,6 @@ namespace llvm {
+ template <typename HasherT, support::endianness Endianness>
+ class HashBuilderImpl;
+ class raw_ostream;
+-class StringRef;
+ 
+ /// Represents a version number in the form major[.minor[.subminor[.build]]].
+ class VersionTuple {
+@@ -182,11 +181,6 @@ public:
+ 
+   /// Retrieve a string representation of the version number.
+   std::string getAsString() const;
+-
+-  /// Try to parse the given string as a version number.
+-  /// \returns \c true if the string does not match the regular expression
+-  ///   [0-9]+(\.[0-9]+){0,3}
+-  bool tryParse(StringRef string);
+ };
+ 
+ /// Print a version number.
+diff --git a/llvm/include/llvm/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h
+index d3aacd14b2097b1e7e13c1003987c1fd52e0cf76..aabdb2f14668a990329b57f5454a0d7db73e12ce 100644
+--- a/llvm/include/llvm/Support/Windows/WindowsSupport.h
++++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h
+@@ -35,8 +35,6 @@
+ 
+ #include "llvm/ADT/SmallVector.h"
+ #include "llvm/ADT/StringExtras.h"
+-#include "llvm/ADT/StringRef.h"
+-#include "llvm/ADT/Twine.h"
+ #include "llvm/Config/llvm-config.h" // Get build system configuration settings
+ #include "llvm/Support/Allocator.h"
+ #include "llvm/Support/Chrono.h"
+@@ -74,7 +72,7 @@ bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix);
+ [[noreturn]] inline void ReportLastErrorFatal(const char *Msg) {
+   std::string ErrMsg;
+   MakeErrMsg(&ErrMsg, Msg);
+-  llvm::report_fatal_error(Twine(ErrMsg));
++  llvm::report_fatal_error(ErrMsg);
+ }
+ 
+ template <typename HandleTraits>
+diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
+index 1e01eb9ea19c4187302a91457b6d34fbe5b67584..2463f1af612a78cafafe3c0e16d496e607cdc322 100644
+--- a/llvm/include/llvm/Support/raw_ostream.h
++++ b/llvm/include/llvm/Support/raw_ostream.h
+@@ -14,13 +14,12 @@
+ #define LLVM_SUPPORT_RAW_OSTREAM_H
+ 
+ #include "llvm/ADT/SmallVector.h"
+-#include "llvm/ADT/StringRef.h"
+-#include "llvm/Support/DataTypes.h"
+ #include <cassert>
+ #include <cstddef>
+ #include <cstdint>
+ #include <cstring>
+ #include <optional>
++#include <span>
+ #include <string>
+ #include <string_view>
+ #include <system_error>
+@@ -208,7 +207,22 @@ public:
+     return *this;
+   }
+ 
+-  raw_ostream &operator<<(StringRef Str) {
++  raw_ostream &operator<<(span<const uint8_t> Arr) {
++    // Inline fast path, particularly for arrays with a known length.
++    size_t Size = Arr.size();
++
++    // Make sure we can use the fast path.
++    if (Size > (size_t)(OutBufEnd - OutBufCur))
++      return write(Arr.data(), Size);
++
++    if (Size) {
++      memcpy(OutBufCur, Arr.data(), Size);
++      OutBufCur += Size;
++    }
++    return *this;
++  }
++
++  raw_ostream &operator<<(std::string_view Str) {
+     // Inline fast path, particularly for strings with a known length.
+     size_t Size = Str.size();
+ 
+@@ -241,7 +255,7 @@ public:
+     // Inline fast path, particularly for constant strings where a sufficiently
+     // smart compiler will simplify strlen.
+ 
+-    return this->operator<<(StringRef(Str));
++    return this->operator<<(std::string_view(Str));
+   }
+ 
+   raw_ostream &operator<<(const std::string &Str) {
+@@ -249,10 +263,6 @@ public:
+     return write(Str.data(), Str.length());
+   }
+ 
+-  raw_ostream &operator<<(const std::string_view &Str) {
+-    return write(Str.data(), Str.length());
+-  }
+-
+   raw_ostream &operator<<(const SmallVectorImpl<char> &Str) {
+     return write(Str.data(), Str.size());
+   }
+@@ -285,7 +295,7 @@ public:
+ 
+   /// Output \p Str, turning '\\', '\t', '\n', '"', and anything that doesn't
+   /// satisfy llvm::isPrint into an escape sequence.
+-  raw_ostream &write_escaped(StringRef Str, bool UseHexEscapes = false);
++  raw_ostream &write_escaped(std::string_view Str, bool UseHexEscapes = false);
+ 
+   raw_ostream &write(unsigned char C);
+   raw_ostream &write(const char *Ptr, size_t Size);
+@@ -501,14 +511,14 @@ public:
+   /// As a special case, if Filename is "-", then the stream will use
+   /// STDOUT_FILENO instead of opening a file. This will not close the stdout
+   /// descriptor.
+-  raw_fd_ostream(StringRef Filename, std::error_code &EC);
+-  raw_fd_ostream(StringRef Filename, std::error_code &EC,
++  raw_fd_ostream(std::string_view Filename, std::error_code &EC);
++  raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                  sys::fs::CreationDisposition Disp);
+-  raw_fd_ostream(StringRef Filename, std::error_code &EC,
++  raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                  sys::fs::FileAccess Access);
+-  raw_fd_ostream(StringRef Filename, std::error_code &EC,
++  raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                  sys::fs::OpenFlags Flags);
+-  raw_fd_ostream(StringRef Filename, std::error_code &EC,
++  raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                  sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
+                  sys::fs::OpenFlags Flags);
+ 
+@@ -613,7 +623,7 @@ public:
+   /// Open the specified file for reading/writing/seeking. If an error occurs,
+   /// information about the error is put into EC, and the stream should be
+   /// immediately destroyed.
+-  raw_fd_stream(StringRef Filename, std::error_code &EC);
++  raw_fd_stream(std::string_view Filename, std::error_code &EC);
+ 
+   /// This reads the \p Size bytes into a buffer pointed by \p Ptr.
+   ///
+@@ -693,8 +703,8 @@ public:
+ 
+   void flush() = delete;
+ 
+-  /// Return a StringRef for the vector contents.
+-  StringRef str() const { return StringRef(OS.data(), OS.size()); }
++  /// Return a std::string_view for the vector contents.
++  std::string_view str() const { return std::string_view(OS.data(), OS.size()); }
+ 
+   void reserveExtraSpace(uint64_t ExtraSize) override {
+     OS.reserve(tell() + ExtraSize);
+@@ -751,7 +761,7 @@ class Error;
+ /// for other names. For raw_fd_ostream instances, the stream writes to
+ /// a temporary file. The final output file is atomically replaced with the
+ /// temporary file after the \p Write function is finished.
+-Error writeToOutput(StringRef OutputFileName,
++Error writeToOutput(std::string_view OutputFileName,
+                     std::function<Error(raw_ostream &)> Write);
+ 
+ raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t);
+diff --git a/llvm/include/llvm/Support/xxhash.h b/llvm/include/llvm/Support/xxhash.h
+index 0cef3a54e50d70177a7401324f7a4daca83c6599..3e19ebabb7ad0ff437220d9fdfe59a313386762a 100644
+--- a/llvm/include/llvm/Support/xxhash.h
++++ b/llvm/include/llvm/Support/xxhash.h
+@@ -38,16 +38,18 @@
+ #ifndef LLVM_SUPPORT_XXHASH_H
+ #define LLVM_SUPPORT_XXHASH_H
+ 
+-#include "llvm/ADT/ArrayRef.h"
+-#include "llvm/ADT/StringRef.h"
++#include <stdint.h>
++
++#include <span>
++#include <string_view>
+ 
+ namespace llvm {
+-uint64_t xxHash64(llvm::StringRef Data);
+-uint64_t xxHash64(llvm::ArrayRef<uint8_t> Data);
++uint64_t xxHash64(std::string_view Data);
++uint64_t xxHash64(span<const uint8_t> Data);
+ 
+-uint64_t xxh3_64bits(ArrayRef<uint8_t> data);
+-inline uint64_t xxh3_64bits(StringRef data) {
+-  return xxh3_64bits(ArrayRef(data.bytes_begin(), data.size()));
++uint64_t xxh3_64bits(span<const uint8_t> data);
++inline uint64_t xxh3_64bits(std::string_view data) {
++  return xxh3_64bits(span(reinterpret_cast<const uint8_t*>(data.data()), data.size()));
+ }
+ }
+ 
+diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp
+index 3fa7365e72d34a5db941d1cbe2b1beebad5c10e6..d53462e742e61d3476915d5b2c5aa63772e78a8a 100644
+--- a/llvm/lib/Support/ConvertUTFWrapper.cpp
++++ b/llvm/lib/Support/ConvertUTFWrapper.cpp
+@@ -6,24 +6,24 @@
+ //
+ //===----------------------------------------------------------------------===//
+ 
+-#include "llvm/ADT/ArrayRef.h"
+-#include "llvm/ADT/StringRef.h"
+ #include "llvm/Support/ConvertUTF.h"
+ #include "llvm/Support/ErrorHandling.h"
+ #include "llvm/Support/SwapByteOrder.h"
++#include <span>
+ #include <string>
++#include <string_view>
+ #include <vector>
+ 
+ namespace llvm {
+ 
+-bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source,
++bool ConvertUTF8toWide(unsigned WideCharWidth, std::string_view Source,
+                        char *&ResultPtr, const UTF8 *&ErrorPtr) {
+   assert(WideCharWidth == 1 || WideCharWidth == 2 || WideCharWidth == 4);
+   ConversionResult result = conversionOK;
+   // Copy the character span over.
+   if (WideCharWidth == 1) {
+-    const UTF8 *Pos = reinterpret_cast<const UTF8*>(Source.begin());
+-    if (!isLegalUTF8String(&Pos, reinterpret_cast<const UTF8*>(Source.end()))) {
++    const UTF8 *Pos = reinterpret_cast<const UTF8*>(Source.data());
++    if (!isLegalUTF8String(&Pos, reinterpret_cast<const UTF8*>(Source.data() + Source.size()))) {
+       result = sourceIllegal;
+       ErrorPtr = Pos;
+     } else {
+@@ -76,12 +76,12 @@ bool ConvertCodePointToUTF8(unsigned Source, char *&ResultPtr) {
+   return true;
+ }
+ 
+-bool hasUTF16ByteOrderMark(ArrayRef<char> S) {
++bool hasUTF16ByteOrderMark(span<const char> S) {
+   return (S.size() >= 2 && ((S[0] == '\xff' && S[1] == '\xfe') ||
+                             (S[0] == '\xfe' && S[1] == '\xff')));
+ }
+ 
+-bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
++bool convertUTF16ToUTF8String(span<const char> SrcBytes, std::string &Out) {
+   assert(Out.empty());
+ 
+   // Error out on an uneven byte count.
+@@ -132,14 +132,14 @@ bool convertUTF16ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
+   return true;
+ }
+ 
+-bool convertUTF16ToUTF8String(ArrayRef<UTF16> Src, std::string &Out) {
++bool convertUTF16ToUTF8String(span<const UTF16> Src, std::string &Out) {
+   return convertUTF16ToUTF8String(
+-      llvm::ArrayRef<char>(reinterpret_cast<const char *>(Src.data()),
++      span<const char>(reinterpret_cast<const char *>(Src.data()),
+                            Src.size() * sizeof(UTF16)),
+       Out);
+ }
+ 
+-bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
++bool convertUTF32ToUTF8String(span<const char> SrcBytes, std::string &Out) {
+   assert(Out.empty());
+ 
+   // Error out on an uneven byte count.
+@@ -190,14 +190,14 @@ bool convertUTF32ToUTF8String(ArrayRef<char> SrcBytes, std::string &Out) {
+   return true;
+ }
+ 
+-bool convertUTF32ToUTF8String(ArrayRef<UTF32> Src, std::string &Out) {
++bool convertUTF32ToUTF8String(span<const UTF32> Src, std::string &Out) {
+   return convertUTF32ToUTF8String(
+-      llvm::ArrayRef<char>(reinterpret_cast<const char *>(Src.data()),
++      span<const char>(reinterpret_cast<const char *>(Src.data()),
+                            Src.size() * sizeof(UTF32)),
+       Out);
+ }
+ 
+-bool convertUTF8ToUTF16String(StringRef SrcUTF8,
++bool convertUTF8ToUTF16String(std::string_view SrcUTF8,
+                               SmallVectorImpl<UTF16> &DstUTF16) {
+   assert(DstUTF16.empty());
+ 
+@@ -208,8 +208,8 @@ bool convertUTF8ToUTF16String(StringRef SrcUTF8,
+     return true;
+   }
+ 
+-  const UTF8 *Src = reinterpret_cast<const UTF8 *>(SrcUTF8.begin());
+-  const UTF8 *SrcEnd = reinterpret_cast<const UTF8 *>(SrcUTF8.end());
++  const UTF8 *Src = reinterpret_cast<const UTF8 *>(SrcUTF8.data());
++  const UTF8 *SrcEnd = reinterpret_cast<const UTF8 *>(SrcUTF8.data() + SrcUTF8.size());
+ 
+   // Allocate the same number of UTF-16 code units as UTF-8 code units. Encoding
+   // as UTF-16 should always require the same amount or less code units than the
+@@ -240,7 +240,7 @@ static_assert(sizeof(wchar_t) == 1 || sizeof(wchar_t) == 2 ||
+               "Expected wchar_t to be 1, 2, or 4 bytes");
+ 
+ template <typename TResult>
+-static inline bool ConvertUTF8toWideInternal(llvm::StringRef Source,
++static inline bool ConvertUTF8toWideInternal(std::string_view Source,
+                                              TResult &Result) {
+   // Even in the case of UTF-16, the number of bytes in a UTF-8 string is
+   // at least as large as the number of elements in the resulting wide
+@@ -256,7 +256,7 @@ static inline bool ConvertUTF8toWideInternal(llvm::StringRef Source,
+   return true;
+ }
+ 
+-bool ConvertUTF8toWide(llvm::StringRef Source, std::wstring &Result) {
++bool ConvertUTF8toWide(std::string_view Source, std::wstring &Result) {
+   return ConvertUTF8toWideInternal(Source, Result);
+ }
+ 
+@@ -265,7 +265,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result) {
+     Result.clear();
+     return true;
+   }
+-  return ConvertUTF8toWide(llvm::StringRef(Source), Result);
++  return ConvertUTF8toWide(std::string_view(Source), Result);
+ }
+ 
+ bool convertWideToUTF8(const std::wstring &Source, std::string &Result) {
+@@ -280,7 +280,7 @@ bool convertWideToUTF8(const std::wstring &Source, std::string &Result) {
+     return true;
+   } else if (sizeof(wchar_t) == 2) {
+     return convertUTF16ToUTF8String(
+-        llvm::ArrayRef<UTF16>(reinterpret_cast<const UTF16 *>(Source.data()),
++        span<const UTF16>(reinterpret_cast<const UTF16 *>(Source.data()),
+                               Source.size()),
+         Result);
+   } else if (sizeof(wchar_t) == 4) {
+diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
+index b8b3b7424ac6b1de782e739782f9671194ce77a1..0aa13a0f78eb370b2a673ca4a773f26820575052 100644
+--- a/llvm/lib/Support/ErrorHandling.cpp
++++ b/llvm/lib/Support/ErrorHandling.cpp
+@@ -14,7 +14,6 @@
+ #include "llvm/Support/ErrorHandling.h"
+ #include "llvm-c/ErrorHandling.h"
+ #include "llvm/ADT/SmallVector.h"
+-#include "llvm/ADT/Twine.h"
+ #include "llvm/Config/config.h"
+ #include "llvm/Support/Debug.h"
+ #include "llvm/Support/Errc.h"
+@@ -80,14 +79,14 @@ void llvm::remove_fatal_error_handler() {
+ }
+ 
+ void llvm::report_fatal_error(const char *Reason, bool GenCrashDiag) {
+-  report_fatal_error(Twine(Reason), GenCrashDiag);
++  report_fatal_error(std::string_view(Reason), GenCrashDiag);
+ }
+ 
+-void llvm::report_fatal_error(StringRef Reason, bool GenCrashDiag) {
+-  report_fatal_error(Twine(Reason), GenCrashDiag);
++void llvm::report_fatal_error(const std::string &Reason, bool GenCrashDiag) {
++  report_fatal_error(std::string_view(Reason), GenCrashDiag);
+ }
+ 
+-void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) {
++void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
+   llvm::fatal_error_handler_t handler = nullptr;
+   void* handlerData = nullptr;
+   {
+@@ -101,7 +100,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) {
+   }
+ 
+   if (handler) {
+-    handler(handlerData, Reason.str().c_str(), GenCrashDiag);
++    handler(handlerData, std::string{Reason}.c_str(), GenCrashDiag);
+   } else {
+     // Blast the result out to stderr.  We don't try hard to make sure this
+     // succeeds (e.g. handling EINTR) and we can't use errs() here because
+@@ -109,7 +108,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) {
+     SmallVector<char, 64> Buffer;
+     raw_svector_ostream OS(Buffer);
+     OS << "LLVM ERROR: " << Reason << "\n";
+-    StringRef MessageStr = OS.str();
++    std::string_view MessageStr = OS.str();
+     ssize_t written = ::write(2, MessageStr.data(), MessageStr.size());
+     (void)written; // If something went wrong, we deliberately just give up.
+   }
+diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp
+index f7e7e80332cc337f6dfa388d1e218e6f3ec95cf2..6cefdff7c28060ca18b522acf5279af3a206e23a 100644
+--- a/llvm/lib/Support/SmallVector.cpp
++++ b/llvm/lib/Support/SmallVector.cpp
+@@ -11,7 +11,6 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/ADT/SmallVector.h"
+-#include "llvm/ADT/Twine.h"
+ #include "llvm/Support/MemAlloc.h"
+ #include <cstdint>
+ #ifdef LLVM_ENABLE_EXCEPTIONS
+@@ -67,7 +66,7 @@ static void report_size_overflow(size_t MinSize, size_t MaxSize) {
+ #ifdef LLVM_ENABLE_EXCEPTIONS
+   throw std::length_error(Reason);
+ #else
+-  report_fatal_error(Twine(Reason));
++  report_fatal_error(Reason);
+ #endif
+ }
+ 
+@@ -81,7 +80,7 @@ static void report_at_maximum_capacity(size_t MaxSize) {
+ #ifdef LLVM_ENABLE_EXCEPTIONS
+   throw std::length_error(Reason);
+ #else
+-  report_fatal_error(Twine(Reason));
++  report_fatal_error(Reason);
+ #endif
+ }
+ 
+diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp
+index 67c05a87959cf0c243d17646ae2f28f6c9f0d708..7be219323f6d76f32a9a841115f2f146141cdbab 100644
+--- a/llvm/lib/Support/StringMap.cpp
++++ b/llvm/lib/Support/StringMap.cpp
+@@ -81,7 +81,7 @@ void StringMapImpl::init(unsigned InitSize) {
+ /// specified bucket will be non-null.  Otherwise, it will be null.  In either
+ /// case, the FullHashValue field of the bucket will be set to the hash value
+ /// of the string.
+-unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
++unsigned StringMapImpl::LookupBucketFor(std::string_view Name) {
+   // Hash table unallocated so far?
+   if (NumBuckets == 0)
+     init(16);
+@@ -121,7 +121,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
+       // Do the comparison like this because Name isn't necessarily
+       // null-terminated!
+       char *ItemStr = (char *)BucketItem + ItemSize;
+-      if (Name == StringRef(ItemStr, BucketItem->getKeyLength())) {
++      if (Name == std::string_view(ItemStr, BucketItem->getKeyLength())) {
+         // We found a match!
+         return BucketNo;
+       }
+@@ -139,7 +139,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) {
+ /// FindKey - Look up the bucket that contains the specified key. If it exists
+ /// in the map, return the bucket number of the key.  Otherwise return -1.
+ /// This does not modify the map.
+-int StringMapImpl::FindKey(StringRef Key) const {
++int StringMapImpl::FindKey(std::string_view Key) const {
+   if (NumBuckets == 0)
+     return -1; // Really empty table?
+   unsigned FullHashValue = xxh3_64bits(Key);
+@@ -166,7 +166,7 @@ int StringMapImpl::FindKey(StringRef Key) const {
+       // Do the comparison like this because NameStart isn't necessarily
+       // null-terminated!
+       char *ItemStr = (char *)BucketItem + ItemSize;
+-      if (Key == StringRef(ItemStr, BucketItem->getKeyLength())) {
++      if (Key == std::string_view(ItemStr, BucketItem->getKeyLength())) {
+         // We found a match!
+         return BucketNo;
+       }
+@@ -185,14 +185,14 @@ int StringMapImpl::FindKey(StringRef Key) const {
+ /// delete it.  This aborts if the value isn't in the table.
+ void StringMapImpl::RemoveKey(StringMapEntryBase *V) {
+   const char *VStr = (char *)V + ItemSize;
+-  StringMapEntryBase *V2 = RemoveKey(StringRef(VStr, V->getKeyLength()));
++  StringMapEntryBase *V2 = RemoveKey(std::string_view(VStr, V->getKeyLength()));
+   (void)V2;
+   assert(V == V2 && "Didn't find key?");
+ }
+ 
+ /// RemoveKey - Remove the StringMapEntry for the specified key from the
+ /// table, returning it.  If the key is not in the table, this returns null.
+-StringMapEntryBase *StringMapImpl::RemoveKey(StringRef Key) {
++StringMapEntryBase *StringMapImpl::RemoveKey(std::string_view Key) {
+   int Bucket = FindKey(Key);
+   if (Bucket == -1)
+     return nullptr;
+diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
+index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d83ac20248 100644
+--- a/llvm/lib/Support/raw_ostream.cpp
++++ b/llvm/lib/Support/raw_ostream.cpp
+@@ -166,7 +166,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) {
+ }
+ 
+ 
+-raw_ostream &raw_ostream::write_escaped(StringRef Str,
++raw_ostream &raw_ostream::write_escaped(std::string_view Str,
+                                         bool UseHexEscapes) {
+   for (unsigned char c : Str) {
+     switch (c) {
+@@ -569,7 +569,7 @@ void format_object_base::home() {
+ //  raw_fd_ostream
+ //===----------------------------------------------------------------------===//
+ 
+-static int getFD(StringRef Filename, std::error_code &EC,
++static int getFD(std::string_view Filename, std::error_code &EC,
+                  sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
+                  sys::fs::OpenFlags Flags) {
+   assert((Access & sys::fs::FA_Write) &&
+@@ -595,25 +595,25 @@ static int getFD(StringRef Filename, std::error_code &EC,
+   return FD;
+ }
+ 
+-raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC)
++raw_fd_ostream::raw_fd_ostream(std::string_view Filename, std::error_code &EC)
+     : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write,
+                      sys::fs::OF_None) {}
+ 
+-raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
++raw_fd_ostream::raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                                sys::fs::CreationDisposition Disp)
+     : raw_fd_ostream(Filename, EC, Disp, sys::fs::FA_Write, sys::fs::OF_None) {}
+ 
+-raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
++raw_fd_ostream::raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                                sys::fs::FileAccess Access)
+     : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, Access,
+                      sys::fs::OF_None) {}
+ 
+-raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
++raw_fd_ostream::raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                                sys::fs::OpenFlags Flags)
+     : raw_fd_ostream(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write,
+                      Flags) {}
+ 
+-raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
++raw_fd_ostream::raw_fd_ostream(std::string_view Filename, std::error_code &EC,
+                                sys::fs::CreationDisposition Disp,
+                                sys::fs::FileAccess Access,
+                                sys::fs::OpenFlags Flags)
+@@ -685,8 +685,7 @@ raw_fd_ostream::~raw_fd_ostream() {
+   // has_error() and clear the error flag with clear_error() before
+   // destructing raw_ostream objects which may have errors.
+   if (has_error())
+-    report_fatal_error(Twine("IO failure on output stream: ") +
+-                           error().message(),
++    report_fatal_error("IO failure on output stream: " + error().message(),
+                        /*gen_crash_diag=*/false);
+ }
+ 
+@@ -705,7 +704,7 @@ raw_fd_ostream::~raw_fd_ostream() {
+ // the input is UTF-8 or transcode from the local codepage to UTF-8 before
+ // quoting it. If they don't, this may mess up the encoding, but this is still
+ // probably the best compromise we can make.
+-static bool write_console_impl(int FD, StringRef Data) {
++static bool write_console_impl(int FD, std::string_view Data) {
+   SmallVector<wchar_t, 256> WideText;
+ 
+   // Fall back to ::write if it wasn't valid UTF-8.
+@@ -748,7 +747,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
+   // If this is a Windows console device, try re-encoding from UTF-8 to UTF-16
+   // and using WriteConsoleW. If that fails, fall back to plain write().
+   if (IsWindowsConsole)
+-    if (write_console_impl(FD, StringRef(Ptr, Size)))
++    if (write_console_impl(FD, std::string_view(Ptr, Size)))
+       return;
+ #endif
+ 
+@@ -919,7 +918,7 @@ raw_ostream &llvm::nulls() {
+ // File Streams
+ //===----------------------------------------------------------------------===//
+ 
+-raw_fd_stream::raw_fd_stream(StringRef Filename, std::error_code &EC)
++raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC)
+     : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways,
+                            sys::fs::FA_Write | sys::fs::FA_Read,
+                            sys::fs::OF_None),
+@@ -997,7 +996,7 @@ void buffer_ostream::anchor() {}
+ 
+ void buffer_unique_ostream::anchor() {}
+ 
+-Error llvm::writeToOutput(StringRef OutputFileName,
++Error llvm::writeToOutput(std::string_view OutputFileName,
+                           std::function<Error(raw_ostream &)> Write) {
+   if (OutputFileName == "-")
+     return Write(outs());
+diff --git a/llvm/lib/Support/xxhash.cpp b/llvm/lib/Support/xxhash.cpp
+index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85fa201073 100644
+--- a/llvm/lib/Support/xxhash.cpp
++++ b/llvm/lib/Support/xxhash.cpp
+@@ -84,11 +84,11 @@ static uint64_t XXH64_avalanche(uint64_t hash) {
+   return hash;
+ }
+ 
+-uint64_t llvm::xxHash64(StringRef Data) {
++uint64_t llvm::xxHash64(std::string_view Data) {
+   size_t Len = Data.size();
+   uint64_t Seed = 0;
+-  const unsigned char *P = Data.bytes_begin();
+-  const unsigned char *const BEnd = Data.bytes_end();
++  const unsigned char *P = reinterpret_cast<const unsigned char*>(Data.data());
++  const unsigned char *const BEnd = P + Data.size();
+   uint64_t H64;
+ 
+   if (Len >= 32) {
+@@ -144,7 +144,7 @@ uint64_t llvm::xxHash64(StringRef Data) {
+   return XXH64_avalanche(H64);
+ }
+ 
+-uint64_t llvm::xxHash64(ArrayRef<uint8_t> Data) {
++uint64_t llvm::xxHash64(span<const uint8_t> Data) {
+   return xxHash64({(const char *)Data.data(), Data.size()});
+ }
+ 
+@@ -394,7 +394,7 @@ static uint64_t XXH3_hashLong_64b(const uint8_t *input, size_t len,
+                         (uint64_t)len * PRIME64_1);
+ }
+ 
+-uint64_t llvm::xxh3_64bits(ArrayRef<uint8_t> data) {
++uint64_t llvm::xxh3_64bits(span<const uint8_t> data) {
+   auto *in = data.data();
+   size_t len = data.size();
+   if (len <= 16)
+diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
+index cc3244528f27e2bd7eaa385d8b7f49b2fbb7a3e6..b710ac07461ba58faa99cedeae7f209dc0f5902b 100644
+--- a/llvm/unittests/ADT/DenseMapTest.cpp
++++ b/llvm/unittests/ADT/DenseMapTest.cpp
+@@ -9,11 +9,11 @@
+ #include "llvm/ADT/DenseMap.h"
+ #include "llvm/ADT/DenseMapInfo.h"
+ #include "llvm/ADT/DenseMapInfoVariant.h"
+-#include "llvm/ADT/StringRef.h"
+ #include "gmock/gmock.h"
+ #include "gtest/gtest.h"
+ #include <map>
+ #include <set>
++#include <string_view>
+ #include <utility>
+ #include <variant>
+ 
+@@ -499,31 +499,6 @@ TEST(DenseMapCustomTest, ReserveTest) {
+   }
+ }
+ 
+-// Make sure DenseMap works with StringRef keys.
+-TEST(DenseMapCustomTest, StringRefTest) {
+-  DenseMap<StringRef, int> M;
+-
+-  M["a"] = 1;
+-  M["b"] = 2;
+-  M["c"] = 3;
+-
+-  EXPECT_EQ(3u, M.size());
+-  EXPECT_EQ(1, M.lookup("a"));
+-  EXPECT_EQ(2, M.lookup("b"));
+-  EXPECT_EQ(3, M.lookup("c"));
+-
+-  EXPECT_EQ(0, M.lookup("q"));
+-
+-  // Test the empty string, spelled various ways.
+-  EXPECT_EQ(0, M.lookup(""));
+-  EXPECT_EQ(0, M.lookup(StringRef()));
+-  EXPECT_EQ(0, M.lookup(StringRef("a", 0)));
+-  M[""] = 42;
+-  EXPECT_EQ(42, M.lookup(""));
+-  EXPECT_EQ(42, M.lookup(StringRef()));
+-  EXPECT_EQ(42, M.lookup(StringRef("a", 0)));
+-}
+-
+ // Key traits that allows lookup with either an unsigned or char* key;
+ // In the latter case, "a" == 0, "b" == 1 and so on.
+ struct TestDenseMapInfo {
+@@ -761,7 +736,7 @@ TEST(DenseMapCustomTest, VariantSupport) {
+ // Test that gTest prints map entries as pairs instead of opaque objects.
+ // See third-party/unittest/googletest/internal/custom/gtest-printers.h
+ TEST(DenseMapCustomTest, PairPrinting) {
+-  DenseMap<int, StringRef> Map = {{1, "one"}, {2, "two"}};
++  DenseMap<int, std::string_view> Map = {{1, "one"}, {2, "two"}};
+   EXPECT_EQ(R"({ (1, "one"), (2, "two") })", ::testing::PrintToString(Map));
+ }
+ 
+diff --git a/llvm/unittests/ADT/FunctionExtrasTest.cpp b/llvm/unittests/ADT/FunctionExtrasTest.cpp
+index fc856a976946bf6decda9b6724cac66afc7bdcd6..aff9d61c7f0d48834123b04b74a2e4f7c86a56d8 100644
+--- a/llvm/unittests/ADT/FunctionExtrasTest.cpp
++++ b/llvm/unittests/ADT/FunctionExtrasTest.cpp
+@@ -249,23 +249,23 @@ TEST(UniqueFunctionTest, Const) {
+ 
+   // Overloaded call operator correctly resolved.
+   struct ChooseCorrectOverload {
+-    StringRef operator()() { return "non-const"; }
+-    StringRef operator()() const { return "const"; }
++    std::string_view operator()() { return "non-const"; }
++    std::string_view operator()() const { return "const"; }
+   };
+-  unique_function<StringRef()> ChooseMutable = ChooseCorrectOverload();
++  unique_function<std::string_view()> ChooseMutable = ChooseCorrectOverload();
+   ChooseCorrectOverload A;
+   EXPECT_EQ("non-const", ChooseMutable());
+   EXPECT_EQ("non-const", A());
+-  unique_function<StringRef() const> ChooseConst = ChooseCorrectOverload();
++  unique_function<std::string_view() const> ChooseConst = ChooseCorrectOverload();
+   const ChooseCorrectOverload &X = A;
+   EXPECT_EQ("const", ChooseConst());
+   EXPECT_EQ("const", X());
+ }
+ 
+ // Test that overloads on unique_functions are resolved as expected.
+-std::string returns(StringRef) { return "not a function"; }
++std::string returns(std::string_view) { return "not a function"; }
+ std::string returns(unique_function<double()> F) { return "number"; }
+-std::string returns(unique_function<StringRef()> F) { return "string"; }
++std::string returns(unique_function<std::string_view()> F) { return "string"; }
+ 
+ TEST(UniqueFunctionTest, SFINAE) {
+   EXPECT_EQ("not a function", returns("boo!"));
+diff --git a/llvm/unittests/ADT/HashingTest.cpp b/llvm/unittests/ADT/HashingTest.cpp
+index 01a8a962b8e2e33ca8f189c049e9548ced42ec3a..62aff9c3b21eea785ca71c6e290c9c4f3a20ae00 100644
+--- a/llvm/unittests/ADT/HashingTest.cpp
++++ b/llvm/unittests/ADT/HashingTest.cpp
+@@ -295,7 +295,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) {
+ #endif
+   };
+   for (unsigned i = 0; i < sizeof(golden_data)/sizeof(*golden_data); ++i) {
+-    StringRef str = golden_data[i].s;
++    std::string_view str = golden_data[i].s;
+     hash_code hash = hash_combine_range(str.begin(), str.end());
+ #if 0 // Enable this to generate paste-able text for the above structure.
+     std::string member_str = "\"" + str.str() + "\",";
+diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
+index a97f2617cbf70783f3569709f7ee1bff03baebd2..7ed8670fd31ea2a14e6ba7f59a8ac8e35046890c 100644
+--- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
++++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
+@@ -12,7 +12,6 @@
+ 
+ #include "llvm/ADT/SmallPtrSet.h"
+ #include "llvm/ADT/PointerIntPair.h"
+-#include "llvm/ADT/STLExtras.h"
+ #include "llvm/Support/PointerLikeTypeTraits.h"
+ #include "gtest/gtest.h"
+ 
+diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp
+index 2f4df8afeafa592cb9616bb78feb4964187786f2..6cf14700b34739420cd3dc4ff8a4c16ce162f715 100644
+--- a/llvm/unittests/ADT/SmallStringTest.cpp
++++ b/llvm/unittests/ADT/SmallStringTest.cpp
+@@ -50,43 +50,43 @@ TEST_F(SmallStringTest, AssignRepeated) {
+ }
+ 
+ TEST_F(SmallStringTest, AssignIterPair) {
+-  StringRef abc = "abc";
++  std::string_view abc = "abc";
+   theString.assign(abc.begin(), abc.end());
+   EXPECT_EQ(3u, theString.size());
+   EXPECT_STREQ("abc", theString.c_str());
+ }
+ 
+-TEST_F(SmallStringTest, AssignStringRef) {
+-  StringRef abc = "abc";
++TEST_F(SmallStringTest, AssignStringView) {
++  std::string_view abc = "abc";
+   theString.assign(abc);
+   EXPECT_EQ(3u, theString.size());
+   EXPECT_STREQ("abc", theString.c_str());
+ }
+ 
+ TEST_F(SmallStringTest, AssignSmallVector) {
+-  StringRef abc = "abc";
++  std::string_view abc = "abc";
+   SmallVector<char, 10> abcVec(abc.begin(), abc.end());
+   theString.assign(abcVec);
+   EXPECT_EQ(3u, theString.size());
+   EXPECT_STREQ("abc", theString.c_str());
+ }
+ 
+-TEST_F(SmallStringTest, AssignStringRefs) {
++TEST_F(SmallStringTest, AssignStringViews) {
+   theString.assign({"abc", "def", "ghi"});
+   EXPECT_EQ(9u, theString.size());
+   EXPECT_STREQ("abcdefghi", theString.c_str());
+ }
+ 
+ TEST_F(SmallStringTest, AppendIterPair) {
+-  StringRef abc = "abc";
++  std::string_view abc = "abc";
+   theString.append(abc.begin(), abc.end());
+   theString.append(abc.begin(), abc.end());
+   EXPECT_EQ(6u, theString.size());
+   EXPECT_STREQ("abcabc", theString.c_str());
+ }
+ 
+-TEST_F(SmallStringTest, AppendStringRef) {
+-  StringRef abc = "abc";
++TEST_F(SmallStringTest, AppendStringView) {
++  std::string_view abc = "abc";
+   theString.append(abc);
+   theString.append(abc);
+   EXPECT_EQ(6u, theString.size());
+@@ -94,7 +94,7 @@ TEST_F(SmallStringTest, AppendStringRef) {
+ }
+ 
+ TEST_F(SmallStringTest, AppendSmallVector) {
+-  StringRef abc = "abc";
++  std::string_view abc = "abc";
+   SmallVector<char, 10> abcVec(abc.begin(), abc.end());
+   theString.append(abcVec);
+   theString.append(abcVec);
+@@ -102,11 +102,11 @@ TEST_F(SmallStringTest, AppendSmallVector) {
+   EXPECT_STREQ("abcabc", theString.c_str());
+ }
+ 
+-TEST_F(SmallStringTest, AppendStringRefs) {
++TEST_F(SmallStringTest, AppendStringViews) {
+   theString.append({"abc", "def", "ghi"});
+   EXPECT_EQ(9u, theString.size());
+   EXPECT_STREQ("abcdefghi", theString.c_str());
+-  StringRef Jkl = "jkl";
++  std::string_view Jkl = "jkl";
+   std::string Mno = "mno";
+   SmallString<4> Pqr("pqr");
+   const char *Stu = "stu";
+@@ -115,15 +115,15 @@ TEST_F(SmallStringTest, AppendStringRefs) {
+   EXPECT_STREQ("abcdefghijklmnopqrstu", theString.c_str());
+ }
+ 
+-TEST_F(SmallStringTest, StringRefConversion) {
+-  StringRef abc = "abc";
++TEST_F(SmallStringTest, StringViewConversion) {
++  std::string_view abc = "abc";
+   theString.assign(abc.begin(), abc.end());
+-  StringRef theStringRef = theString;
+-  EXPECT_EQ("abc", theStringRef);
++  std::string_view theStringView = theString;
++  EXPECT_EQ("abc", theStringView);
+ }
+ 
+ TEST_F(SmallStringTest, StdStringConversion) {
+-  StringRef abc = "abc";
++  std::string_view abc = "abc";
+   theString.assign(abc.begin(), abc.end());
+   std::string theStdString = std::string(theString);
+   EXPECT_EQ("abc", theStdString);
+@@ -149,29 +149,29 @@ TEST_F(SmallStringTest, Slice) {
+ TEST_F(SmallStringTest, Find) {
+   theString = "hello";
+   EXPECT_EQ(2U, theString.find('l'));
+-  EXPECT_EQ(StringRef::npos, theString.find('z'));
+-  EXPECT_EQ(StringRef::npos, theString.find("helloworld"));
++  EXPECT_EQ(std::string_view::npos, theString.find('z'));
++  EXPECT_EQ(std::string_view::npos, theString.find("helloworld"));
+   EXPECT_EQ(0U, theString.find("hello"));
+   EXPECT_EQ(1U, theString.find("ello"));
+-  EXPECT_EQ(StringRef::npos, theString.find("zz"));
++  EXPECT_EQ(std::string_view::npos, theString.find("zz"));
+   EXPECT_EQ(2U, theString.find("ll", 2));
+-  EXPECT_EQ(StringRef::npos, theString.find("ll", 3));
++  EXPECT_EQ(std::string_view::npos, theString.find("ll", 3));
+   EXPECT_EQ(0U, theString.find(""));
+ 
+   EXPECT_EQ(3U, theString.rfind('l'));
+-  EXPECT_EQ(StringRef::npos, theString.rfind('z'));
+-  EXPECT_EQ(StringRef::npos, theString.rfind("helloworld"));
++  EXPECT_EQ(std::string_view::npos, theString.rfind('z'));
++  EXPECT_EQ(std::string_view::npos, theString.rfind("helloworld"));
+   EXPECT_EQ(0U, theString.rfind("hello"));
+   EXPECT_EQ(1U, theString.rfind("ello"));
+-  EXPECT_EQ(StringRef::npos, theString.rfind("zz"));
++  EXPECT_EQ(std::string_view::npos, theString.rfind("zz"));
+ 
+   EXPECT_EQ(2U, theString.find_first_of('l'));
+   EXPECT_EQ(1U, theString.find_first_of("el"));
+-  EXPECT_EQ(StringRef::npos, theString.find_first_of("xyz"));
++  EXPECT_EQ(std::string_view::npos, theString.find_first_of("xyz"));
+ 
+   EXPECT_EQ(1U, theString.find_first_not_of('h'));
+   EXPECT_EQ(4U, theString.find_first_not_of("hel"));
+-  EXPECT_EQ(StringRef::npos, theString.find_first_not_of("hello"));
++  EXPECT_EQ(std::string_view::npos, theString.find_first_not_of("hello"));
+ 
+   theString = "hellx xello hell ello world foo bar hello";
+   EXPECT_EQ(36U, theString.find("hello"));
+diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp
+index 137dd43b473068eae34b39edc4b9b8b9633bab95..7029038d18d433cef987bedbfa4fda269b24fb8f 100644
+--- a/llvm/unittests/ADT/SmallVectorTest.cpp
++++ b/llvm/unittests/ADT/SmallVectorTest.cpp
+@@ -11,10 +11,10 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/ADT/SmallVector.h"
+-#include "llvm/ADT/ArrayRef.h"
+ #include "llvm/Support/Compiler.h"
+ #include "gtest/gtest.h"
+ #include <list>
++#include <span>
+ #include <stdarg.h>
+ 
+ using namespace llvm;
+@@ -252,11 +252,11 @@ TYPED_TEST(SmallVectorTest, ConstructorIterTest) {
+ }
+ 
+ // Constructor test.
+-TYPED_TEST(SmallVectorTest, ConstructorFromArrayRefSimpleTest) {
+-  SCOPED_TRACE("ConstructorFromArrayRefSimpleTest");
++TYPED_TEST(SmallVectorTest, ConstructorFromSpanSimpleTest) {
++  SCOPED_TRACE("ConstructorFromSpanSimpleTest");
+   std::array<Constructable, 3> StdArray = {Constructable(1), Constructable(2),
+                                            Constructable(3)};
+-  ArrayRef<Constructable> Array = StdArray;
++  span<const Constructable> Array = StdArray;
+   auto &V = this->theVector;
+   V = SmallVector<Constructable, 4>(Array);
+   assertValuesInOrder(V, 3u, 1, 2, 3);
+@@ -1129,24 +1129,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) {
+   EXPECT_EQ(NestedV[0][0][0], 42);
+ }
+ 
+-TEST(SmallVectorTest, InitializerList) {
+-  SmallVector<int, 2> V1 = {};
+-  EXPECT_TRUE(V1.empty());
+-  V1 = {0, 0};
+-  EXPECT_TRUE(ArrayRef(V1).equals({0, 0}));
+-  V1 = {-1, -1};
+-  EXPECT_TRUE(ArrayRef(V1).equals({-1, -1}));
+-
+-  SmallVector<int, 2> V2 = {1, 2, 3, 4};
+-  EXPECT_TRUE(ArrayRef(V2).equals({1, 2, 3, 4}));
+-  V2.assign({4});
+-  EXPECT_TRUE(ArrayRef(V2).equals({4}));
+-  V2.append({3, 2});
+-  EXPECT_TRUE(ArrayRef(V2).equals({4, 3, 2}));
+-  V2.insert(V2.begin() + 1, 5);
+-  EXPECT_TRUE(ArrayRef(V2).equals({4, 5, 3, 2}));
+-}
+-
+ TEST(SmallVectorTest, ToVector) {
+   {
+     std::vector<char> v = {'a', 'b', 'c'};
+@@ -1183,10 +1165,10 @@ private:
+   To T;
+ };
+ 
+-TEST(SmallVectorTest, ConstructFromArrayRefOfConvertibleType) {
++TEST(SmallVectorTest, ConstructFromSpanOfConvertibleType) {
+   To to1{1}, to2{2}, to3{3};
+   std::vector<From> StdVector = {From(to1), From(to2), From(to3)};
+-  ArrayRef<From> Array = StdVector;
++  span<const From> Array = StdVector;
+   {
+     llvm::SmallVector<To> Vector(Array);
+ 
+diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp
+index f9b138e9a472137139397d9cae76823711594211..7f10b3d7d3a8894b1ab0ac660268d94a8b89e082 100644
+--- a/llvm/unittests/ADT/StringMapTest.cpp
++++ b/llvm/unittests/ADT/StringMapTest.cpp
+@@ -7,8 +7,6 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/ADT/StringMap.h"
+-#include "llvm/ADT/STLExtras.h"
+-#include "llvm/ADT/Twine.h"
+ #include "llvm/Support/DataTypes.h"
+ #include "gtest/gtest.h"
+ #include <limits>
+@@ -43,10 +41,10 @@ protected:
+     // Lookup tests
+     EXPECT_FALSE(testMap.contains(testKey));
+     EXPECT_EQ(0u, testMap.count(testKey));
+-    EXPECT_EQ(0u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
++    EXPECT_EQ(0u, testMap.count(std::string_view(testKeyFirst, testKeyLength)));
+     EXPECT_EQ(0u, testMap.count(testKeyStr));
+     EXPECT_TRUE(testMap.find(testKey) == testMap.end());
+-    EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
++    EXPECT_TRUE(testMap.find(std::string_view(testKeyFirst, testKeyLength)) ==
+                 testMap.end());
+     EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end());
+   }
+@@ -67,10 +65,10 @@ protected:
+     // Lookup tests
+     EXPECT_TRUE(testMap.contains(testKey));
+     EXPECT_EQ(1u, testMap.count(testKey));
+-    EXPECT_EQ(1u, testMap.count(StringRef(testKeyFirst, testKeyLength)));
++    EXPECT_EQ(1u, testMap.count(std::string_view(testKeyFirst, testKeyLength)));
+     EXPECT_EQ(1u, testMap.count(testKeyStr));
+     EXPECT_TRUE(testMap.find(testKey) == testMap.begin());
+-    EXPECT_TRUE(testMap.find(StringRef(testKeyFirst, testKeyLength)) ==
++    EXPECT_TRUE(testMap.find(std::string_view(testKeyFirst, testKeyLength)) ==
+                 testMap.begin());
+     EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin());
+   }
+@@ -108,10 +106,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) {
+ 
+   // Lookup tests
+   EXPECT_EQ(0u, constTestMap.count(testKey));
+-  EXPECT_EQ(0u, constTestMap.count(StringRef(testKeyFirst, testKeyLength)));
++  EXPECT_EQ(0u, constTestMap.count(std::string_view(testKeyFirst, testKeyLength)));
+   EXPECT_EQ(0u, constTestMap.count(testKeyStr));
+   EXPECT_TRUE(constTestMap.find(testKey) == constTestMap.end());
+-  EXPECT_TRUE(constTestMap.find(StringRef(testKeyFirst, testKeyLength)) ==
++  EXPECT_TRUE(constTestMap.find(std::string_view(testKeyFirst, testKeyLength)) ==
+               constTestMap.end());
+   EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end());
+ }
+@@ -251,7 +249,7 @@ TEST_F(StringMapTest, StringMapEntryTest) {
+   MallocAllocator Allocator;
+   StringMap<uint32_t>::value_type *entry =
+       StringMap<uint32_t>::value_type::create(
+-          StringRef(testKeyFirst, testKeyLength), Allocator, 1u);
++          std::string_view(testKeyFirst, testKeyLength), Allocator, 1u);
+   EXPECT_STREQ(testKey, entry->first().data());
+   EXPECT_EQ(1u, entry->second);
+   entry->Destroy(Allocator);
+@@ -261,7 +259,7 @@ TEST_F(StringMapTest, StringMapEntryTest) {
+ TEST_F(StringMapTest, InsertTest) {
+   SCOPED_TRACE("InsertTest");
+   testMap.insert(StringMap<uint32_t>::value_type::create(
+-      StringRef(testKeyFirst, testKeyLength), testMap.getAllocator(), 1u));
++      std::string_view(testKeyFirst, testKeyLength), testMap.getAllocator(), 1u));
+   assertSingleItemMap();
+ }
+ 
+@@ -330,10 +328,10 @@ TEST_F(StringMapTest, IterMapKeysVector) {
+   Map["C"] = 3;
+   Map["D"] = 3;
+ 
+-  std::vector<StringRef> Keys{Map.keys().begin(), Map.keys().end()};
++  std::vector<std::string_view> Keys{Map.keys().begin(), Map.keys().end()};
+   llvm::sort(Keys);
+ 
+-  std::vector<StringRef> Expected{{"A", "B", "C", "D"}};
++  std::vector<std::string_view> Expected{{"A", "B", "C", "D"}};
+   EXPECT_EQ(Expected, Keys);
+ }
+ 
+@@ -347,7 +345,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) {
+   auto Keys = to_vector<4>(Map.keys());
+   llvm::sort(Keys);
+ 
+-  SmallVector<StringRef, 4> Expected = {"A", "B", "C", "D"};
++  SmallVector<std::string_view, 4> Expected = {"A", "B", "C", "D"};
+   EXPECT_EQ(Expected, Keys);
+ }
+ 
+@@ -389,13 +387,13 @@ private:
+ TEST_F(StringMapTest, MoveOnly) {
+   StringMap<MoveOnly> t;
+   t.insert(std::make_pair("Test", MoveOnly(42)));
+-  StringRef Key = "Test";
++  std::string_view Key = "Test";
+   StringMapEntry<MoveOnly>::create(Key, t.getAllocator(), MoveOnly(42))
+       ->Destroy(t.getAllocator());
+ }
+ 
+ TEST_F(StringMapTest, CtorArg) {
+-  StringRef Key = "Test";
++  std::string_view Key = "Test";
+   MallocAllocator Allocator;
+   StringMapEntry<MoveOnly>::create(Key, Allocator, Immovable())
+       ->Destroy(Allocator);
+@@ -580,7 +578,7 @@ TEST(StringMapCustomTest, InitialSizeTest) {
+     CountCtorCopyAndMove::Copy = 0;
+     for (int i = 0; i < Size; ++i)
+       Map.insert(std::pair<std::string, CountCtorCopyAndMove>(
+-          std::piecewise_construct, std::forward_as_tuple(Twine(i).str()),
++          std::piecewise_construct, std::forward_as_tuple(std::to_string(i)),
+           std::forward_as_tuple(i)));
+     // After the initial move, the map will move the Elts in the Entry.
+     EXPECT_EQ((unsigned)Size * 2, CountCtorCopyAndMove::Move);
+@@ -649,7 +647,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) {
+   else
+     LargeValue = std::numeric_limits<unsigned>::max() + 1ULL;
+   StringMapEntry<int> LargeEntry(LargeValue);
+-  StringRef Key = LargeEntry.getKey();
++  std::string_view Key = LargeEntry.getKey();
+   EXPECT_EQ(LargeValue, Key.size());
+ 
+   // Test that the entry can hold at least max size_t.
+diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp
+index 6e75fbae0969ba1bf0a76c4d79a123e405a8dae7..3b07d344f15a555f11ad5f8177a0a65b8a4fa472 100644
+--- a/llvm/unittests/Support/ConvertUTFTest.cpp
++++ b/llvm/unittests/Support/ConvertUTFTest.cpp
+@@ -7,7 +7,6 @@
+ //===----------------------------------------------------------------------===//
+ 
+ #include "llvm/Support/ConvertUTF.h"
+-#include "llvm/ADT/ArrayRef.h"
+ #include "gtest/gtest.h"
+ #include <string>
+ #include <vector>
+@@ -17,7 +16,7 @@ using namespace llvm;
+ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+-  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
++  span<const char> Ref(Src, sizeof(Src) - 1);
+   std::string Result;
+   bool Success = convertUTF16ToUTF8String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -29,7 +28,7 @@ TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF32) static const char Src[] =
+       "\xFF\xFE\x00\x00\xA0\x0C\x00\x00\x5F\x00\x00\x00\xA0\x0C\x00\x00";
+-  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
++  span<const char> Ref(Src, sizeof(Src) - 1);
+   std::string Result;
+   bool Success = convertUTF32ToUTF8String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -40,7 +39,7 @@ TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+ TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF16) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
+-  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
++  span<const char> Ref(Src, sizeof(Src) - 1);
+   std::string Result;
+   bool Success = convertUTF16ToUTF8String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -52,7 +51,7 @@ TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF32) static const char Src[] =
+       "\x00\x00\xFE\xFF\x00\x00\x0C\xA0\x00\x00\x00\x5F\x00\x00\x0C\xA0";
+-  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
++  span<const char> Ref(Src, sizeof(Src) - 1);
+   std::string Result;
+   bool Success = convertUTF32ToUTF8String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -63,7 +62,7 @@ TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+ TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
+   // Src is the look of disapproval.
+   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
+-  StringRef Ref(Src, sizeof(Src) - 1);
++  std::string_view Ref(Src, sizeof(Src) - 1);
+   SmallVector<UTF16, 5> Result;
+   bool Success = convertUTF8ToUTF16String(Ref, Result);
+   EXPECT_TRUE(Success);
+@@ -75,38 +74,38 @@ TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
+ 
+ TEST(ConvertUTFTest, OddLengthInput) {
+   std::string Result;
+-  bool Success = convertUTF16ToUTF8String(ArrayRef("xxxxx", 5), Result);
++  bool Success = convertUTF16ToUTF8String(span<const char>("xxxxx", 5), Result);
+   EXPECT_FALSE(Success);
+ }
+ 
+ TEST(ConvertUTFTest, Empty) {
+   std::string Result;
+   bool Success =
+-      convertUTF16ToUTF8String(llvm::ArrayRef<char>(std::nullopt), Result);
++      convertUTF16ToUTF8String(span<const char>(), Result);
+   EXPECT_TRUE(Success);
+   EXPECT_TRUE(Result.empty());
+ }
+ 
+ TEST(ConvertUTFTest, HasUTF16BOM) {
+-  bool HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xff\xfe", 2));
++  bool HasBOM = hasUTF16ByteOrderMark("\xff\xfe");
+   EXPECT_TRUE(HasBOM);
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff", 2));
++  HasBOM = hasUTF16ByteOrderMark("\xfe\xff");
+   EXPECT_TRUE(HasBOM);
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff ", 3));
++  HasBOM = hasUTF16ByteOrderMark("\xfe\xff ");
+   EXPECT_TRUE(HasBOM); // Don't care about odd lengths.
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe\xff\x00asdf", 6));
++  HasBOM = hasUTF16ByteOrderMark("\xfe\xff\x00asdf");
+   EXPECT_TRUE(HasBOM);
+ 
+-  HasBOM = hasUTF16ByteOrderMark(std::nullopt);
++  HasBOM = hasUTF16ByteOrderMark("");
+   EXPECT_FALSE(HasBOM);
+-  HasBOM = hasUTF16ByteOrderMark(ArrayRef("\xfe", 1));
++  HasBOM = hasUTF16ByteOrderMark("\xfe");
+   EXPECT_FALSE(HasBOM);
+ }
+ 
+ TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
+   // Src is the look of disapproval.
+   alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+-  ArrayRef<UTF16> SrcRef = ArrayRef((const UTF16 *)Src, 4);
++  span<const UTF16> SrcRef((const UTF16 *)Src, 4);
+   std::string Result;
+   bool Success = convertUTF16ToUTF8String(SrcRef, Result);
+   EXPECT_TRUE(Success);
+@@ -123,7 +122,7 @@ TEST(ConvertUTFTest, ConvertUTF8toWide) {
+   std::wstring Expected(L"\x0ca0_\x0ca0");
+   EXPECT_EQ(Expected, Result);
+   Result.clear();
+-  Success = ConvertUTF8toWide(StringRef(Src, 7), Result);
++  Success = ConvertUTF8toWide(Src, Result);
+   EXPECT_TRUE(Success);
+   EXPECT_EQ(Expected, Result);
+ }
+@@ -172,7 +171,7 @@ struct ConvertUTFResultContainer {
+ };
+ 
+ std::pair<ConversionResult, std::vector<unsigned>>
+-ConvertUTF8ToUnicodeScalarsLenient(StringRef S) {
++ConvertUTF8ToUnicodeScalarsLenient(std::string_view S) {
+   const UTF8 *SourceStart = reinterpret_cast<const UTF8 *>(S.data());
+ 
+   const UTF8 *SourceNext = SourceStart;
+@@ -189,7 +188,7 @@ ConvertUTF8ToUnicodeScalarsLenient(StringRef S) {
+ }
+ 
+ std::pair<ConversionResult, std::vector<unsigned>>
+-ConvertUTF8ToUnicodeScalarsPartialLenient(StringRef S) {
++ConvertUTF8ToUnicodeScalarsPartialLenient(std::string_view S) {
+   const UTF8 *SourceStart = reinterpret_cast<const UTF8 *>(S.data());
+ 
+   const UTF8 *SourceNext = SourceStart;
+@@ -207,7 +206,7 @@ ConvertUTF8ToUnicodeScalarsPartialLenient(StringRef S) {
+ 
+ ::testing::AssertionResult
+ CheckConvertUTF8ToUnicodeScalars(ConvertUTFResultContainer Expected,
+-                                 StringRef S, bool Partial = false) {
++                                 std::string_view S, bool Partial = false) {
+   ConversionResult ErrorCode;
+   std::vector<unsigned> Decoded;
+   if (!Partial)
+@@ -302,7 +301,7 @@ TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {
+   // U+0000 NULL
+   EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
+       ConvertUTFResultContainer(conversionOK).withScalars(0x0000),
+-      StringRef("\x00", 1)));
++      std::string_view("\x00", 1)));
+ 
+   // U+0080 PADDING CHARACTER
+   EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
+@@ -1076,7 +1075,7 @@ TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {
+   // U+0000 NULL
+   EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
+       ConvertUTFResultContainer(conversionOK).withScalars(0x0000),
+-      StringRef("\x00", 1)));
++      std::string_view("\x00", 1)));
+ 
+   // Overlong sequences of the above.
+   EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
+diff --git a/llvm/unittests/Support/xxhashTest.cpp b/llvm/unittests/Support/xxhashTest.cpp
+index 7d78de6772b5159459572fe11633c76d04b86907..d61a5acd21f4d685ca631d3adb20c2649e050bc3 100644
+--- a/llvm/unittests/Support/xxhashTest.cpp
++++ b/llvm/unittests/Support/xxhashTest.cpp
+@@ -12,7 +12,7 @@
+ using namespace llvm;
+ 
+ TEST(xxhashTest, Basic) {
+-  EXPECT_EQ(0xef46db3751d8e999U, xxHash64(StringRef()));
++  EXPECT_EQ(0xef46db3751d8e999U, xxHash64(std::string_view()));
+   EXPECT_EQ(0x33bf00a859c4ba3fU, xxHash64("foo"));
+   EXPECT_EQ(0x48a37c90ad27a659U, xxHash64("bar"));
+   EXPECT_EQ(0x69196c1b3af0bff9U,
+@@ -31,7 +31,7 @@ TEST(xxhashTest, xxh3) {
+   }
+ 
+ #define F(len, expected)                                                       \
+-  EXPECT_EQ(uint64_t(expected), xxh3_64bits(ArrayRef(a, size_t(len))))
++  EXPECT_EQ(uint64_t(expected), xxh3_64bits(span(a, size_t(len))))
+   F(0, 0x2d06800538d394c2);
+   F(1, 0xd0d496e05c553485);
+   F(2, 0x84d625edb7055eac);