[clangd] Cleanup after landing documentSymbol. NFC
authorIlya Biryukov <ibiryukov@google.com>
Mon, 26 Nov 2018 09:57:41 +0000 (09:57 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Mon, 26 Nov 2018 09:57:41 +0000 (09:57 +0000)
- fix compile error on older gcc in Protocol.cpp,
- remove redundant 'llvm::' qualifiers from Protocol.cpp,
- remove unused variables in AST.cpp

llvm-svn: 347539

clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/Protocol.cpp

index e9cf2ff..9d4a61f 100644 (file)
@@ -95,11 +95,11 @@ std::string printName(const ASTContext &Ctx, const NamedDecl &ND) {
     return Out.str();
   }
   // The name was empty, so present an anonymous entity.
-  if (auto *NS = llvm::dyn_cast<NamespaceDecl>(&ND))
+  if (llvm::dyn_cast<NamespaceDecl>(&ND))
     return "(anonymous namespace)";
   if (auto *Cls = llvm::dyn_cast<RecordDecl>(&ND))
     return ("(anonymous " + Cls->getKindName() + ")").str();
-  if (auto *En = llvm::dyn_cast<EnumDecl>(&ND))
+  if (llvm::dyn_cast<EnumDecl>(&ND))
     return "(anonymous enum)";
   return "(anonymous)";
 }
index bf32a96..b7053ed 100644 (file)
@@ -455,11 +455,11 @@ json::Value toJSON(const CodeAction &CA) {
   return std::move(CodeAction);
 }
 
-llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const DocumentSymbol &S) {
+raw_ostream &operator<<(raw_ostream &O, const DocumentSymbol &S) {
   return O << S.name << " - " << toJSON(S);
 }
 
-llvm::json::Value toJSON(const DocumentSymbol &S) {
+json::Value toJSON(const DocumentSymbol &S) {
   json::Object Result{{"name", S.name},
                       {"kind", static_cast<int>(S.kind)},
                       {"range", S.range},
@@ -471,7 +471,8 @@ llvm::json::Value toJSON(const DocumentSymbol &S) {
     Result["children"] = S.children;
   if (S.deprecated)
     Result["deprecated"] = true;
-  return Result;
+  // Older gcc cannot compile 'return Result', even though it is legal.
+  return json::Value(std::move(Result));
 }
 
 json::Value toJSON(const WorkspaceEdit &WE) {