Commit Graph

31 Commits

Author SHA1 Message Date
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Minhyuk Kim
e924cf6104 Replace usages of StringRef.find(Key) != StringRef::npos to StringRef.contains(Key) 2021-02-04 00:42:04 +09:00
Xi Ge
950eb74e67 ABI Checker: use lower-cased decl keywords to be consistent with source. NFC 2020-09-12 10:35:03 -07:00
Xi Ge
de05cbc350 swift-module-digester: more refactoring to exclude empty values in the dump. 2018-09-27 11:34:56 -07:00
Xi Ge
e4388af6be swift-module-digester: refactor the ABI/API diagnostics to use DiagnosticEngine. NFC (#18957)
Before this patch, we used to define tooling-specific diagnostics. With adding more
checking logics, we found this mechanism hard to extend. This patch
eliminates the home-made diagnostics model to use the one from compiler, which provides
several benefits: less boiler-templates, better integration with DiagnosticConsumer,
and easy ordering of detected issues.
2018-08-24 13:11:32 -07:00
Brent Royal-Gordon
88ac6f11a2 Add error for invalid SDKNodeKind 2018-08-17 00:27:38 -07:00
Xi Ge
c23d1a89a4 migrator: ensure we update unresolved member access correctly to global names. rdar://41658300 2018-06-29 17:29:53 -07:00
Xi Ge
4ed9f9a9a6 migrator: support the migration from member variables to global ones. rdar://41658300 2018-06-29 16:35:51 -07:00
Xi Ge
7312fea3b2 migrator: emit error messages when migration scripts are missing.
We used to assert migration scripts exist. This patch further
decouples these scripts and the compiler by treating missing scripts
as a regular compiler error.

Related: rdar://40538097
2018-05-25 11:25:32 -07:00
Xi Ge
343d84ba35 migrator: handle argument renames when a global function is hoisted to a static member function. rdar://40145590 2018-05-14 11:33:25 -07:00
Xi Ge
82a2c2c644 migrator: ignore migration scripts with underscored new names. rdar://39877447
Updating something to underscored names is hardly correct. This patch
disallows picking up such migration scripts.
2018-05-01 16:06:06 -07:00
Xi Ge
53c9f1aaa9 swift-api-digester: add a new action to dump name correction template.
Rename detection in the tool may not reflect overlay additions; thus we
mistakes a new name to be an underscored one. This new action searches
migration scripts for suspicious ones and generates a template for us to
specify the correct names.
2018-04-19 18:01:01 -07:00
Xi Ge
4c4e4d2b79 migrator: handle simple attribute assignment and reference.
This patch migrates simple attribute assignment and reference when the
attribute used to be of type String and later became StringRepresentable struct.

Related: rdar://38192995
2018-04-12 11:54:28 -07:00
Xi Ge
72f49e2351 swift-api-digester: separate internal and external names for node kinds. NFC 2018-04-05 15:38:17 -07:00
Xi Ge
824aaa11e2 swift-api-digester: detect the move of static members only.
This patch restricts the detection of moved members to be static members,
since only in this case we need to update qualified access to
them. The move of instance members will be either handled by rename or
we don't need to update anything at all.

Additionally, this patch introduces a sub-kind of type member diff item
called qualified replacement to describe the aforementioned case. However,
the migrator part has not started to honor this sub-kind yet.

rdar://32466196
2017-05-31 11:47:27 -07:00
Xi Ge
d1b0e67620 swift-api-digester: teach the tool do detect APINotes' moving one member variable/method to another type. (#9985)
Different from type hoist that moves global variables to static member
variables, we've also seen member variables being moved among different
types via apinotes. Swift-api-digester should be able to detect such
case so that migrator can handle them properly.

rdar://32466196
2017-05-30 14:23:32 -07:00
Xi Ge
1019396663 [migrator] Handle getter function to property change in function overrides. (#9844)
We used to only migrate them in call sites, e.g. changing from
``p.getHeight()`` to ``p.Height``. However, with experimenting on more real-world
projects, we realize migrating overrides is equally important.

rdar://32265583
2017-05-22 16:11:53 -07:00
Xi Ge
ff2622734e migrator: handle the special migration cases of NSOpenGLSetOption/NSOpenGLGetOption. rdar://32178753 (#9591) 2017-05-14 13:00:03 -07:00
Xi Ge
24de53fcdf migrator: Add an API diff kind for specially handled cases. (#9585)
This item is to associate a usr with a special case Id, however, it's
up to the migrator to interpret the special case Id and apply proper
transformations.
2017-05-14 10:43:06 -07:00
Xi Ge
65b9043eb1 migrator: handle function hoist API changes and several its varieties. rdar://31234806 (#9544) 2017-05-12 21:34:06 -07:00
Xi Ge
beb5347f95 [Migrator] During de-serialization, remove duplicated API diff items from the store. (#9239) 2017-05-03 16:48:44 -07:00
Nathan Hawes
8ad6aa4e0d [migrator] Add pass for API type changes
This handles optionality changes and type rewrites in function param and return types and constructor param and failability types.
Resolves rdar://problem/31766010
2017-04-27 22:19:52 -07:00
Xi Ge
539cba9479 [Migrator] Handle enum modernization changes. (#9077) 2017-04-27 14:08:31 -07:00
Xi Ge
2a2731a797 migrator: add a flag to print incoming usrs to the API diff data store to facilitate testing. NFC (#8969) 2017-04-24 13:53:55 -07:00
Xi Ge
5b86c72493 migrator: support simple variable renames. rda://31766131 2017-04-24 12:36:30 -07:00
Xi Ge
e57232dbe9 [migrator] Add a viewer utility for child indices to facilitate access. NFC (#8925) 2017-04-21 15:15:58 -07:00
Xi Ge
acf4f6e27e [Migrator] Add stubs for API change data files. (#8844)
These data files are installed into runtime resource directory so that migrator can pick them automatically according to specific platforms. To support testing, a front-end option -api-diff-data-file can be used to specify the data file to use and it will overwrite the default ones from resource directory.
2017-04-18 15:20:57 -07:00
Xi Ge
ba33fd6236 swift-api-digester: Add a data structure APIDiffItemStore. (#8794)
This structure serves multiple purposes:
	a. Allow migrator to speak in the same language with swift-api-digester in terms of API changes.
	b. Serialize/Deserialize detected API change items in JSON format.
	c. Manage memory after deserializing API change items.
	d. Facilitate look up by USRs of APIs under migration.
The structure is tested by round-trip serialization and deserialization.
2017-04-17 13:04:02 -07:00
Xi Ge
dbb71698e9 swift-api-digester: Extract/Expose API change descriptors to libIDE to allow visibility from libMigrator. NFC (#8766) 2017-04-13 18:31:41 -07:00