Bug 1131783 - Optimize away null checks in non-POD Vectors too r=waldo

This commit is contained in:
Dan Gohman 2015-02-12 08:37:01 -08:00
parent 45a9e8d6b5
commit 3a947820fc
2 changed files with 18 additions and 0 deletions

View File

@ -212,6 +212,22 @@
# define MOZ_COLD
#endif
/**
* MOZ_NONNULL tells the compiler that some of the arguments to a function are
* known to be non-null. The arguments are a list of 1-based argument indexes
* identifying arguments which are known to be non-null.
*
* Place this attribute at the very beginning of a function definition. For
* example, write
*
* MOZ_NONNULL(1, 2) int foo(char *p, char *q);
*/
#if defined(__GNUC__) || defined(__clang__)
# define MOZ_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__)))
#else
# define MOZ_NONNULL(...)
#endif
/*
* MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS, specified at the end of a function
* declaration, indicates that for the purposes of static analysis, this

View File

@ -58,6 +58,7 @@ struct VectorImpl
/*
* Constructs a default object in the uninitialized memory at *aDst.
*/
MOZ_NONNULL(1)
static inline void new_(T* aDst)
{
new(aDst) T();
@ -67,6 +68,7 @@ struct VectorImpl
* Constructs an object in the uninitialized memory at *aDst from aSrc.
*/
template<typename U>
MOZ_NONNULL(1)
static inline void new_(T* aDst, U&& aU)
{
new(aDst) T(Forward<U>(aU));