summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2017-12-22 08:12:39 +0000
committerSam McCall <sam.mccall@gmail.com>2017-12-22 08:12:39 +0000
commit0bf34062caf58358ab3ee7fbab084b4e692ae2ec (patch)
tree939c3f1e5731f67480828d134fa2d04a37618564
parent1b3094d4c737803a502d37872d5c7373c6edb14e (diff)
[clangd] Improve packing of Symbol struct. NFC
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@321348 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clangd/index/Index.h4
-rw-r--r--clangd/index/SymbolCollector.cpp10
2 files changed, 10 insertions, 4 deletions
diff --git a/clangd/index/Index.h b/clangd/index/Index.h
index 1816d79f..b5044634 100644
--- a/clangd/index/Index.h
+++ b/clangd/index/Index.h
@@ -82,13 +82,13 @@ void operator>>(llvm::StringRef HexStr, SymbolID &ID);
struct Symbol {
// The ID of the symbol.
SymbolID ID;
+ // The symbol information, like symbol kind.
+ index::SymbolInfo SymInfo;
// The unqualified name of the symbol, e.g. "bar" (for "n1::n2::bar").
llvm::StringRef Name;
// The scope (e.g. namespace) of the symbol, e.g. "n1::n2" (for
// "n1::n2::bar").
llvm::StringRef Scope;
- // The symbol information, like symbol kind.
- index::SymbolInfo SymInfo;
// The location of the canonical declaration of the symbol.
//
// A C++ symbol could have multiple declarations and one definition (e.g.
diff --git a/clangd/index/SymbolCollector.cpp b/clangd/index/SymbolCollector.cpp
index ee1c69dd..c53522a4 100644
--- a/clangd/index/SymbolCollector.cpp
+++ b/clangd/index/SymbolCollector.cpp
@@ -101,8 +101,14 @@ bool SymbolCollector::handleDeclOccurence(
SM.getFileOffset(D->getLocEnd())};
std::string QName = ND->getQualifiedNameAsString();
auto ScopeAndName = splitQualifiedName(QName);
- Symbols.insert({std::move(ID), ScopeAndName.second, ScopeAndName.first,
- index::getSymbolInfo(D), std::move(Location)});
+
+ Symbol S;
+ S.ID = std::move(ID);
+ S.Scope = ScopeAndName.first;
+ S.Name = ScopeAndName.second;
+ S.SymInfo = index::getSymbolInfo(D);
+ S.CanonicalDeclaration = Location;
+ Symbols.insert(S);
}
return true;