Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1860)

Unified Diff: Source/platform/heap/Visitor.h

Issue 813883002: replace COMPILE_ASSERT with static_assert in platform/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: final fixups Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/scroll/ScrollableArea.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Visitor.h
diff --git a/Source/platform/heap/Visitor.h b/Source/platform/heap/Visitor.h
index b4ef6e45793b9490de381f3256aae8f8d0cb83e6..df2b5568ffa6af5c70ac01b0ab046c12a3aa3dfd 100644
--- a/Source/platform/heap/Visitor.h
+++ b/Source/platform/heap/Visitor.h
@@ -65,10 +65,10 @@ template<typename T> class WeakMember;
class Visitor;
template <typename T> struct IsGarbageCollectedType;
-#define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \
- COMPILE_ASSERT(IsGarbageCollectedType<T>::value, ErrorMessage)
-#define COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, ErrorMessage) \
- COMPILE_ASSERT(!IsGarbageCollectedType<T>::value, ErrorMessage)
+#define STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \
+ static_assert(IsGarbageCollectedType<T>::value, ErrorMessage)
+#define STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, ErrorMessage) \
+ static_assert(!IsGarbageCollectedType<T>::value, ErrorMessage)
template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldWeakPointersBeMarkedStrongly strongify, typename T, typename Traits> struct CollectionBackingTraceTrait;
@@ -284,7 +284,7 @@ public:
#endif
TraceTrait<T>::mark(toDerived(), t);
- COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, AttemptedToMarkNonGarbageCollectedObject);
+ STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, "attempted to mark non garbage collected object");
}
// Member version of the one-argument templated trace method.
@@ -318,9 +318,9 @@ public:
void trace(const WeakMember<T>& t)
{
// Check that we actually know the definition of T when tracing.
- COMPILE_ASSERT(sizeof(T), WeNeedToKnowTheDefinitionOfTheTypeWeAreTracing);
+ static_assert(sizeof(T), "we need to know the definition of the type we are tracing");
registerWeakCell(const_cast<WeakMember<T>&>(t).cell());
- COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, AttemptedToWeakTraceNonGarbageCollectedObject);
+ STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, "cannot weak trace non garbage collected object");
}
template<typename T>
@@ -394,35 +394,35 @@ public:
// those off-heap collection backing stores.
template<typename T, size_t inlineCapacity> void trace(const Vector<OwnPtr<T>, inlineCapacity>& vector)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideVector);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Vector");
}
template<typename T, size_t inlineCapacity> void trace(const Vector<RefPtr<T>, inlineCapacity>& vector)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideVector);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Vector");
}
template<typename T, size_t inlineCapacity> void trace(const Vector<RawPtr<T>, inlineCapacity>& vector)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideVector);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Vector");
}
template<typename T, size_t inlineCapacity> void trace(const Vector<WeakPtr<T>, inlineCapacity>& vector)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideVector);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Vector");
}
template<typename T, size_t N> void trace(const Deque<OwnPtr<T>, N>& deque)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideDeque);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Deque");
}
template<typename T, size_t N> void trace(const Deque<RefPtr<T>, N>& deque)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideDeque);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Deque");
}
template<typename T, size_t N> void trace(const Deque<RawPtr<T>, N>& deque)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideDeque);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Deque");
}
template<typename T, size_t N> void trace(const Deque<WeakPtr<T>, N>& deque)
{
- COMPILE_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, AttemptedToTraceGarbageCollectedObjectInsideDeque);
+ STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, "cannot trace garbage collected object inside Deque");
}
#endif
@@ -434,7 +434,7 @@ public:
template<typename T> inline bool isAlive(T* obj)
{
// Check that we actually know the definition of T when tracing.
- COMPILE_ASSERT(sizeof(T), WeNeedToKnowTheDefinitionOfTheTypeWeAreTracing);
+ static_assert(sizeof(T), "T must be fully defined");
// The strongification of collections relies on the fact that once a
// collection has been strongified, there is no way that it can contain
// non-live entries, so no entries will be removed. Since you can't set
@@ -758,7 +758,7 @@ public: \
virtual void adjustAndMark(blink::Visitor* visitor) const override \
{ \
typedef WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<TYPE>::Type, blink::GarbageCollected> IsSubclassOfGarbageCollected; \
- COMPILE_ASSERT(IsSubclassOfGarbageCollected::value, OnlyGarbageCollectedObjectsCanHaveGarbageCollectedMixins); \
+ static_assert(IsSubclassOfGarbageCollected::value, "only garbage collected objects can have garbage collected mixins"); \
if (TraceEagerlyTrait<TYPE>::value) { \
if (visitor->ensureMarked(static_cast<const TYPE*>(this))) \
TraceTrait<TYPE>::trace(visitor, const_cast<TYPE*>(this)); \
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/platform/scroll/ScrollableArea.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698