[clang-tools-extra] r330835 - [clangd] Add "str()" method to SymbolID.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 25 08:27:09 PDT 2018
Author: hokein
Date: Wed Apr 25 08:27:09 2018
New Revision: 330835
URL: http://llvm.org/viewvc/llvm-project?rev=330835&view=rev
Log:
[clangd] Add "str()" method to SymbolID.
Summary:
This is a convenient function when we try to get std::string of
SymbolID.
Reviewers: ioeric
Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits
Differential Revision: https://reviews.llvm.org/D46065
Modified:
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
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=330835&r1=330834&r2=330835&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp Wed Apr 25 08:27:09 2018
@@ -78,10 +78,7 @@ public:
auto Symbols = Collector->takeSymbols();
for (const auto &Sym : Symbols) {
- std::string IDStr;
- llvm::raw_string_ostream OS(IDStr);
- OS << Sym.ID;
- Ctx->reportResult(OS.str(), SymbolToYAML(Sym));
+ Ctx->reportResult(Sym.ID.str(), SymbolToYAML(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=330835&r1=330834&r2=330835&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Wed Apr 25 08:27:09 2018
@@ -31,6 +31,13 @@ raw_ostream &operator<<(raw_ostream &OS,
return OS;
}
+std::string SymbolID::str() const {
+ std::string ID;
+ llvm::raw_string_ostream OS(ID);
+ OS << *this;
+ return OS.str();
+}
+
void operator>>(StringRef Str, SymbolID &ID) {
std::string HexString = fromHex(Str);
assert(HexString.size() == ID.HashValue.size());
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=330835&r1=330834&r2=330835&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Wed Apr 25 08:27:09 2018
@@ -69,6 +69,9 @@ public:
return HashValue < Sym.HashValue;
}
+ // Returns a 40-bytes hex encoded string.
+ std::string str() const;
+
private:
static constexpr unsigned HashByteLength = 20;
More information about the cfe-commits
mailing list