[clang] 7c9b15f - Revert "[Tooling/Inclusion] Handle std::get symbol."
Caroline Tice via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 23 15:19:28 PST 2023
Author: Caroline Tice
Date: 2023-02-23T15:18:17-08:00
New Revision: 7c9b15fbaeb2846ad25e797d55ffe1ccef9e1379
URL: https://github.com/llvm/llvm-project/commit/7c9b15fbaeb2846ad25e797d55ffe1ccef9e1379
DIFF: https://github.com/llvm/llvm-project/commit/7c9b15fbaeb2846ad25e797d55ffe1ccef9e1379.diff
LOG: Revert "[Tooling/Inclusion] Handle std::get symbol."
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>(
^
Added:
Modified:
clang-tools-extra/clangd/index/CanonicalIncludes.cpp
clang/include/clang/Tooling/Inclusions/StandardLibrary.h
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
clang/unittests/Tooling/StandardLibraryTest.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
index 4311eb9f481f8..0c61a7bd7e929 100644
--- a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -717,8 +717,7 @@ llvm::StringRef CanonicalIncludes::mapSymbol(llvm::StringRef Scope,
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 "";
}
diff --git a/clang/include/clang/Tooling/Inclusions/StandardLibrary.h b/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
index a39ceb520dcf8..9d45d84a429be 100644
--- a/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
+++ b/clang/include/clang/Tooling/Inclusions/StandardLibrary.h
@@ -81,7 +81,7 @@ class Symbol {
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;
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index cfcb955831ad2..416b53117d16b 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -14,7 +14,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
-#include <optional>
namespace clang {
namespace tooling {
@@ -121,8 +120,7 @@ static int initialize(Lang Language) {
}
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);
@@ -207,11 +205,8 @@ std::optional<Symbol> Symbol::named(llvm::StringRef Scope, llvm::StringRef Name,
}
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;
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
index c9632bee1cbec..3d2ea91a94d36 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -218,8 +218,3 @@ SYMBOL(ssize, std::, <string_view>)
SYMBOL(ssize, std::, <unordered_map>)
SYMBOL(ssize, std::, <unordered_set>)
SYMBOL(ssize, std::, <vector>)
-
-// std::get has a few variants for
diff erent 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*/)
diff --git a/clang/unittests/Tooling/StandardLibraryTest.cpp b/clang/unittests/Tooling/StandardLibraryTest.cpp
index 6d90bbdf3b6eb..47d064bdd2a92 100644
--- a/clang/unittests/Tooling/StandardLibraryTest.cpp
+++ b/clang/unittests/Tooling/StandardLibraryTest.cpp
@@ -58,9 +58,6 @@ TEST(StdlibTest, All) {
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>"),
More information about the cfe-commits
mailing list