[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 https://github.com/clangd/clangd/issues/666.

Differential Revision: https://reviews.llvm.org/D95423
This commit is contained in:
Kadir Cetinkaya 2021-01-26 07:39:43 +01:00
parent b208e5bcd0
commit 9190f17a7c
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
1 changed files with 4 additions and 0 deletions

View File

@ -92,6 +92,8 @@ void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {
#include "StdSymbolMap.inc"
// There are two std::move()s, this is by far the most common.
SYMBOL(move, std::, <utility>)
// There are multiple headers for size_t, pick one.
SYMBOL(size_t, std::, <cstddef>)
#undef SYMBOL
});
StdSymbolMapping = Symbols;
@ -99,6 +101,8 @@ void CanonicalIncludes::addSystemHeadersMapping(const LangOptions &Language) {
static const auto *CSymbols = new llvm::StringMap<llvm::StringRef>({
#define SYMBOL(Name, NameSpace, Header) {#Name, #Header},
#include "CSymbolMap.inc"
// There are multiple headers for size_t, pick one.
SYMBOL(size_t, None, <stddef.h>)
#undef SYMBOL
});
StdSymbolMapping = CSymbols;