Commit Graph

6 Commits

Author SHA1 Message Date
Nico Weber
9d5359d1f8 [Demangling] Remove includes of swift/Basic/Assertions.h
They are not used. Demangling uses `assert()` from <cassert>,
and macros from lib/Demangling/DemanglerAssert.h.

Reverts the lib/Demangling changes from #74184.

No behavior change.
2024-08-05 12:16:00 -04: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
tbkka
74f287899c Punycode error handling (#31977)
* Fix NULL deref for invalid mangled input

The `Qo` operator expects to consume a type name and a list (terminated with a `y` empty list marker) from the stack.  After popping the list, it doesn't check whether the stack is empty, so `$syQo` crashes (it pops down to the `y` then tries to pop again).

This PR just adds the obvious check to guard against this.

Resolves rdar://63128307

* Audit Punycode implementation against RFC3492

Fuzz tests have revealed some weaknesses in the error handling of our Punycode implementation used to mangle Unicode identifiers.  A more detailed comparison of the implementation against the algorithm detailed in RFC3492 showed that most of the arithmetic overflow checks were omitted and the ones that were present were handled as success instead of failure.

A typical example:

RFC3492 algorithm:
```
 let w = w * (base - t), fail on overflow
```

Original implementation:
```
 w = w * (base - t);
```

Corrected implementation:
```
 if (w > std::numeric_limits<int>::max() / (base - t))
   return false;
 w = w * (base - t);
```

Resolves rdar://63392615
2020-07-06 16:23:01 -07:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08:00