Skip to content

Commit

Permalink
Revert "Remove DISALLOW_IMPLICIT_CONSTRUCTORS()"
Browse files Browse the repository at this point in the history
This reverts commit 5625bdd.

Reason for revert: breaks compile on https://ci.chromium.org/p/chrome/builders/ci/chromeos-eve-chrome and https://ci.chromium.org/p/chrome/builders/ci/chromeos-kevin-chrome

Original change's description:
> Remove DISALLOW_IMPLICIT_CONSTRUCTORS()
>
> This removes the macro definition and presubmit checks and all existing
> instances are inlined.
>
> IWYU is left as a separate step until all DISALLOW_* macros are removed.
>
> Bug: 1010217
> Change-Id: Ibc4d90d6a1f244a01e65cd3c5a9c50e5419ea5a1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3257088
> Reviewed-by: Lei Zhang <thestig@chromium.org>
> Owners-Override: Lei Zhang <thestig@chromium.org>
> Commit-Queue: Peter Boström <pbos@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#937250}

Bug: 1010217
Change-Id: I6341be7521fde453b671d6b339eef796a49847ac
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3256685
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Owners-Override: Henrik Boström <hbos@google.com>
Commit-Queue: Tomasz Tylenda <ttylenda@chromium.org>
Cr-Commit-Position: refs/heads/main@{#937292}
  • Loading branch information
Tomasz Tylenda authored and Chromium LUCI CQ committed Nov 2, 2021
1 parent 0f8ff62 commit 15aa982
Show file tree
Hide file tree
Showing 50 changed files with 136 additions and 232 deletions.
2 changes: 1 addition & 1 deletion PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
),
),
(
r'/DISALLOW_(COPY|ASSIGN|COPY_AND_ASSIGN)\(',
r'/DISALLOW_(COPY|ASSIGN|COPY_AND_ASSIGN|IMPLICIT_CONSTRUCTORS)\(',
(
'DISALLOW_xxx macros are deprecated. See base/macros.h for details.',
),
Expand Down
6 changes: 2 additions & 4 deletions base/android/library_loader/library_prefetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ namespace android {
// the Android runtime, can be killed at any time, which is not an issue here.
class BASE_EXPORT NativeLibraryPrefetcher {
public:
NativeLibraryPrefetcher() = delete;
NativeLibraryPrefetcher(const NativeLibraryPrefetcher&) = delete;
NativeLibraryPrefetcher& operator=(const NativeLibraryPrefetcher&) = delete;

// Finds the executable code range, forks a low priority process pre-fetching
// it wait()s for the process to exit or die. If ordered_only is true, only
// the ordered section is prefetched. See GetOrdrderedTextRange() in
Expand Down Expand Up @@ -62,6 +58,8 @@ class BASE_EXPORT NativeLibraryPrefetcher {

FRIEND_TEST_ALL_PREFIXES(NativeLibraryPrefetcherTest,
TestPercentageOfResidentCode);

DISALLOW_IMPLICIT_CONSTRUCTORS(NativeLibraryPrefetcher);
};

} // namespace android
Expand Down
15 changes: 4 additions & 11 deletions base/json/json_file_value_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@

class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer {
public:
JSONFileValueSerializer() = delete;

// |json_file_path_| is the path of a file that will be destination of the
// serialization. The serializer will attempt to create the file at the
// specified location.
explicit JSONFileValueSerializer(const base::FilePath& json_file_path);

JSONFileValueSerializer(const JSONFileValueSerializer&) = delete;
JSONFileValueSerializer& operator=(const JSONFileValueSerializer&) = delete;

~JSONFileValueSerializer() override;

// DO NOT USE except in unit tests to verify the file was written properly.
Expand All @@ -47,21 +42,17 @@ class BASE_EXPORT JSONFileValueSerializer : public base::ValueSerializer {
bool SerializeInternal(const base::Value& root, bool omit_binary_values);

const base::FilePath json_file_path_;

DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueSerializer);
};

class BASE_EXPORT JSONFileValueDeserializer : public base::ValueDeserializer {
public:
JSONFileValueDeserializer() = delete;

// |json_file_path_| is the path of a file that will be source of the
// deserialization. |options| is a bitmask of JSONParserOptions.
explicit JSONFileValueDeserializer(const base::FilePath& json_file_path,
int options = 0);

JSONFileValueDeserializer(const JSONFileValueDeserializer&) = delete;
JSONFileValueDeserializer& operator=(const JSONFileValueDeserializer&) =
delete;

~JSONFileValueDeserializer() override;

// Attempt to deserialize the data structure encoded in the file passed
Expand Down Expand Up @@ -105,6 +96,8 @@ class BASE_EXPORT JSONFileValueDeserializer : public base::ValueDeserializer {
const base::FilePath json_file_path_;
const int options_;
size_t last_read_size_ = 0u;

DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueDeserializer);
};

#endif // BASE_JSON_JSON_FILE_VALUE_SERIALIZER_H_
Expand Down
6 changes: 6 additions & 0 deletions base/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
DISALLOW_COPY(TypeName); \
DISALLOW_ASSIGN(TypeName)

// DEPRECATED: See above. Disallow all implicit constructors, namely the
// default constructor, copy constructor and operator= functions.
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName() = delete; \
DISALLOW_COPY_AND_ASSIGN(TypeName)

// Used to explicitly mark the return value of a function as unused. If you are
// really sure you don't want to do anything with the return value of a function
// that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
Expand Down
8 changes: 3 additions & 5 deletions base/memory/weak_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,9 @@ class BASE_EXPORT WeakPtrFactoryBase {
template <class T>
class WeakPtrFactory : public internal::WeakPtrFactoryBase {
public:
WeakPtrFactory() = delete;

explicit WeakPtrFactory(T* ptr)
: WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}

WeakPtrFactory(const WeakPtrFactory&) = delete;
WeakPtrFactory& operator=(const WeakPtrFactory&) = delete;

~WeakPtrFactory() = default;

WeakPtr<T> GetWeakPtr() const {
Expand Down Expand Up @@ -373,6 +368,9 @@ class WeakPtrFactory : public internal::WeakPtrFactoryBase {
DCHECK(ptr_);
return weak_reference_owner_.HasRefs();
}

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory);
};

// A class may extend from SupportsWeakPtr to let others take weak pointers to
Expand Down
7 changes: 3 additions & 4 deletions base/message_loop/message_pump_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,6 @@ class MessagePumpCrApplication : public MessagePumpNSApplication {

class BASE_EXPORT MessagePumpMac {
public:
MessagePumpMac() = delete;
MessagePumpMac(const MessagePumpMac&) = delete;
MessagePumpMac& operator=(const MessagePumpMac&) = delete;

// If not on the main thread, returns a new instance of
// MessagePumpNSRunLoop.
//
Expand All @@ -439,6 +435,9 @@ class BASE_EXPORT MessagePumpMac {
// Requires NSApp to implement CrAppProtocol.
static bool IsHandlingSendEvent();
#endif // !defined(OS_IOS)

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
};

// Tasks posted to the message loop are posted under this mode, as well
Expand Down
7 changes: 3 additions & 4 deletions base/process/memory_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ void EnableTerminationOnOutOfMemory() {
// without the class.
class AdjustOOMScoreHelper {
public:
AdjustOOMScoreHelper() = delete;
AdjustOOMScoreHelper(const AdjustOOMScoreHelper&) = delete;
AdjustOOMScoreHelper& operator=(const AdjustOOMScoreHelper&) = delete;

static bool AdjustOOMScore(ProcessId process, int score);

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(AdjustOOMScoreHelper);
};

// static.
Expand Down
7 changes: 3 additions & 4 deletions base/profiler/module_cache_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ class ModuleHandleTraits : public win::HandleTraits {
public:
using Handle = HMODULE;

ModuleHandleTraits() = delete;
ModuleHandleTraits(const ModuleHandleTraits&) = delete;
ModuleHandleTraits& operator=(const ModuleHandleTraits&) = delete;

static bool CloseHandle(HMODULE handle) { return ::FreeLibrary(handle) != 0; }
static bool IsHandleValid(HMODULE handle) { return handle != nullptr; }
static HMODULE NullHandle() { return nullptr; }

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ModuleHandleTraits);
};

// HMODULE is not really a handle, and has reference count semantics, so the
Expand Down
7 changes: 3 additions & 4 deletions base/syslog_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class EventLogHandleTraits {
public:
using Handle = HANDLE;

EventLogHandleTraits() = delete;
EventLogHandleTraits(const EventLogHandleTraits&) = delete;
EventLogHandleTraits& operator=(const EventLogHandleTraits&) = delete;

// Closes the handle.
static bool CloseHandle(HANDLE handle) {
return ::DeregisterEventSource(handle) != FALSE;
Expand All @@ -53,6 +49,9 @@ class EventLogHandleTraits {

// Returns null handle value.
static HANDLE NullHandle() { return nullptr; }

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(EventLogHandleTraits);
};

using ScopedEventLogHandle =
Expand Down
6 changes: 2 additions & 4 deletions base/test/test_timeouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
// the timeouts for different environments (like TSan).
class TestTimeouts {
public:
TestTimeouts() = delete;
TestTimeouts(const TestTimeouts&) = delete;
TestTimeouts& operator=(const TestTimeouts&) = delete;

// Initializes the timeouts. Non thread-safe. Should be called exactly once
// by the test suite.
static void Initialize();
Expand Down Expand Up @@ -60,6 +56,8 @@ class TestTimeouts {
static base::TimeDelta action_timeout_;
static base::TimeDelta action_max_timeout_;
static base::TimeDelta test_launcher_timeout_;

DISALLOW_IMPLICIT_CONSTRUCTORS(TestTimeouts);
};

#endif // BASE_TEST_TEST_TIMEOUTS_H_
6 changes: 2 additions & 4 deletions base/threading/platform_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ class BASE_EXPORT PlatformThread {
virtual ~Delegate() = default;
};

PlatformThread() = delete;
PlatformThread(const PlatformThread&) = delete;
PlatformThread& operator=(const PlatformThread&) = delete;

// Gets the current thread id, which may be useful for logging purposes.
static PlatformThreadId CurrentId();

Expand Down Expand Up @@ -282,6 +278,8 @@ class BASE_EXPORT PlatformThread {

private:
static void SetCurrentThreadPriorityImpl(ThreadPriority priority);

DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformThread);
};

namespace internal {
Expand Down
6 changes: 2 additions & 4 deletions base/trace_event/builtin_categories.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,6 @@ static_assert(!StrEqConstexpr("abc", "ab"), "strings should not be equal");
// TODO(skyostil): Remove after migrating to the Perfetto client API.
class BASE_EXPORT BuiltinCategories {
public:
BuiltinCategories() = delete;
BuiltinCategories(const BuiltinCategories&) = delete;
BuiltinCategories& operator=(const BuiltinCategories&) = delete;

// Returns a built-in category name at |index| in the registry.
static constexpr const char* At(size_t index) {
return kBuiltinCategories[index];
Expand Down Expand Up @@ -530,6 +526,8 @@ class BASE_EXPORT BuiltinCategories {
return IsStringInArray(category, kBuiltinCategories,
base::size(kBuiltinCategories));
}

DISALLOW_IMPLICIT_CONSTRUCTORS(BuiltinCategories);
};

} // namespace trace_event
Expand Down
21 changes: 9 additions & 12 deletions base/win/scoped_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ class HandleTraits {
public:
using Handle = HANDLE;

HandleTraits() = delete;
HandleTraits(const HandleTraits&) = delete;
HandleTraits& operator=(const HandleTraits&) = delete;

// Closes the handle.
static bool BASE_EXPORT CloseHandle(HANDLE handle);

Expand All @@ -132,17 +128,16 @@ class HandleTraits {

// Returns NULL handle value.
static HANDLE NullHandle() { return nullptr; }

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(HandleTraits);
};

// Do-nothing verifier.
class DummyVerifierTraits {
public:
using Handle = HANDLE;

DummyVerifierTraits() = delete;
DummyVerifierTraits(const DummyVerifierTraits&) = delete;
DummyVerifierTraits& operator=(const DummyVerifierTraits&) = delete;

static void StartTracking(HANDLE handle,
const void* owner,
const void* pc1,
Expand All @@ -151,17 +146,16 @@ class DummyVerifierTraits {
const void* owner,
const void* pc1,
const void* pc2) {}

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(DummyVerifierTraits);
};

// Performs actual run-time tracking.
class BASE_EXPORT VerifierTraits {
public:
using Handle = HANDLE;

VerifierTraits() = delete;
VerifierTraits(const VerifierTraits&) = delete;
VerifierTraits& operator=(const VerifierTraits&) = delete;

static void StartTracking(HANDLE handle,
const void* owner,
const void* pc1,
Expand All @@ -170,6 +164,9 @@ class BASE_EXPORT VerifierTraits {
const void* owner,
const void* pc1,
const void* pc2);

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(VerifierTraits);
};

using UncheckedScopedHandle =
Expand Down
7 changes: 3 additions & 4 deletions base/win/scoped_hdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ class CreateDCTraits {
public:
typedef HDC Handle;

CreateDCTraits() = delete;
CreateDCTraits(const CreateDCTraits&) = delete;
CreateDCTraits& operator=(const CreateDCTraits&) = delete;

static bool CloseHandle(HDC handle) { return ::DeleteDC(handle) != FALSE; }

static bool IsHandleValid(HDC handle) { return handle != NULL; }

static HDC NullHandle() { return NULL; }

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CreateDCTraits);
};

typedef GenericScopedHandle<CreateDCTraits, DummyVerifierTraits> ScopedCreateDC;
Expand Down
3 changes: 2 additions & 1 deletion cc/PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ def CheckForDisallowMacros(input_api, output_api, allowlist=CC_SOURCE_FILES,
# DISALLOW macros are not allowed, use deleted constructors instead.
if re.search(r"\bDISALLOW_COPY\(", contents) or \
re.search(r"\bDISALLOW_ASSIGN\(", contents) or \
re.search(r"\bDISALLOW_COPY_AND_ASSIGN\(", contents):
re.search(r"\bDISALLOW_COPY_AND_ASSIGN\(", contents) or \
re.search(r"\bDISALLOW_IMPLICIT_CONSTRUCTORS\(", contents):
disallow_macro_files.append(f.LocalPath())

if disallow_macro_files:
Expand Down
8 changes: 2 additions & 6 deletions crypto/openssl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,21 @@ CRYPTO_EXPORT void ClearOpenSSLERRStack(const base::Location& location);
// the OpenSSL error stack on function exit.
class OpenSSLErrStackTracer {
public:
OpenSSLErrStackTracer() = delete;

// Pass FROM_HERE as |location|, to help track the source of OpenSSL error
// messages. Note any diagnostic emitted will be tagged with the location of
// the constructor call as it's not possible to trace a destructor's callsite.
explicit OpenSSLErrStackTracer(const base::Location& location)
: location_(location) {
EnsureOpenSSLInit();
}

OpenSSLErrStackTracer(const OpenSSLErrStackTracer&) = delete;
OpenSSLErrStackTracer& operator=(const OpenSSLErrStackTracer&) = delete;

~OpenSSLErrStackTracer() {
ClearOpenSSLERRStack(location_);
}

private:
const base::Location location_;

DISALLOW_IMPLICIT_CONSTRUCTORS(OpenSSLErrStackTracer);
};

} // namespace crypto
Expand Down
7 changes: 3 additions & 4 deletions google_apis/gaia/oauth_request_signer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class OAuthRequestSigner {

typedef std::map<std::string,std::string> Parameters;

OAuthRequestSigner() = delete;
OAuthRequestSigner(const OAuthRequestSigner&) = delete;
OAuthRequestSigner& operator=(const OAuthRequestSigner&) = delete;

// Percent encoding and decoding for OAuth.
//
// The form of percent encoding used for OAuth request signing is very
Expand Down Expand Up @@ -96,6 +92,9 @@ class OAuthRequestSigner {
const std::string& token_key,
const std::string& token_secret,
std::string* signed_result);

private:
DISALLOW_IMPLICIT_CONSTRUCTORS(OAuthRequestSigner);
};

#endif // GOOGLE_APIS_GAIA_OAUTH_REQUEST_SIGNER_H_
Loading

0 comments on commit 15aa982

Please sign in to comment.