clang-format

pull/13357/head
Mark D. Roth 8 years ago
parent 3228489f0b
commit d3984c32c8
  1. 1
      src/core/lib/support/debug_location.h
  2. 4
      src/core/lib/support/reference_counted.cc
  3. 2
      src/core/lib/support/reference_counted.h
  4. 8
      src/core/lib/support/reference_counted_ptr.h
  5. 4
      test/core/support/reference_counted_ptr_test.cc
  6. 4
      test/core/support/reference_counted_test.cc

@ -28,6 +28,7 @@ class DebugLocation {
bool Log() const { return true; } bool Log() const { return true; }
const char* file() const { return file_; } const char* file() const { return file_; }
int line() const { return line_; } int line() const { return line_; }
private: private:
const char* file_; const char* file_;
const int line_; const int line_;

@ -34,9 +34,7 @@ void ReferenceCounted::Ref(const DebugLocation& location, const char* reason) {
Ref(); Ref();
} }
void ReferenceCounted::Ref() { void ReferenceCounted::Ref() { gpr_ref(&refs_); }
gpr_ref(&refs_);
}
bool ReferenceCounted::Unref(const DebugLocation& location, bool ReferenceCounted::Unref(const DebugLocation& location,
const char* reason) { const char* reason) {

@ -40,7 +40,7 @@ class ReferenceCounted {
protected: protected:
// Allow Delete() to access destructor. // Allow Delete() to access destructor.
template<typename T> template <typename T>
friend void Delete(T*); friend void Delete(T*);
explicit ReferenceCounted(TraceFlag* trace_flag) : trace_flag_(trace_flag) { explicit ReferenceCounted(TraceFlag* trace_flag) : trace_flag_(trace_flag) {

@ -27,15 +27,13 @@ namespace grpc_core {
// A smart pointer class for objects that provide Ref() and Unref() methods, // A smart pointer class for objects that provide Ref() and Unref() methods,
// such as those provided by the ReferenceCounted base class. // such as those provided by the ReferenceCounted base class.
template<typename T> template <typename T>
class ReferenceCountedPtr { class ReferenceCountedPtr {
public: public:
ReferenceCountedPtr() {} ReferenceCountedPtr() {}
// If value is non-null, we take ownership of a ref to it. // If value is non-null, we take ownership of a ref to it.
explicit ReferenceCountedPtr(T* value) { explicit ReferenceCountedPtr(T* value) { value_ = value; }
value_ = value;
}
// Move support. // Move support.
ReferenceCountedPtr(ReferenceCountedPtr&& other) { ReferenceCountedPtr(ReferenceCountedPtr&& other) {
@ -80,7 +78,7 @@ class ReferenceCountedPtr {
T* value_ = nullptr; T* value_ = nullptr;
}; };
template<typename T, typename... Args> template <typename T, typename... Args>
inline ReferenceCountedPtr<T> MakeReferenceCounted(Args&&... args) { inline ReferenceCountedPtr<T> MakeReferenceCounted(Args&&... args) {
return ReferenceCountedPtr<T>(New<T>(std::forward<Args>(args)...)); return ReferenceCountedPtr<T>(New<T>(std::forward<Args>(args)...));
} }

@ -41,9 +41,7 @@ class Foo : public ReferenceCounted {
int value_; int value_;
}; };
TEST(ReferenceCountedPtr, DefaultConstructor) { TEST(ReferenceCountedPtr, DefaultConstructor) { ReferenceCountedPtr<Foo> foo; }
ReferenceCountedPtr<Foo> foo;
}
TEST(ReferenceCountedPtr, ExplicitConstructorEmpty) { TEST(ReferenceCountedPtr, ExplicitConstructorEmpty) {
ReferenceCountedPtr<Foo> foo(nullptr); ReferenceCountedPtr<Foo> foo(nullptr);

@ -31,9 +31,7 @@ class Foo : public ReferenceCounted {
Foo() : ReferenceCounted(nullptr) {} Foo() : ReferenceCounted(nullptr) {}
}; };
TEST(ReferenceCounted, StackAllocated) { TEST(ReferenceCounted, StackAllocated) { Foo foo; }
Foo foo;
}
TEST(ReferenceCounted, StackAllocatedWithExtraRef) { TEST(ReferenceCounted, StackAllocatedWithExtraRef) {
Foo foo; Foo foo;

Loading…
Cancel
Save