Commit Graph

59 Commits

Author SHA1 Message Date
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
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Alex Hoppen
873ed19786 [SourceKit] Add the raw doc comment to the cursor info response
SourceKit-LSP currently parses the XML comment to generate Markdown again but round-tripping a (probably markdown) doc comment to XML to Markdown is lossy in many cases and unnecessary work. Include the comment as it is spelled in source in the cursor info response so that sourcekit-lsp can display it.

Part of rdar://120685874
2024-02-24 08:41:08 -08: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
Saleem Abdulrasool
49a5098db4 build: update for cmark build revamp and split the build
Extricate cmark from the unified build system. This is preparatory work
to support building CMark GFM with dynamic linkage for sharing it across
swift-markdown and the compiler. It also simplifies the build logic for
the unified build.
2024-01-17 08:54:36 -08:00
Alex Langford
62200c14bf [Markup] Fix warning in measureIndentation
The primary goal is to fix this warning:

$PROJECT_PATH/swift-project/swift/lib/Markup/LineList.cpp:46:10: warning: variable 'Col' set but not used [-Wunused-but-set-variable]
  size_t Col = 0;

I also rewrote the implementation to use StringRef functionality instead
of manually walking over the characters.
2023-10-13 14:11:07 -07: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
Victoria Mitchell
0639a9e2fb review: rename Attribute to InlineAttributes 2022-07-21 17:22:41 -06:00
Victoria Mitchell
76fe621c1f markup: add support for swift-cmark inline attributes
rdar://96830173
2022-07-21 08:13:07 -06:00
Victoria Mitchell
57475013c9 use newer cmark node kind names
the older names were kept in the cmark header for compatibility, but
these are the ones that are actually defined in the main enum
2022-07-21 08:13:06 -06:00
Victoria Mitchell
f3cc9eb012 use new static-define definition 2022-03-16 14:58:25 -06:00
Victoria Mitchell
455cdbc5a7 use swift-cmark/gfm instead of /main 2022-03-16 14:56:21 -06:00
Evan Wilde
2c04be2724 llvm::StringRef compare_lower -> compare_insensitive
The `compare_lower` API was replaced with `compare_insensitive` in llvm
commit 2e4a2b8430aca6f7aef8100a5ff81ca0328d03f9.

git clang-format ran.

(cherry picked from commit aca2de95ee)
2021-07-02 10:55:17 -07:00
Ben Barham
52de30ce1f [Gardening] Do not store start/end line in SingleRawComment
The start and end lines were only used while constructing the comments,
so move the line tracking into that method instead of storing it in each
comment.
2021-04-16 08:10:49 +10:00
Tony Allevato
bbd000ff5a Fix Windows CR-LF detection in libMarkup. 2020-06-15 13:52:43 -07:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Owen Voorhees
d68089dcf9 [Diagnostics] Add a basic terminal markdown printer for educational notes
Currently the printer only supports the subset of markdown used by
educational notes. It bolds headers, improves the appearance of lists
and horizontal rules, and does basic indenting of blockquotes and
code blocks.
2020-03-05 18:04:32 -08:00
Ashley Garland
edd7fdb73f Fix bug in LineList end locations
LineList Line end locations were getting cut off too early because they were
based on the untrimmed (w.r.t. comment markers) locations, instead of the
trimmed one.
2020-02-17 16:21:01 -08:00
Ashley Garland
7a3a0a9e23 Symbol graph support
Adds a tool `swift-symbolgraph-extract` that reads an existing Swift
module and prints a platform- and language-agnostic JSON description of
the module, primarly for documentation.

Adds a small sub-library `SymbolGraphGen` which houses the core
implementation for collecting relevant information about declarations.
The main entry point is integrated directly into the driver as a mode:
the tool is meant to be run outside of the normal edit-compile-run/test
workflow to avoid impacting build times.

Along with common options for other tools, unique options include
`pretty-print` for debugging, and a `minimum-access-level` options for
including internal documentation.

A symbol graph is a directed graph where the nodes are symbols in a
module and the edges are relationships between them. For example, a
`struct S` may have a member `var x`. The graph would have two nodes for
`S` and `x`, and one "member-of" relationship edge. Other relationship
kinds include "inherits-from" or "conforms to". The data format for a
symbol graph is still under development and may change without notice
until a specificiation and versioning scheme is published.

Various aspects about a symbol are recorded in the nodes, such as
availability, documentation comments, or data needed for printing the
shapes of declarations without having to understand specifics about the
langauge.

Implicit and public-underscored stdlib declarations are not included by
default.

rdar://problem/55346798
2020-01-10 09:53:37 -08:00
Saleem Abdulrasool
9934532e07 cmake: switch host libraries to use target_link_libraries
This is a follow up to the discussion on #22740 to switch the host
libraries to use the `target_link_libraries` rather than the
`LINK_LIBRARIES` special handling.  This allows the dependency to be
properly tracked by CMake and allows us to use the more modern syntax.
2019-02-22 15:28:07 -08:00
Michael Gottesman
a761d7c0ba Revert "Revert "Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library"""
This reverts commit 121f5b64be.

Sorry to revert this again. This commit makes some pretty big changes. After
messing with the merge-conflict created by this internally, I did not feel
comfortable landing this now. I talked with Saleem and he agreed with me that
this was the right thing to do.
2018-11-06 13:24:00 -08:00
Saleem Abdulrasool
121f5b64be Revert "Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library""
This reverts commit 103f9a8246.
2018-11-05 14:37:40 -08:00
Xi Ge
103f9a8246 Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library" 2018-11-02 12:49:07 -07:00
Saleem Abdulrasool
39dde93c88 add_swift_host_library: rename LINK_LIBRARIES to LINK_LIBS 2018-10-31 12:46:31 -07:00
Saleem Abdulrasool
951b7fb356 Markup: add CMARK_STATIC_DEFINE to CFLAGS
This is needed to link against cmark properly for Windows.  Without this CMark
behaves as a shared library and cannot be linked to statically.
2018-10-29 21:52:05 -07:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
PhilArmstrong
534a5e6b9f Fix unallocated memory read in Markup parser 2018-05-11 11:55:22 +01:00
Michael Gottesman
8437819b5a [CMake] Revert recent changes.
These changes caused a number of issues:

1. No debug info is emitted when a release-debug info compiler is built.
2. OS X deployment target specification is broken.
3. Swift options were broken without any attempt any recreating that
functionality. The specific option in question is --force-optimized-typechecker.

Such refactorings should be done in a fashion that does not break existing
users and use cases.

This reverts commit e6ce2ff388.
This reverts commit e8645f3750.
This reverts commit 89b038ea7e.
This reverts commit 497cac64d9.
This reverts commit 953ad094da.
This reverts commit e096d1c033.

rdar://30549345
2017-02-15 22:26:06 -08:00
Chris Bieneman
e096d1c033 [CMake] Simplify add_swift_library
This patch splits add_swift_library into two functions one which handles
the simple case of adding a library that is part of the compiler being
built and the second handling the more complicated case of "target"
libraries, which may need to build for one or more targets.

The new add_swift_library is built using llvm_add_library, which re-uses
LLVM's CMake modules. In adapting to use LLVM's modules some of
add_swift_library's named parameters have been removed and
LINK_LIBRARIES has changed to LINK_LIBS, and LLVM_LINK_COMPONENTS
changed to LINK_COMPONENTS.

This patch also cleans up libswiftBasic's handling of UUID library and
headers, and how it interfaces with gyb sources.

add_swift_library also no longer has the FILE_DEPENDS parameter, which
doesn't matter because llvm_add_library's DEPENDS parameter has the same
behavior.
2017-02-14 14:28:10 -08:00
Chris Bieneman
44b6f32f0e Clean up handling of CMark library dependency.
This change depends on:

https://github.com/apple/swift-cmark/pull/4
2017-02-08 14:32:50 -08:00
Hugh Bellamy
7a5ef4bdd1 Support building swift/AST with MSVC on Windows 2017-01-09 09:05:06 +00:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
David Farler
abed7b67d6 Merge pull request #2132 from bitjammer/closure-param-doc
Add nested parameter/returns/throws comment recognition
2016-04-10 17:06:51 -07:00
David Farler
c20f3db09e Nesting parameter/returns/throws doc comments for closure parameters
Under parameter doc comment list items, allow function doc comment
syntax to nest so you can document the meaning of closure parameters'
signatures.

rdar://problem/24794725
2016-04-10 15:32:07 -07:00
David Farler
a9297eed9f Rename llvm::markup namespace to swift::markup
This was naming was cargoed from long ago and this functionality isn't
directly related to LLVM, it's specific to Swift.
2016-04-10 13:46:25 -07:00
David Farler
fbc220a036 Revert "Revert "Enable cmark smart punctuation in doc comments""
This reverts commit f723b86614 and
updates the IDE tests that incidentally included some punctuation.
No new tests are necessary - the character level tests are exercised
in cmark itself.
2016-04-10 13:32:43 -07:00
Ted Kremenek
f723b86614 Revert "Enable cmark smart punctuation in doc comments"
This reverts commit 3f0376116c.

This broke the Linux build.
2016-04-10 13:03:12 -07:00
David Farler
3f0376116c Enable cmark smart punctuation in doc comments
The following unescaped sequences will be rendered with cmark's "smart
punctuation" rules, roughly:

- Closed pairs of single/double straight quotes -> curly quotes
- Double dash: en-dash
- Triple dash: em-dash
- Three periods -> ellipsis character

rdar://problem/24794606
2016-04-10 12:42:52 -07:00
Jordan Rose
658bded970 [Markup] Adopt llvm::TrailingObjects for markup nodes.
Again, I didn't see any mistakes, but this does clean up the code a little.
No intended functionality change.
2016-02-09 08:57:02 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
David Farler
e87be804c9 [Markup] Slurp fenced code block info string
Add a language property for Markup code blocks - the default is
"swift" but will respect overrides such as the following:

```c++
Something::Somethign::create()
```

For code listings in doc comments written in other languages, such
as when you want to compare usage against another language.

rdar://problem/23948115
2015-12-17 17:51:27 -08:00
Chris Lattner
43e4741559 Merge pull request #127 from Nirma/unified_quotes
Unified the use of character and string sequences.
2015-12-04 20:43:42 -08:00
Nick Wellnhofer
e02ca76275 Don't rely on cmark internals
The cmark_node struct and the node.h header are private.
2015-12-04 23:11:47 +01:00
Nicholas Maccharoli
6169201d90 Unified the use of character and string sequences. 2015-12-04 10:22:00 +09:00