Commit Graph

13 Commits

Author SHA1 Message Date
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
Alex Hoppen
7593682c98 [JSONSerialization] Make key a StringRef
Most keys are string literals and if they are converted directly to
StringRef, the string length can be computed at compile time, increasing
performance.
2018-07-27 16:20:34 -07:00
Alex Hoppen
07b449bbd5 [JSONSerialization] Introduce ScalarReferenceTraits
For ScalarTraits, a buffer was always created on the heap to which the
scalar string value was written just to be copied to the output buffer
again. In case the value already exists in a memory buffer it is way
cheaper to avoid the heap allocation and copy it straight to the output
buffer.
2018-07-27 16:20:34 -07:00
Rintaro Ishizaki
d48a2a4071 [JSONSerialization] Compact output for empty objects and arrays
Now, they are represented as `{}` and `[]` instead of:
  {

  }
and
  [

  ]
2018-01-30 15:40:17 +09:00
Rintaro Ishizaki
4087cff99d [JSONSerialization] Add ability to emit 'null' value 2018-01-30 15:23:12 +09: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
Han Sangjin
cccfbf4d3c [swiftc/msvc] Compiling with MSVC (#1516)
Some modifications for the ms-extension option of the clang.exe in the Visual Studio 2015 development environment

This patch is only for swiftc.exe. I used the library set of Visual Studio 2015 Update 1 and recent version of swift-clang as the compiler. If you are using the real MSVC compiler, more patch might be required.
2016-07-08 19:06:10 -07:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Arsen Gasparyan
be738abb7c Fix else code style 2015-12-22 11:13:26 +03:00
Dmitri Hrybenko
97b166fe8a Fix a warning about redundant comparison of unsigned char to 0
Swift SVN r22340
2014-09-28 18:56:59 +00:00
Connor Wakamo
725f501e9b Fixed the escaping of strings in swift::json::Output.
Instead of using llvm::raw_ostream::write_escaped (which does not produce valid
JSON strings), implemented custom escaping logic based on the JSON standard,
which only requires that the following characters be escaped:

  - Quotation mark (U+0022)
  - Reverse solidus (U+005C)
  - Control characters (U+0000 to U+001F)

Since these characters all fit within a single UTF8 byte, and will not be
present in a multi-byte UTF8 representation, simply check whether the current
byte needs to be escaped according to those requirements. If the current byte
needs to be escaped, then print out the escaped version of the byte; otherwise,
pass the current byte to the stream directly.

This fixes <rdar://problem/18266570>.

Swift SVN r21892
2014-09-11 22:20:05 +00:00
Connor Wakamo
a69eb17411 [json] Added a basic JSON serialization class in swiftBasic.
The swift::json namespace now contains an Output class, which largely mirrors
llvm::yaml::Output. It takes the same approach where there are various traits
structs which dictate how a particular type is output in JSON. (This is separate
from llvm::yaml because, while all JSON is valid YAML, not all YAML is valid
JSON, and customization on how scalar types are output as JSON is necessary.)

Unlike llvm::yaml, there is no equivalent Input class. Since JSON is valid YAML,
llvm::yaml::Input can be used instead.

At some point, the traits structs could likely be merged with llvm::yaml (with
some ability to customize how scalars are output if it's outputting JSON instead
of YAML), but this provides enough of a starting point to allow the driver to
generate parseable output in JSON format.

Part of <rdar://problem/15958329>.

Swift SVN r20870
2014-08-01 01:15:35 +00:00