[clangd] Fix subtle use after return.

I didn't find this because my main development machine still happens to
use libstdc++ with the broken C++11 ABI, which has a global empty
string.

llvm-svn: 294309
This commit is contained in:
Benjamin Kramer 2017-02-07 14:35:09 +00:00
parent 8c0f62d293
commit 81f91c1777

View File

@ -26,7 +26,10 @@ public:
/// Delete a document from the store.
void removeDocument(StringRef Uri) { Docs.erase(Uri); }
/// Retrieve a document from the store. Empty string if it's unknown.
StringRef getDocument(StringRef Uri) const { return Docs.lookup(Uri); }
StringRef getDocument(StringRef Uri) const {
auto I = Docs.find(Uri);
return I == Docs.end() ? StringRef("") : StringRef(I->second);
}
private:
llvm::StringMap<std::string> Docs;