Commit Graph

19 Commits

Author SHA1 Message Date
Rintaro Ishizaki
d4db99ce9d [Parse] Remove unnecessary dependencies to Parser.h
C++ swift::Parser is going to be replaced with SwiftParser+ASTGen.
Direct dependencies to it should be removed. Before that, remove
unnecessary '#include "swift/Parse/Parser.h"' to clarify what actually
depends on 'swift::Parser'.

Split 'swift::parseDeclName()' et al. into the dedicated files.
2024-11-02 01:23:59 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
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
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Saleem Abdulrasool
910fbee14e gardening: make c++98-compat-extra-semi an error
This cleans up 90 instances of this warning and reduces the build spew
when building on Linux.  This helps identify actual issues when
building which can get lost in the stream of warning messages.  It also
helps restore the ability to build the compiler with gcc.
2021-11-27 11:40:17 -08:00
Becca Royal-Gordon
e22b6d6ee4 Handle subscripts in formDeclNameRef()
In particular, we were unconditionally dropping argument labels on accessors; now we only do that for property accessors, not subscript accessors.

Doing this unconditionally causes ClangImporter failures when a method parameter is called “subscript” (really!), so this behavior is enabled only by the caller’s request.
2021-03-24 14:55:06 -07:00
Becca Royal-Gordon
8d0040fa2b Improve access note error handling
The LLVM rebranch added an “AllowUnknownKeys” setting to llvm::yaml::Input, which lets us rip out a lot of marginal code and encourages a broader rework of access note error diagnosis:

• Access note warnings and errors are now diagnosed as they’re found during YAML parsing
• They now have proper SourceLocs inside the .accessnotes file
• They’re now tested using -verify-additional-file instead of FileCheck
• A lot of gross duct tape is now gone
2021-02-10 00:29:34 -08:00
Becca Royal-Gordon
d8c34638ec Update access note serialization for LLVM rebranch 2021-02-09 19:00:54 -08:00
Becca Royal-Gordon
01fa74510e [NFC] Clean up access note code
• Rename properties for greater consistency with the YAML file
• Rename AccessNotes -> AccessNotesFile
• Add doc comments
• Miscellaneous comment/style improvements.
2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
bf13139495 Allow unknown keys in access notes
LLVM’s YAML support wants to show a hard error if an unknown string appears in an access note. Instead, emit a remark but load the parts of the access note we do understand to allow for future expansion of access notes.
2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
899d1a47e5 [NFC] Centralize ObjCSelector helper 2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
e42294737f Handle access note I/O and parse errors 2021-02-09 14:17:35 -08:00
Becca Royal-Gordon
af55bbcede [NFC] Correct copyright years 2021-02-09 14:17:34 -08:00
Becca Royal-Gordon
feca4e6391 Let access notes apply to accessors
`Name: ‘getter:Context.property()’` now applies an access note to a getter of Context.property, and `Name: ‘setter:Context.property(_:)’` applies one to its setter. Additionally, access notes without `getter:` or `setter:` now cannot apply to accessors.
2021-02-09 14:17:34 -08:00
Becca Royal-Gordon
9ca2fbdb74 Clarify behavior of access note with ObjCName only
An access note with an ObjCName property but no ObjC property now implicitly sets ObjC to true. ObjC: false with an ObjCName is still illegal.
2021-02-09 14:17:34 -08:00
Becca Royal-Gordon
bde58ed167 Flatten access note format
Rather than nesting notes for members inside a note for the type, access note files now contain a flat list of notes with parent names embedded in the `Name` property.

Fixes rdar://71872830.

fixup spacing in access notes
2021-02-09 14:17:34 -08:00
Becca Royal-Gordon
ccf244b89b Add ability to load access notes 2021-02-09 14:17:33 -08:00