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.
Paths
| Differential D90397
[clangd] Value initialize SymbolIDs ClosedPublic Authored by kadircet on Oct 29 2020, 8:06 AM.
Details
Summary 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
kadircet marked an inline comment as done. 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.
This revision is now accepted and ready to land.Oct 31 2020, 6:12 PM Comment Actions
Good point! kadircet marked 4 inline comments as done. Comment Actions
This revision was landed with ongoing or failed builds.Nov 2 2020, 2:43 AM Closed by commit rG0df197516b69: [clangd] Value initialize SymbolIDs (authored by kadircet). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 302231 clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CollectMacros.cpp
clang-tools-extra/clangd/HeaderSourceSwitch.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/SymbolID.h
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
|
probably want to be a bit more specific about the possibility of returning null (and below)