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

Unified Diff: third_party/WebKit/Source/wtf/StdLibExtras.h

Issue 2694283003: Annotate ScriptWrappable-embedding singletons.
Patch Set: add XPathValue singleton Created 3 years, 10 months 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 | « third_party/WebKit/Source/wtf/Allocator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/StdLibExtras.h
diff --git a/third_party/WebKit/Source/wtf/StdLibExtras.h b/third_party/WebKit/Source/wtf/StdLibExtras.h
index 26ba1d8d02958298aacfc73daea5743ccbbce201..e88a4f6267e287ff7ddba3296ef6f65142d62d3f 100644
--- a/third_party/WebKit/Source/wtf/StdLibExtras.h
+++ b/third_party/WebKit/Source/wtf/StdLibExtras.h
@@ -26,12 +26,13 @@
#ifndef WTF_StdLibExtras_h
#define WTF_StdLibExtras_h
+#include <cstddef>
#include "base/numerics/safe_conversions.h"
+#include "wtf/Allocator.h"
#include "wtf/Assertions.h"
#include "wtf/CPU.h"
#include "wtf/LeakAnnotations.h"
#include "wtf/TypeTraits.h"
-#include <cstddef>
#if DCHECK_IS_ON()
#include "wtf/Noncopyable.h"
@@ -112,13 +113,24 @@ class StaticLocalWrapper<T, true> {
// LEAK_SANITIZER_REGISTER_STATIC_LOCAL() use, it taking care of the grungy
// details.
//
-#define DEFINE_STATIC_LOCAL(Type, Name, Arguments) \
- DEFINE_STATIC_LOCAL_CHECK_THREADSAFE_ACCESS(Name); \
- using WrappedTypeFor##Name = StaticLocalWrapper<Type>::WrapType; \
- static WrappedTypeFor##Name* WrappedInstanceFor##Name = \
- LEAK_SANITIZER_REGISTER_STATIC_LOCAL( \
- WrappedTypeFor##Name, new WrappedTypeFor##Name Arguments); \
- Type& Name = StaticLocalWrapper<Type>::unwrap(WrappedInstanceFor##Name);
+
+#define DEFINE_STATIC_LOCAL(Type, Name, Arguments) \
+ STATIC_ALLOCATED_SINGLETON() \
+ static StaticLocalWrapper<Type>::WrapType* WrappedInstanceFor##Name = \
+ LEAK_SANITIZER_REGISTER_STATIC_LOCAL( \
+ StaticLocalWrapper<Type>::WrapType, \
+ new StaticLocalWrapper<Type>::WrapType Arguments); \
+ DEFINE_STATIC_LOCAL_CHECK_THREADSAFE_ACCESS(Name); \
+ Type& Name = StaticLocalWrapper<Type>::unwrap(WrappedInstanceFor##Name)
+
+// Static local singletons that embed ScriptWrappable-derived objects are
+// problematic (see issue 688569). The clang GC plugin issues warnings
+// when encountering such singletons. If you cannot avoid introducing
+// the static local and can prove that the ScriptWrappable reference is
+// safe, you may use ALLOW_UNSAFE_SINGLETON() to disable the clang GC
+// plugin check. See issue 688569 for more details.
+//
+#define ALLOW_UNSAFE_SINGLETON() GC_PLUGIN_IGNORE("crbug.com/688569")
// Use this to declare and define a static local pointer to a ref-counted object
// so that it is leaked so that the object's destructors are not called at
« no previous file with comments | « third_party/WebKit/Source/wtf/Allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698