зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1493093 - Allow to relax MOZ_NON_TEMPORARY_CLASS for some specific constructors r=andi
Differential Revision: https://phabricator.services.mozilla.com/D6566 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fc8ac20d5a
Коммит
b487ebbc58
|
@ -1,3 +1,4 @@
|
|||
ATTR(moz_allow_temporary)
|
||||
ATTR(moz_can_run_script)
|
||||
ATTR(moz_can_run_script_boundary)
|
||||
ATTR(moz_global_class)
|
||||
|
|
|
@ -29,6 +29,10 @@ AST_MATCHER(CXXRecordDecl, hasTrivialCtorDtor) {
|
|||
return hasCustomAttribute<moz_trivial_ctor_dtor>(&Node);
|
||||
}
|
||||
|
||||
AST_MATCHER(CXXConstructExpr, allowsTemporary) {
|
||||
return hasCustomAttribute<moz_allow_temporary>(Node.getConstructor());
|
||||
}
|
||||
|
||||
/// This matcher will match lvalue-ref-qualified methods.
|
||||
AST_MATCHER(CXXMethodDecl, isLValueRefQualified) {
|
||||
return Node.getRefQualifier() == RQ_LValue;
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
void ScopeChecker::registerMatchers(MatchFinder *AstMatcher) {
|
||||
AstMatcher->addMatcher(varDecl().bind("node"), this);
|
||||
AstMatcher->addMatcher(cxxNewExpr().bind("node"), this);
|
||||
AstMatcher->addMatcher(materializeTemporaryExpr().bind("node"), this);
|
||||
AstMatcher->addMatcher(
|
||||
materializeTemporaryExpr(
|
||||
unless(hasDescendant(cxxConstructExpr(allowsTemporary())))
|
||||
).bind("node"), this);
|
||||
AstMatcher->addMatcher(
|
||||
callExpr(callee(functionDecl(heapAllocator()))).bind("node"), this);
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ template<typename T>
|
|||
class Optional : public Optional_base<T, T>
|
||||
{
|
||||
public:
|
||||
Optional() :
|
||||
MOZ_ALLOW_TEMPORARY Optional() :
|
||||
Optional_base<T, T>()
|
||||
{}
|
||||
|
||||
|
@ -235,7 +235,7 @@ class Optional<JS::Handle<T> > :
|
|||
public Optional_base<JS::Handle<T>, JS::Rooted<T> >
|
||||
{
|
||||
public:
|
||||
Optional() :
|
||||
MOZ_ALLOW_TEMPORARY Optional() :
|
||||
Optional_base<JS::Handle<T>, JS::Rooted<T> >()
|
||||
{}
|
||||
|
||||
|
|
|
@ -598,6 +598,10 @@
|
|||
* or constexpr constructor and a trivial destructor. Setting this attribute
|
||||
* on a class makes it a compile-time error for that class to get a
|
||||
* non-trivial constructor or destructor for any reason.
|
||||
* MOZ_ALLOW_TEMPORARY: Applies to constructors. This indicates that using the
|
||||
* constructor is allowed in temporary expressions, if it would have otherwise
|
||||
* been forbidden by the type being a MOZ_NON_TEMPORARY_CLASS. Useful for
|
||||
* constructors like Maybe(Nothing).
|
||||
* 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.
|
||||
|
@ -721,6 +725,7 @@
|
|||
# define MOZ_NON_TEMPORARY_CLASS __attribute__((annotate("moz_non_temporary_class")))
|
||||
# define MOZ_TEMPORARY_CLASS __attribute__((annotate("moz_temporary_class")))
|
||||
# define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor")))
|
||||
# define MOZ_ALLOW_TEMPORARY __attribute__((annotate("moz_allow_temporary")))
|
||||
# ifdef DEBUG
|
||||
/* in debug builds, these classes do have non-trivial constructors. */
|
||||
# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class")))
|
||||
|
@ -776,6 +781,7 @@
|
|||
# define MOZ_NON_TEMPORARY_CLASS /* nothing */
|
||||
# define MOZ_TEMPORARY_CLASS /* nothing */
|
||||
# define MOZ_TRIVIAL_CTOR_DTOR /* nothing */
|
||||
# define MOZ_ALLOW_TEMPORARY /* nothing */
|
||||
# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */
|
||||
# define MOZ_IMPLICIT /* nothing */
|
||||
# define MOZ_IS_SMARTPTR_TO_REFCOUNTED /* nothing */
|
||||
|
|
|
@ -182,12 +182,12 @@ class MOZ_NON_PARAM MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Maybe
|
|||
public:
|
||||
using ValueType = T;
|
||||
|
||||
Maybe() : mIsSome(false)
|
||||
MOZ_ALLOW_TEMPORARY Maybe() : mIsSome(false)
|
||||
{
|
||||
}
|
||||
~Maybe() { reset(); }
|
||||
|
||||
MOZ_IMPLICIT Maybe(Nothing) : mIsSome(false)
|
||||
MOZ_ALLOW_TEMPORARY MOZ_IMPLICIT Maybe(Nothing) : mIsSome(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче