Skip to content

Commit

Permalink
Bug 1187073 - Use MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS to …
Browse files Browse the repository at this point in the history
…validate the usage of AlignedStorage2. r=ehsan

--HG--
extra : rebase_source : 43caddb03d8bf630edd6f8f60f5dff0e8890e7b8
  • Loading branch information
mystor committed Jul 31, 2015
1 parent fd765fa commit e0cec02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mfbt/Alignment.h
Expand Up @@ -9,6 +9,7 @@
#ifndef mozilla_Alignment_h
#define mozilla_Alignment_h

#include "mozilla/Attributes.h"
#include <stddef.h>
#include <stdint.h>

Expand Down Expand Up @@ -122,7 +123,7 @@ struct AlignedStorage
};

template<typename T>
struct AlignedStorage2
struct MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS AlignedStorage2
{
union U
{
Expand Down
7 changes: 7 additions & 0 deletions mfbt/Attributes.h
Expand Up @@ -463,6 +463,10 @@
* template arguments are required to be safe to move in memory using
* memmove(). Passing MOZ_NON_MEMMOVABLE types to these templates is a
* compile time error.
* MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS: Applies to template class
* declarations where an instance of the template should be considered, for
* static analysis purposes, to inherit any type annotations (such as
* MOZ_MUST_USE and MOZ_STACK_CLASS) from its template arguments.
*/
#ifdef MOZ_CLANG_PLUGIN
# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
Expand All @@ -486,6 +490,8 @@
# define MOZ_NEEDS_NO_VTABLE_TYPE __attribute__((annotate("moz_needs_no_vtable_type")))
# define MOZ_NON_MEMMOVABLE __attribute__((annotate("moz_non_memmovable")))
# define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type")))
# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS \
__attribute__((annotate("moz_inherit_type_annotations_from_template_args")))
/*
* It turns out that clang doesn't like void func() __attribute__ {} without a
* warning, so use pragmas to disable the warning. This code won't work on GCC
Expand Down Expand Up @@ -513,6 +519,7 @@
# define MOZ_NEEDS_NO_VTABLE_TYPE /* nothing */
# define MOZ_NON_MEMMOVABLE /* nothing */
# define MOZ_NEEDS_MEMMOVABLE_TYPE /* nothing */
# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS /* nothing */
#endif /* MOZ_CLANG_PLUGIN */

#endif /* __cplusplus */
Expand Down

0 comments on commit e0cec02

Please sign in to comment.