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.
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)
* 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
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