Commit 446232f1 authored by honggyu.kp's avatar honggyu.kp Committed by Commit bot

Strictly disable instantiation of AllStatic class

Since the intention of using AllStatic class is to provide classes that
only contain static method functions without member variables so it
doesn't have to be instantiated at all.

However, current implementation only disables dynamic instantiation, and
it can be detected at runtime by reaching UNREACHABLE().  And it can
still have instances allocated inside stack.

This blocks all those cases by deleting default constructor of AllStatic
class to prevent undesirable usage of it.

BUG=
R=jochen@chromium.org

Review-Url: https://codereview.chromium.org/2108273003
Cr-Commit-Position: refs/heads/master@{#37532}
parent 40511877
...@@ -46,17 +46,6 @@ void Embedded::operator delete(void* p) { ...@@ -46,17 +46,6 @@ void Embedded::operator delete(void* p) {
UNREACHABLE(); UNREACHABLE();
} }
void* AllStatic::operator new(size_t size) {
UNREACHABLE();
return invalid;
}
void AllStatic::operator delete(void* p) {
UNREACHABLE();
}
#endif #endif
......
...@@ -45,12 +45,12 @@ class Embedded { ...@@ -45,12 +45,12 @@ class Embedded {
#endif #endif
// Superclass for classes only using statics. // Superclass for classes only using static method functions.
// The subclass of AllStatic cannot be instantiated at all.
class AllStatic { class AllStatic {
#ifdef DEBUG #ifdef DEBUG
public: public:
void* operator new(size_t size); AllStatic() = delete;
void operator delete(void* p);
#endif #endif
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment