Skip to content

Commit

Permalink
Run clang-tidy modernize-use-equals-{delete,default} on //sql
Browse files Browse the repository at this point in the history
modernize-use-equals-delete marks unimplemented and private special member
functions with "= delete". This more clearly communicates intent and improves
error messages.

modernize-use-equals-default rewrites special member functions whose behavior
matches the default, with "= default". This:
 * Greatly simplifies copy and move constructors, and copy assign and move
   assign operators because the members don't need to be manually written.
 * In some cases allows classes that were previously non-aggregates or
   non-trivial to become aggregates or trivial. Explicitly writing an empty
   body for default constructor disqualifies it from being trivial.
   Trivial classes and member functions can be better optimized by the
   compiler and library (via type traits).
 * Lets the defaulted functions and constructors to be constexpr if the
   implicit version would have been.
 * More clearly communicates intent, especially to distinguish member
   functions that aren't customized against those that are.

This change was done using clang-tidy as described here:
https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md

In some cases the the tool leaves behind a string of commas where it
replaced a member initializer list
(https://bugs.llvm.org/show_bug.cgi?id=35051). Clean them up with:
  git diff --name-only | \
    xargs sed -E -i 's/(^\s*|\)\s*):[ ,]*= default/\1 = default/'

See the relevant cxx post for more details:
https://groups.google.com/a/chromium.org/forum/#!topic/cxx/RkOHzIK6Tq8

BUG=778959,778957

Change-Id: I0fb961bb4ba00befba4da08fa7fc625080b46fee
Reviewed-on: https://chromium-review.googlesource.com/790031
Reviewed-by: Victor Costan <pwnall@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519209}
  • Loading branch information
Chris Watkins authored and Commit Bot committed Nov 27, 2017
1 parent ba9c2f0 commit cf61725
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sql/connection_memory_dump_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ConnectionMemoryDumpProvider::ConnectionMemoryDumpProvider(
const std::string& name)
: db_(db), connection_name_(name) {}

ConnectionMemoryDumpProvider::~ConnectionMemoryDumpProvider() {}
ConnectionMemoryDumpProvider::~ConnectionMemoryDumpProvider() = default;

void ConnectionMemoryDumpProvider::ResetDatabase() {
base::AutoLock lock(lock_);
Expand Down
2 changes: 1 addition & 1 deletion sql/connection_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ScopedMockTimeSource {
MockTimeSource(ScopedMockTimeSource& owner)
: owner_(owner) {
}
~MockTimeSource() override {}
~MockTimeSource() override = default;

base::TimeTicks Now() override {
base::TimeTicks ret(owner_.current_time_);
Expand Down
3 changes: 1 addition & 2 deletions sql/meta_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ namespace sql {
MetaTable::MetaTable() : db_(NULL) {
}

MetaTable::~MetaTable() {
}
MetaTable::~MetaTable() = default;

// static
constexpr int64_t MetaTable::kMmapFailure;
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_memory_dump_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ SqlMemoryDumpProvider* SqlMemoryDumpProvider::GetInstance() {
base::LeakySingletonTraits<SqlMemoryDumpProvider>>::get();
}

SqlMemoryDumpProvider::SqlMemoryDumpProvider() {}
SqlMemoryDumpProvider::SqlMemoryDumpProvider() = default;

SqlMemoryDumpProvider::~SqlMemoryDumpProvider() {}
SqlMemoryDumpProvider::~SqlMemoryDumpProvider() = default;

bool SqlMemoryDumpProvider::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
Expand Down
6 changes: 2 additions & 4 deletions sql/test/sql_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@

namespace sql {

SQLTestBase::SQLTestBase() {
}
SQLTestBase::SQLTestBase() = default;

SQLTestBase::~SQLTestBase() {
}
SQLTestBase::~SQLTestBase() = default;

base::FilePath SQLTestBase::db_path() {
return temp_dir_.GetPath().AppendASCII("SQLTest.db");
Expand Down
2 changes: 1 addition & 1 deletion sql/test/sql_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace sql {
SQLTestSuite::SQLTestSuite(int argc, char** argv)
: base::TestSuite(argc, argv) {}

SQLTestSuite::~SQLTestSuite() {}
SQLTestSuite::~SQLTestSuite() = default;

void SQLTestSuite::Initialize() {
base::TestSuite::Initialize();
Expand Down

0 comments on commit cf61725

Please sign in to comment.