[clang-tools-extra] r341211 - [clangd] Flatten out Symbol::Details. It was ill-conceived, sorry.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 31 06:55:02 PDT 2018
Author: sammccall
Date: Fri Aug 31 06:55:01 2018
New Revision: 341211
URL: http://llvm.org/viewvc/llvm-project?rev=341211&view=rev
Log:
[clangd] Flatten out Symbol::Details. It was ill-conceived, sorry.
Reviewers: ioeric
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D51504
Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/clangd/index/Merge.cpp
clang-tools-extra/trunk/clangd/index/Merge.h
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
clang-tools-extra/trunk/clangd/index/SymbolYAML.h
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Fri Aug 31 06:55:01 2018
@@ -285,8 +285,7 @@ struct CompletionCandidate {
}
llvm::Optional<llvm::StringRef> headerToInsertIfNotPresent() const {
- if (!IndexResult || !IndexResult->Detail ||
- IndexResult->Detail->IncludeHeader.empty())
+ if (!IndexResult || IndexResult->IncludeHeader.empty())
return llvm::None;
if (SemaResult && SemaResult->Declaration) {
// Avoid inserting new #include if the declaration is found in the current
@@ -296,7 +295,7 @@ struct CompletionCandidate {
if (SM.isInMainFile(SM.getExpansionLoc(RD->getBeginLoc())))
return llvm::None;
}
- return IndexResult->Detail->IncludeHeader;
+ return IndexResult->IncludeHeader;
}
using Bundle = llvm::SmallVector<CompletionCandidate, 4>;
@@ -382,7 +381,7 @@ struct CodeCompletionBuilder {
log("Failed to generate include insertion edits for adding header "
"(FileURI='{0}', IncludeHeader='{1}') into {2}",
C.IndexResult->CanonicalDeclaration.FileURI,
- C.IndexResult->Detail->IncludeHeader, FileName);
+ C.IndexResult->IncludeHeader, FileName);
}
}
@@ -397,12 +396,11 @@ struct CodeCompletionBuilder {
} else if (C.IndexResult) {
S.Signature = C.IndexResult->Signature;
S.SnippetSuffix = C.IndexResult->CompletionSnippetSuffix;
- if (auto *D = C.IndexResult->Detail)
- S.ReturnType = D->ReturnType;
+ S.ReturnType = C.IndexResult->ReturnType;
}
if (ExtractDocumentation && Completion.Documentation.empty()) {
- if (C.IndexResult && C.IndexResult->Detail)
- Completion.Documentation = C.IndexResult->Detail->Documentation;
+ if (C.IndexResult)
+ Completion.Documentation = C.IndexResult->Documentation;
else if (C.SemaResult)
Completion.Documentation = getDocComment(ASTCtx, *C.SemaResult,
/*CommentsFromHeader=*/false);
@@ -846,9 +844,8 @@ public:
IndexRequest.IDs.insert(*S.IDForDoc);
}
Index->lookup(IndexRequest, [&](const Symbol &S) {
- if (!S.Detail || S.Detail->Documentation.empty())
- return;
- FetchedDocs[S.ID] = S.Detail->Documentation;
+ if (!S.Documentation.empty())
+ FetchedDocs[S.ID] = S.Documentation;
});
log("SigHelp: requested docs for {0} symbols from the index, got {1} "
"symbols with non-empty docs in the response",
Modified: clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp Fri Aug 31 06:55:01 2018
@@ -160,17 +160,14 @@ public:
SymbolSlab mergeResults() override {
SymbolSlab::Builder UniqueSymbols;
- llvm::BumpPtrAllocator Arena;
- Symbol::Details Scratch;
Executor.getToolResults()->forEachResult(
[&](llvm::StringRef Key, llvm::StringRef Value) {
- Arena.Reset();
- llvm::yaml::Input Yin(Value, &Arena);
- auto Sym = clang::clangd::SymbolFromYAML(Yin, Arena);
+ llvm::yaml::Input Yin(Value);
+ auto Sym = clang::clangd::SymbolFromYAML(Yin);
clang::clangd::SymbolID ID;
Key >> ID;
if (const auto *Existing = UniqueSymbols.find(ID))
- UniqueSymbols.insert(mergeSymbol(*Existing, Sym, &Scratch));
+ UniqueSymbols.insert(mergeSymbol(*Existing, Sym));
else
UniqueSymbols.insert(Sym);
});
@@ -188,9 +185,8 @@ public:
void consumeSymbols(SymbolSlab Symbols) override {
std::lock_guard<std::mutex> Lock(Mut);
for (auto &&Sym : Symbols) {
- Symbol::Details Scratch;
if (const auto *Existing = Result.find(Sym.ID))
- Result.insert(mergeSymbol(*Existing, Sym, &Scratch));
+ Result.insert(mergeSymbol(*Existing, Sym));
else
Result.insert(Sym);
}
Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Fri Aug 31 06:55:01 2018
@@ -90,18 +90,9 @@ static void own(Symbol &S, llvm::UniqueS
Intern(S.Signature);
Intern(S.CompletionSnippetSuffix);
-
- if (S.Detail) {
- // Copy values of StringRefs into arena.
- auto *Detail = Arena.Allocate<Symbol::Details>();
- *Detail = *S.Detail;
- // Intern the actual strings.
- Intern(Detail->Documentation);
- Intern(Detail->ReturnType);
- Intern(Detail->IncludeHeader);
- // Replace the detail pointer with our copy.
- S.Detail = Detail;
- }
+ Intern(S.Documentation);
+ Intern(S.ReturnType);
+ Intern(S.IncludeHeader);
}
void SymbolSlab::Builder::insert(const Symbol &S) {
Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Fri Aug 31 06:55:01 2018
@@ -208,30 +208,19 @@ struct Symbol {
/// This is in LSP snippet syntax (e.g. "({$0})" for a no-args function).
/// (When snippets are disabled, the symbol name alone is used).
llvm::StringRef CompletionSnippetSuffix;
-
- /// Optional symbol details that are not required to be set. For example, an
- /// index fuzzy match can return a large number of symbol candidates, and it
- /// is preferable to send only core symbol information in the batched results
- /// and have clients resolve full symbol information for a specific candidate
- /// if needed.
- struct Details {
- /// Documentation including comment for the symbol declaration.
- llvm::StringRef Documentation;
- /// Type when this symbol is used in an expression. (Short display form).
- /// e.g. return type of a function, or type of a variable.
- llvm::StringRef ReturnType;
- /// This can be either a URI of the header to be #include'd for this symbol,
- /// or a literal header quoted with <> or "" that is suitable to be included
- /// directly. When this is a URI, the exact #include path needs to be
- /// calculated according to the URI scheme.
- ///
- /// This is a canonical include for the symbol and can be different from
- /// FileURI in the CanonicalDeclaration.
- llvm::StringRef IncludeHeader;
- };
-
- // Optional details of the symbol.
- const Details *Detail = nullptr;
+ /// Documentation including comment for the symbol declaration.
+ llvm::StringRef Documentation;
+ /// Type when this symbol is used in an expression. (Short display form).
+ /// e.g. return type of a function, or type of a variable.
+ llvm::StringRef ReturnType;
+ /// This can be either a URI of the header to be #include'd for this symbol,
+ /// or a literal header quoted with <> or "" that is suitable to be included
+ /// directly. When this is a URI, the exact #include path needs to be
+ /// calculated according to the URI scheme.
+ ///
+ /// This is a canonical include for the symbol and can be different from
+ /// FileURI in the CanonicalDeclaration.
+ llvm::StringRef IncludeHeader;
// FIXME: add all occurrences support.
// FIXME: add extra fields for index scoring signals.
Modified: clang-tools-extra/trunk/clangd/index/Merge.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Merge.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Merge.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Merge.cpp Fri Aug 31 06:55:01 2018
@@ -42,13 +42,12 @@ class MergedIndex : public SymbolIndex {
SymbolSlab Dyn = std::move(DynB).build();
DenseSet<SymbolID> SeenDynamicSymbols;
- Symbol::Details Scratch;
More |= Static->fuzzyFind(Req, [&](const Symbol &S) {
auto DynS = Dyn.find(S.ID);
if (DynS == Dyn.end())
return Callback(S);
SeenDynamicSymbols.insert(S.ID);
- Callback(mergeSymbol(*DynS, S, &Scratch));
+ Callback(mergeSymbol(*DynS, S));
});
for (const Symbol &S : Dyn)
if (!SeenDynamicSymbols.count(S.ID))
@@ -64,14 +63,13 @@ class MergedIndex : public SymbolIndex {
Dynamic->lookup(Req, [&](const Symbol &S) { B.insert(S); });
auto RemainingIDs = Req.IDs;
- Symbol::Details Scratch;
Static->lookup(Req, [&](const Symbol &S) {
const Symbol *Sym = B.find(S.ID);
RemainingIDs.erase(S.ID);
if (!Sym)
Callback(S);
else
- Callback(mergeSymbol(*Sym, S, &Scratch));
+ Callback(mergeSymbol(*Sym, S));
});
for (const auto &ID : RemainingIDs)
if (const Symbol *Sym = B.find(ID))
@@ -93,8 +91,7 @@ private:
};
} // namespace
-Symbol
-mergeSymbol(const Symbol &L, const Symbol &R, Symbol::Details *Scratch) {
+Symbol mergeSymbol(const Symbol &L, const Symbol &R) {
assert(L.ID == R.ID);
// We prefer information from TUs that saw the definition.
// Classes: this is the def itself. Functions: hopefully the header decl.
@@ -114,21 +111,12 @@ mergeSymbol(const Symbol &L, const Symbo
S.Signature = O.Signature;
if (S.CompletionSnippetSuffix == "")
S.CompletionSnippetSuffix = O.CompletionSnippetSuffix;
-
- if (O.Detail) {
- if (S.Detail) {
- // Copy into scratch space so we can merge.
- *Scratch = *S.Detail;
- if (Scratch->Documentation == "")
- Scratch->Documentation = O.Detail->Documentation;
- if (Scratch->ReturnType == "")
- Scratch->ReturnType = O.Detail->ReturnType;
- if (Scratch->IncludeHeader == "")
- Scratch->IncludeHeader = O.Detail->IncludeHeader;
- S.Detail = Scratch;
- } else
- S.Detail = O.Detail;
- }
+ if (S.Documentation == "")
+ S.Documentation = O.Documentation;
+ if (S.ReturnType == "")
+ S.ReturnType = O.ReturnType;
+ if (S.IncludeHeader == "")
+ S.IncludeHeader = O.IncludeHeader;
S.Origin |= O.Origin | SymbolOrigin::Merge;
return S;
Modified: clang-tools-extra/trunk/clangd/index/Merge.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Merge.h?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Merge.h (original)
+++ clang-tools-extra/trunk/clangd/index/Merge.h Fri Aug 31 06:55:01 2018
@@ -18,7 +18,7 @@ namespace clangd {
// Merge symbols L and R, preferring data from L in case of conflict.
// The two symbols must have the same ID.
// Returned symbol may contain data owned by either source.
-Symbol mergeSymbol(const Symbol &L, const Symbol &R, Symbol::Details *Scratch);
+Symbol mergeSymbol(const Symbol &L, const Symbol &R);
// mergedIndex returns a composite index based on two provided Indexes:
// - the Dynamic index covers few files, but is relatively up-to-date.
Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Fri Aug 31 06:55:01 2018
@@ -422,9 +422,7 @@ bool SymbolCollector::handleMacroOccuren
}
S.Signature = Signature;
S.CompletionSnippetSuffix = SnippetSuffix;
- Symbol::Details Detail;
- Detail.IncludeHeader = Include;
- S.Detail = &Detail;
+ S.IncludeHeader = Include;
Symbols.insert(S);
return true;
}
@@ -530,11 +528,9 @@ const Symbol *SymbolCollector::addDeclar
}
S.Signature = Signature;
S.CompletionSnippetSuffix = SnippetSuffix;
- Symbol::Details Detail;
- Detail.Documentation = Documentation;
- Detail.ReturnType = ReturnType;
- Detail.IncludeHeader = Include;
- S.Detail = &Detail;
+ S.Documentation = Documentation;
+ S.ReturnType = ReturnType;
+ S.IncludeHeader = Include;
S.Origin = Opts.Origin;
Symbols.insert(S);
Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolYAML.cpp Fri Aug 31 06:55:01 2018
@@ -66,40 +66,9 @@ template <> struct MappingTraits<SymbolI
}
};
-template <> struct MappingTraits<Symbol::Details> {
- static void mapping(IO &io, Symbol::Details &Detail) {
- io.mapOptional("Documentation", Detail.Documentation);
- io.mapOptional("ReturnType", Detail.ReturnType);
- io.mapOptional("IncludeHeader", Detail.IncludeHeader);
- }
-};
-
-// A YamlIO normalizer for fields of type "const T*" allocated on an arena.
-// Normalizes to Optional<T>, so traits should be provided for T.
-template <typename T> struct ArenaPtr {
- ArenaPtr(IO &) {}
- ArenaPtr(IO &, const T *D) {
- if (D)
- Opt = *D;
- }
-
- const T *denormalize(IO &IO) {
- assert(IO.getContext() && "Expecting an arena (as context) to allocate "
- "data for read symbols.");
- if (!Opt)
- return nullptr;
- return new (*static_cast<llvm::BumpPtrAllocator *>(IO.getContext()))
- T(std::move(*Opt)); // Allocate a copy of Opt on the arena.
- }
-
- llvm::Optional<T> Opt;
-};
-
template <> struct MappingTraits<Symbol> {
static void mapping(IO &IO, Symbol &Sym) {
MappingNormalization<NormalizedSymbolID, SymbolID> NSymbolID(IO, Sym.ID);
- MappingNormalization<ArenaPtr<Symbol::Details>, const Symbol::Details *>
- NDetail(IO, Sym.Detail);
IO.mapRequired("ID", NSymbolID->HexString);
IO.mapRequired("Name", Sym.Name);
IO.mapRequired("Scope", Sym.Scope);
@@ -112,7 +81,9 @@ template <> struct MappingTraits<Symbol>
false);
IO.mapOptional("Signature", Sym.Signature);
IO.mapOptional("CompletionSnippetSuffix", Sym.CompletionSnippetSuffix);
- IO.mapOptional("Detail", NDetail->Opt);
+ IO.mapOptional("Documentation", Sym.Documentation);
+ IO.mapOptional("ReturnType", Sym.ReturnType);
+ IO.mapOptional("IncludeHeader", Sym.IncludeHeader);
}
};
@@ -169,9 +140,7 @@ namespace clang {
namespace clangd {
SymbolSlab symbolsFromYAML(llvm::StringRef YAMLContent) {
- // Store data of pointer fields (excl. `StringRef`) like `Detail`.
- llvm::BumpPtrAllocator Arena;
- llvm::yaml::Input Yin(YAMLContent, &Arena);
+ llvm::yaml::Input Yin(YAMLContent);
std::vector<Symbol> S;
Yin >> S;
@@ -181,9 +150,7 @@ SymbolSlab symbolsFromYAML(llvm::StringR
return std::move(Syms).build();
}
-Symbol SymbolFromYAML(llvm::yaml::Input &Input, llvm::BumpPtrAllocator &Arena) {
- // We could grab Arena out of Input, but it'd be a huge hazard for callers.
- assert(Input.getContext() == &Arena);
+Symbol SymbolFromYAML(llvm::yaml::Input &Input) {
Symbol S;
Input >> S;
return S;
Modified: clang-tools-extra/trunk/clangd/index/SymbolYAML.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolYAML.h?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/SymbolYAML.h (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolYAML.h Fri Aug 31 06:55:01 2018
@@ -30,9 +30,8 @@ namespace clangd {
SymbolSlab symbolsFromYAML(llvm::StringRef YAMLContent);
// Read one symbol from a YAML-stream.
-// The arena must be the Input's context! (i.e. yaml::Input Input(Text, &Arena))
-// The returned symbol is backed by both Input and Arena.
-Symbol SymbolFromYAML(llvm::yaml::Input &Input, llvm::BumpPtrAllocator &Arena);
+// The returned symbol is backed by Input.
+Symbol SymbolFromYAML(llvm::yaml::Input &Input);
// Convert a single symbol to YAML-format string.
// The YAML result is safe to concatenate.
Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Fri Aug 31 06:55:01 2018
@@ -564,12 +564,10 @@ TEST(CompletionTest, IncludeInsertionPre
IgnoreDiagnostics DiagConsumer;
ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
- Symbol::Details Scratch;
auto BarURI = URI::createFile(BarHeader).toString();
Symbol Sym = cls("ns::X");
Sym.CanonicalDeclaration.FileURI = BarURI;
- Scratch.IncludeHeader = BarURI;
- Sym.Detail = &Scratch;
+ Sym.IncludeHeader = BarURI;
// Shoten include path based on search dirctory and insert.
auto Results = completions(Server,
R"cpp(
@@ -595,16 +593,14 @@ TEST(CompletionTest, NoIncludeInsertionW
IgnoreDiagnostics DiagConsumer;
ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
- Symbol::Details Scratch;
Symbol SymX = cls("ns::X");
Symbol SymY = cls("ns::Y");
std::string BarHeader = testPath("bar.h");
auto BarURI = URI::createFile(BarHeader).toString();
SymX.CanonicalDeclaration.FileURI = BarURI;
SymY.CanonicalDeclaration.FileURI = BarURI;
- Scratch.IncludeHeader = "<bar>";
- SymX.Detail = &Scratch;
- SymY.Detail = &Scratch;
+ SymX.IncludeHeader = "<bar>";
+ SymY.IncludeHeader = "<bar>";
// Shoten include path based on search dirctory and insert.
auto Results = completions(Server,
R"cpp(
@@ -1179,11 +1175,9 @@ TEST(CompletionTest, OverloadBundling) {
UnorderedElementsAre(Labeled("GFuncC(â¦)"), Labeled("GFuncD(int)")));
// Differences in header-to-insert suppress bundling.
- Symbol::Details Detail;
std::string DeclFile = URI::createFile(testPath("foo")).toString();
NoArgsGFunc.CanonicalDeclaration.FileURI = DeclFile;
- Detail.IncludeHeader = "<foo>";
- NoArgsGFunc.Detail = &Detail;
+ NoArgsGFunc.IncludeHeader = "<foo>";
EXPECT_THAT(
completions(Context + "int y = GFunc^", {NoArgsGFunc}, Opts).Completions,
UnorderedElementsAre(AllOf(Named("GFuncC"), InsertInclude("<foo>")),
@@ -1664,13 +1658,10 @@ TEST(SignatureHelpTest, InstantiatedSign
}
TEST(SignatureHelpTest, IndexDocumentation) {
- Symbol::Details DocDetails;
- DocDetails.Documentation = "Doc from the index";
-
Symbol Foo0 = sym("foo", index::SymbolKind::Function, "@F@\\0#");
- Foo0.Detail = &DocDetails;
+ Foo0.Documentation = "Doc from the index";
Symbol Foo1 = sym("foo", index::SymbolKind::Function, "@F@\\0#I#");
- Foo1.Detail = &DocDetails;
+ Foo1.Documentation = "Doc from the index";
Symbol Foo2 = sym("foo", index::SymbolKind::Function, "@F@\\0#I#I#");
StringRef Sig0 = R"cpp(
Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Fri Aug 31 06:55:01 2018
@@ -177,7 +177,7 @@ TEST(FileIndexTest, NoIncludeCollected)
Req.Query = "";
bool SeenSymbol = false;
M.fuzzyFind(Req, [&](const Symbol &Sym) {
- EXPECT_TRUE(Sym.Detail->IncludeHeader.empty());
+ EXPECT_TRUE(Sym.IncludeHeader.empty());
SeenSymbol = true;
});
EXPECT_TRUE(SeenSymbol);
Modified: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Fri Aug 31 06:55:01 2018
@@ -198,32 +198,23 @@ TEST(MergeTest, Merge) {
R.References = 2;
L.Signature = "()"; // present in left only
R.CompletionSnippetSuffix = "{$1:0}"; // present in right only
- Symbol::Details DetL, DetR;
- DetL.ReturnType = "DetL";
- DetR.ReturnType = "DetR";
- DetR.Documentation = "--doc--";
- L.Detail = &DetL;
- R.Detail = &DetR;
+ R.Documentation = "--doc--";
L.Origin = SymbolOrigin::Dynamic;
R.Origin = SymbolOrigin::Static;
- Symbol::Details Scratch;
- Symbol M = mergeSymbol(L, R, &Scratch);
+ Symbol M = mergeSymbol(L, R);
EXPECT_EQ(M.Name, "Foo");
EXPECT_EQ(M.CanonicalDeclaration.FileURI, "file:///left.h");
EXPECT_EQ(M.References, 3u);
EXPECT_EQ(M.Signature, "()");
EXPECT_EQ(M.CompletionSnippetSuffix, "{$1:0}");
- ASSERT_TRUE(M.Detail);
- EXPECT_EQ(M.Detail->ReturnType, "DetL");
- EXPECT_EQ(M.Detail->Documentation, "--doc--");
+ EXPECT_EQ(M.Documentation, "--doc--");
EXPECT_EQ(M.Origin,
SymbolOrigin::Dynamic | SymbolOrigin::Static | SymbolOrigin::Merge);
}
TEST(MergeTest, PreferSymbolWithDefn) {
Symbol L, R;
- Symbol::Details Scratch;
L.ID = R.ID = SymbolID("hello");
L.CanonicalDeclaration.FileURI = "file:/left.h";
@@ -231,13 +222,13 @@ TEST(MergeTest, PreferSymbolWithDefn) {
L.Name = "left";
R.Name = "right";
- Symbol M = mergeSymbol(L, R, &Scratch);
+ Symbol M = mergeSymbol(L, R);
EXPECT_EQ(M.CanonicalDeclaration.FileURI, "file:/left.h");
EXPECT_EQ(M.Definition.FileURI, "");
EXPECT_EQ(M.Name, "left");
R.Definition.FileURI = "file:/right.cpp"; // Now right will be favored.
- M = mergeSymbol(L, R, &Scratch);
+ M = mergeSymbol(L, R);
EXPECT_EQ(M.CanonicalDeclaration.FileURI, "file:/right.h");
EXPECT_EQ(M.Definition.FileURI, "file:/right.cpp");
EXPECT_EQ(M.Name, "right");
Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=341211&r1=341210&r2=341211&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Fri Aug 31 06:55:01 2018
@@ -45,22 +45,16 @@ using testing::UnorderedElementsAreArray
MATCHER_P(Labeled, Label, "") {
return (arg.Name + arg.Signature).str() == Label;
}
-MATCHER(HasReturnType, "") {
- return arg.Detail && !arg.Detail->ReturnType.empty();
-}
-MATCHER_P(ReturnType, D, "") {
- return arg.Detail && arg.Detail->ReturnType == D;
-}
-MATCHER_P(Doc, D, "") { return arg.Detail && arg.Detail->Documentation == D; }
+MATCHER(HasReturnType, "") { return !arg.ReturnType.empty(); }
+MATCHER_P(ReturnType, D, "") { return arg.ReturnType == D; }
+MATCHER_P(Doc, D, "") { return arg.Documentation == D; }
MATCHER_P(Snippet, S, "") {
return (arg.Name + arg.CompletionSnippetSuffix).str() == S;
}
MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }
MATCHER_P(DeclURI, P, "") { return arg.CanonicalDeclaration.FileURI == P; }
MATCHER_P(DefURI, P, "") { return arg.Definition.FileURI == P; }
-MATCHER_P(IncludeHeader, P, "") {
- return arg.Detail && arg.Detail->IncludeHeader == P;
-}
+MATCHER_P(IncludeHeader, P, "") { return arg.IncludeHeader == P; }
MATCHER_P(DeclRange, Pos, "") {
return std::tie(arg.CanonicalDeclaration.Start.Line,
arg.CanonicalDeclaration.Start.Column,
@@ -764,9 +758,8 @@ CanonicalDeclaration:
Line: 1
Column: 1
IsIndexedForCodeCompletion: true
-Detail:
- Documentation: 'Foo doc'
- ReturnType: 'int'
+Documentation: 'Foo doc'
+ReturnType: 'int'
...
)";
const std::string YAML2 = R"(
More information about the cfe-commits
mailing list