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/Trace.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/Trace.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/Trace.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/clang-tools-extra/clangd/Trace.cpp b/clang-tools-extra/clangd/Trace.cpp index 24c1fdd74e6..8fb19cc8847 100644 --- a/clang-tools-extra/clangd/Trace.cpp +++ b/clang-tools-extra/clangd/Trace.cpp @@ -19,10 +19,10 @@ #include <atomic> #include <mutex> +using namespace llvm; namespace clang { namespace clangd { namespace trace { -using namespace llvm; namespace { // The current implementation is naive: each thread writes to Out guarded by Mu. @@ -49,7 +49,7 @@ public: // We stash a Span object in the context. It will record the start/end, // and this also allows us to look up the parent Span's information. - Context beginSpan(llvm::StringRef Name, json::Object *Args) override { + Context beginSpan(StringRef Name, json::Object *Args) override { return Context::current().derive( SpanKey, llvm::make_unique<JSONSpan>(this, Name, Args)); } @@ -62,7 +62,7 @@ public: Context::current().getExisting(SpanKey)->markEnded(); } - void instant(llvm::StringRef Name, json::Object &&Args) override { + void instant(StringRef Name, json::Object &&Args) override { captureThreadMetadata(); jsonEvent("i", json::Object{{"name", Name}, {"args", std::move(Args)}}); } @@ -80,7 +80,7 @@ public: private: class JSONSpan { public: - JSONSpan(JSONTracer *Tracer, llvm::StringRef Name, json::Object *Args) + JSONSpan(JSONTracer *Tracer, StringRef Name, json::Object *Args) : StartTime(Tracer->timestamp()), EndTime(0), Name(Name), TID(get_threadid()), Tracer(Tracer), Args(Args) { // ~JSONSpan() may run in a different thread, so we need to capture now. @@ -195,8 +195,7 @@ Session::Session(EventTracer &Tracer) { Session::~Session() { T = nullptr; } -std::unique_ptr<EventTracer> createJSONTracer(llvm::raw_ostream &OS, - bool Pretty) { +std::unique_ptr<EventTracer> createJSONTracer(raw_ostream &OS, bool Pretty) { return llvm::make_unique<JSONTracer>(OS, Pretty); } @@ -207,19 +206,19 @@ void log(const Twine &Message) { } // Returned context owns Args. -static Context makeSpanContext(llvm::Twine Name, json::Object *Args) { +static Context makeSpanContext(Twine Name, json::Object *Args) { if (!T) return Context::current().clone(); WithContextValue WithArgs{std::unique_ptr<json::Object>(Args)}; return T->beginSpan(Name.isSingleStringRef() ? Name.getSingleStringRef() - : llvm::StringRef(Name.str()), + : StringRef(Name.str()), Args); } // Span keeps a non-owning pointer to the args, which is how users access them. // The args are owned by the context though. They stick around until the // beginSpan() context is destroyed, when the tracing engine will consume them. -Span::Span(llvm::Twine Name) +Span::Span(Twine Name) : Args(T ? new json::Object() : nullptr), RestoreCtx(makeSpanContext(Name, Args)) {} |

