diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-10-20 15:30:37 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-10-20 15:30:37 +0000 |
| commit | c008af646620f6718384c2cd95f58a7311fe10fb (patch) | |
| tree | 4961c6079af876f19462df09f9a0d0fa1176a824 /clang-tools-extra/clangd/Protocol.cpp | |
| parent | 0c35aa114d34c4f8add2a532de3a797ef0c1b667 (diff) | |
| download | bcm5719-llvm-c008af646620f6718384c2cd95f58a7311fe10fb.tar.gz bcm5719-llvm-c008af646620f6718384c2cd95f58a7311fe10fb.zip | |
[clangd] Namespace style cleanup in cpp files. NFC.
Standardize on the most common namespace setup in our *.cpp files:
using namespace llvm;
namespace clang {
namespace clangd {
void foo(StringRef) { ... }
And remove redundant llvm:: qualifiers. (Except for cases like
make_unique where this causes problems with std:: and ADL).
This choice is pretty arbitrary, but some broad consistency is nice.
This is going to conflict with everything. Sorry :-/
Squash the other configurations:
A)
using namespace llvm;
using namespace clang;
using namespace clangd;
void clangd::foo(StringRef);
This is in some of the older files. (It prevents accidentally defining a
new function instead of one in the header file, for what that's worth).
B)
namespace clang {
namespace clangd {
void foo(llvm::StringRef) { ... }
This is fine, but in practice the using directive often gets added over time.
C)
namespace clang {
namespace clangd {
using namespace llvm; // inside the namespace
This was pretty common, but is a bit misleading: name lookup preferrs
clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using
directive is).
llvm-svn: 344850
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/Protocol.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index 805225a2434..3622a43c18e 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -21,14 +21,14 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +using namespace llvm; namespace clang { namespace clangd { -using namespace llvm; char LSPError::ID; URIForFile::URIForFile(std::string AbsPath) { - assert(llvm::sys::path::is_absolute(AbsPath) && "the path is relative"); + assert(sys::path::is_absolute(AbsPath) && "the path is relative"); File = std::move(AbsPath); } @@ -57,7 +57,7 @@ bool fromJSON(const json::Value &E, URIForFile &R) { json::Value toJSON(const URIForFile &U) { return U.uri(); } -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const URIForFile &U) { +raw_ostream &operator<<(raw_ostream &OS, const URIForFile &U) { return OS << U.uri(); } @@ -82,7 +82,7 @@ json::Value toJSON(const Position &P) { }; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Position &P) { +raw_ostream &operator<<(raw_ostream &OS, const Position &P) { return OS << P.line << ':' << P.character; } @@ -98,7 +98,7 @@ json::Value toJSON(const Range &P) { }; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Range &R) { +raw_ostream &operator<<(raw_ostream &OS, const Range &R) { return OS << R.start << '-' << R.end; } @@ -109,7 +109,7 @@ json::Value toJSON(const Location &P) { }; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Location &L) { +raw_ostream &operator<<(raw_ostream &OS, const Location &L) { return OS << L.range << '@' << L.uri; } @@ -139,7 +139,7 @@ json::Value toJSON(const TextEdit &P) { }; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const TextEdit &TE) { +raw_ostream &operator<<(raw_ostream &OS, const TextEdit &TE) { OS << TE.range << " => \""; printEscapedString(TE.newText, OS); return OS << '"'; @@ -342,7 +342,7 @@ bool fromJSON(const json::Value &Params, DocumentSymbolParams &R) { return O && O.map("textDocument", R.textDocument); } -llvm::json::Value toJSON(const Diagnostic &D) { +json::Value toJSON(const Diagnostic &D) { json::Object Diag{ {"range", D.range}, {"severity", D.severity}, @@ -366,7 +366,7 @@ bool fromJSON(const json::Value &Params, CodeActionContext &R) { return O && O.map("diagnostics", R.diagnostics); } -llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diagnostic &D) { +raw_ostream &operator<<(raw_ostream &OS, const Diagnostic &D) { OS << D.range << " ["; switch (D.severity) { case 1: @@ -399,7 +399,7 @@ bool fromJSON(const json::Value &Params, WorkspaceEdit &R) { return O && O.map("changes", R.changes); } -const llvm::StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND = +const StringLiteral ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND = "clangd.applyFix"; bool fromJSON(const json::Value &Params, ExecuteCommandParams &R) { json::ObjectMapper O(Params); @@ -423,8 +423,7 @@ json::Value toJSON(const SymbolInformation &P) { }; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &O, - const SymbolInformation &SI) { +raw_ostream &operator<<(raw_ostream &O, const SymbolInformation &SI) { O << SI.containerName << "::" << SI.name << " - " << toJSON(SI); return O; } @@ -441,9 +440,9 @@ json::Value toJSON(const Command &C) { return std::move(Cmd); } -const llvm::StringLiteral CodeAction::QUICKFIX_KIND = "quickfix"; +const StringLiteral CodeAction::QUICKFIX_KIND = "quickfix"; -llvm::json::Value toJSON(const CodeAction &CA) { +json::Value toJSON(const CodeAction &CA) { auto CodeAction = json::Object{{"title", CA.title}}; if (CA.kind) CodeAction["kind"] = *CA.kind; @@ -575,7 +574,7 @@ json::Value toJSON(const CompletionItem &CI) { return std::move(Result); } -llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const CompletionItem &I) { +raw_ostream &operator<<(raw_ostream &O, const CompletionItem &I) { O << I.label << " - " << toJSON(I); return O; } @@ -611,8 +610,7 @@ json::Value toJSON(const SignatureInformation &SI) { return std::move(Result); } -llvm::raw_ostream &operator<<(llvm::raw_ostream &O, - const SignatureInformation &I) { +raw_ostream &operator<<(raw_ostream &O, const SignatureInformation &I) { O << I.label << " - " << toJSON(I); return O; } @@ -642,8 +640,7 @@ json::Value toJSON(const DocumentHighlight &DH) { }; } -llvm::raw_ostream &operator<<(llvm::raw_ostream &O, - const DocumentHighlight &V) { +raw_ostream &operator<<(raw_ostream &O, const DocumentHighlight &V) { O << V.range; if (V.kind == DocumentHighlightKind::Read) O << "(r)"; @@ -657,8 +654,7 @@ bool fromJSON(const json::Value &Params, DidChangeConfigurationParams &CCP) { return O && O.map("settings", CCP.settings); } -bool fromJSON(const llvm::json::Value &Params, - ClangdCompileCommand &CDbUpdate) { +bool fromJSON(const json::Value &Params, ClangdCompileCommand &CDbUpdate) { json::ObjectMapper O(Params); return O && O.map("workingDirectory", CDbUpdate.workingDirectory) && O.map("compilationCommand", CDbUpdate.compilationCommand); |

