mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 773014 - Part 2: Mark Static{Auto,Ref}Ptr as global-only; r=jrmuizel
This commit is contained in:
parent
5726a71b1a
commit
66d94da660
@ -1031,7 +1031,7 @@ imgLoader::imgLoader()
|
||||
already_AddRefed<imgLoader>
|
||||
imgLoader::GetInstance()
|
||||
{
|
||||
static StaticRefPtr<imgLoader> singleton;
|
||||
static nsRefPtr<imgLoader> singleton;
|
||||
if (!singleton) {
|
||||
singleton = imgLoader::Create();
|
||||
if (!singleton)
|
||||
|
@ -495,6 +495,10 @@
|
||||
* class uses this class, or if another class inherits from this class, then
|
||||
* it is considered to be a non-heap class as well, although this attribute
|
||||
* need not be provided in such cases.
|
||||
* MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS: Applies to all classes that are
|
||||
* intended to prevent introducing static initializers. This attribute
|
||||
* currently makes it a compile-time error to instantiate these classes
|
||||
* anywhere other than at the global scope, or as a static member of a class.
|
||||
* MOZ_HEAP_ALLOCATOR: Applies to any function. This indicates that the return
|
||||
* value is allocated on the heap, and will as a result check such allocations
|
||||
* during MOZ_STACK_CLASS and MOZ_NONHEAP_CLASS annotation checking.
|
||||
@ -509,6 +513,7 @@
|
||||
# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
|
||||
# define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
|
||||
# define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
|
||||
# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class")))
|
||||
# define MOZ_IMPLICIT __attribute__((annotate("moz_implicit")))
|
||||
# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg")))
|
||||
/*
|
||||
@ -525,6 +530,7 @@
|
||||
# define MOZ_MUST_OVERRIDE /* nothing */
|
||||
# define MOZ_STACK_CLASS /* nothing */
|
||||
# define MOZ_NONHEAP_CLASS /* nothing */
|
||||
# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */
|
||||
# define MOZ_IMPLICIT /* nothing */
|
||||
# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT /* nothing */
|
||||
# define MOZ_HEAP_ALLOCATOR /* nothing */
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define mozilla_StaticPtr_h
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -25,17 +26,16 @@ namespace mozilla {
|
||||
* upon destruction.
|
||||
*
|
||||
* Since the compiler guarantees that all global variables are initialized to
|
||||
* 0, these trivial constructors are safe, so long as you use
|
||||
* Static{Auto,Ref}Ptr as a global variable. If you use Static{Auto,Ref}Ptr as
|
||||
* a stack variable or as a class instance variable, you will get what you
|
||||
* deserve.
|
||||
* 0, these trivial constructors are safe. Since we rely on this, the clang
|
||||
* plugin, run as part of our "static analysis" builds, makes it a compile-time
|
||||
* error to use Static{Auto,Ref}Ptr as anything except a global variable.
|
||||
*
|
||||
* Static{Auto,Ref}Ptr have a limited interface as compared to ns{Auto,Ref}Ptr;
|
||||
* this is intentional, since their range of acceptable uses is smaller.
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
class StaticAutoPtr
|
||||
class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS StaticAutoPtr
|
||||
{
|
||||
public:
|
||||
// In debug builds, check that mRawPtr is initialized for us as we expect
|
||||
@ -87,7 +87,7 @@ private:
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class StaticRefPtr
|
||||
class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS StaticRefPtr
|
||||
{
|
||||
public:
|
||||
// In debug builds, check that mRawPtr is initialized for us as we expect
|
||||
|
Loading…
Reference in New Issue
Block a user