Skip to content

Commit 9817e2c

Browse files
kadircetmemfrob
authored andcommitted
[clangd] Add std::size_t to StdSymbol mapping
This is a common symbol that's missing from our mapping because cppreference yields multiple headers. Add it manually by picking cstddef to prevent insertion of some stdlib-internal headers instead. Fixes clangd/clangd#666. Differential Revision: https://reviews.llvm.org/D95423
1 parent 2065419 commit 9817e2c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang-tools-extra/clangd/index/CanonicalIncludes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {
9292
#include "StdSymbolMap.inc"
9393
// There are two std::move()s, this is by far the most common.
9494
SYMBOL(move, std::, <utility>)
95+
// There are multiple headers for size_t, pick one.
96+
SYMBOL(size_t, std::, <cstddef>)
9597
#undef SYMBOL
9698
});
9799
StdSymbolMapping = Symbols;
98100
} else if (Language.C11) {
99101
static const auto *CSymbols = new llvm::StringMap<llvm::StringRef>({
100102
#define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
101103
#include "CSymbolMap.inc"
104+
// There are multiple headers for size_t, pick one.
105+
SYMBOL(size_t, None, <stddef.h>)
102106
#undef SYMBOL
103107
});
104108
StdSymbolMapping = CSymbols;

0 commit comments

Comments
 (0)