We were default initializing SymbolIDs before, which would leave
indeterminate values in underlying std::array.
This patch updates the underlying data initalization to be value-init and adds a
way to check for validness of a SymbolID.
Differential D90397
[clangd] Value initialize SymbolIDs kadircet on Oct 29 2020, 8:06 AM. Authored by
Details
We were default initializing SymbolIDs before, which would leave This patch updates the underlying data initalization to be value-init and adds a
Diff Detail
Event Timeline
Comment Actions
Note that all the functional changes are in SymbolID.h, rest is api updates. Comment Actions Would it have been possible to disallow default-constructing SymbolID altogether, and preserve the ability to represent "an always-valid symbol id" (SymbolID) vs. "a maybe-valid symbol id" (Optional<SymbolID>) as distinct types in the type system? Comment Actions Absolutely, except where it matters`sizeof(SymbolID)==8` and sizeof(Optional<SymbolID>)==16.
Comment Actions
|
I'm not a big fan of LLVM's habit of calling the sentinel value "invalid".
Consider SourceLocation - one can construct invalid source locations that are isValid() (add an offset longer than the file) and SourceLocation() most commonly means "there is no location associated" rather than "we have bad data".
WDYT about calling this "isNull" (and possibly defining operator bool())?