This reverts commit
cbcb3eef70def3509bdffd4fe1ebfb6422afeaa2.
Causing many clangd test breakages, similar to:
error: no matching constructor for initialization of 'llvm::SmallVector<clang::tooling::stdlib::Header>'
: llvm::SmallVector<clang::tooling::stdlib::Header>(
^
if (Scope == "std::" && Name == "move")
return "<utility>";
if (auto StdSym = tooling::stdlib::Symbol::named(Scope, Name, Lang))
- if (auto Header = StdSym->header())
- return Header->name();
+ return StdSym->header().name();
return "";
}
llvm::StringRef name() const;
llvm::StringRef qualifiedName() const;
// The preferred header for this symbol (e.g. the suggested insertion).
- std::optional<Header> header() const;
+ Header header() const;
// Some symbols may be provided by multiple headers.
llvm::SmallVector<Header> headers() const;
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
-#include <optional>
namespace clang {
namespace tooling {
}
Mapping->SymbolNames[SymIndex] = {
QName.data(), NSLen, static_cast<unsigned int>(QName.size() - NSLen)};
- if (!HeaderName.empty())
- Mapping->SymbolHeaderIDs[SymIndex].push_back(AddHeader(HeaderName));
+ Mapping->SymbolHeaderIDs[SymIndex].push_back(AddHeader(HeaderName));
NSSymbolMap &NSSymbols = AddNS(QName.take_front(NSLen));
NSSymbols.try_emplace(QName.drop_front(NSLen), SymIndex);
}
return std::nullopt;
}
-std::optional<Header> Symbol::header() const {
- const auto& Headers = getMappingPerLang(Language)->SymbolHeaderIDs[ID];
- if (Headers.empty())
- return std::nullopt;
- return Header(Headers.front(), Language);
+Header Symbol::header() const {
+ return Header(getMappingPerLang(Language)->SymbolHeaderIDs[ID][0], Language);
}
llvm::SmallVector<Header> Symbol::headers() const {
llvm::SmallVector<Header> Results;
SYMBOL(ssize, std::, <unordered_map>)
SYMBOL(ssize, std::, <unordered_set>)
SYMBOL(ssize, std::, <vector>)
-
-// std::get has a few variants for different types (tuple, array, pair etc)
-// which is tricky to disambiguate without type information.
-// Don't set any header for it, as it comes with the type header.
-SYMBOL(get, std::, /*no headers*/)
EXPECT_EQ(Vector->header(), *VectorH);
EXPECT_THAT(Vector->headers(), ElementsAre(*VectorH));
- EXPECT_TRUE(stdlib::Symbol::named("std::", "get"));
- EXPECT_FALSE(stdlib::Symbol::named("std::", "get")->header());
-
EXPECT_THAT(stdlib::Symbol::named("std::", "basic_iostream")->headers(),
ElementsAre(stdlib::Header::named("<istream>"),
stdlib::Header::named("<iostream>"),