зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1569681) for causing build bustages. CLOSED TREE
Backed out changeset 292cc6853e82 (bug 1569681) Backed out changeset 4d0a7b968eb0 (bug 1569681) Backed out changeset be9e5f8f00d0 (bug 1569681)
This commit is contained in:
Родитель
824e154440
Коммит
fbddadbfab
|
@ -24,7 +24,5 @@ ATTR(moz_non_temporary_class)
|
|||
ATTR(moz_nonheap_class)
|
||||
ATTR(moz_required_base_method)
|
||||
ATTR(moz_stack_class)
|
||||
ATTR(moz_static_local_class)
|
||||
ATTR(moz_temporary_class)
|
||||
ATTR(moz_trivial_ctor_dtor)
|
||||
ATTR(moz_trivial_dtor)
|
||||
|
|
|
@ -29,12 +29,6 @@ AST_MATCHER(CXXRecordDecl, hasTrivialCtorDtor) {
|
|||
return hasCustomAttribute<moz_trivial_ctor_dtor>(&Node);
|
||||
}
|
||||
|
||||
/// This matcher will match any C++ class that is marked as having a trivial
|
||||
/// destructor.
|
||||
AST_MATCHER(CXXRecordDecl, hasTrivialDtor) {
|
||||
return hasCustomAttribute<moz_trivial_dtor>(&Node);
|
||||
}
|
||||
|
||||
AST_MATCHER(CXXConstructExpr, allowsTemporary) {
|
||||
return hasCustomAttribute<moz_allow_temporary>(Node.getConstructor());
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ CustomTypeAnnotation NonTemporaryClass =
|
|||
CustomTypeAnnotation(moz_non_temporary_class, "non-temporary");
|
||||
CustomTypeAnnotation TemporaryClass =
|
||||
CustomTypeAnnotation(moz_temporary_class, "temporary");
|
||||
CustomTypeAnnotation StaticLocalClass =
|
||||
CustomTypeAnnotation(moz_static_local_class, "static-local");
|
||||
|
||||
void CustomTypeAnnotation::dumpAnnotationReason(BaseCheck &Check, QualType T,
|
||||
SourceLocation Loc) {
|
||||
|
|
|
@ -70,6 +70,5 @@ extern CustomTypeAnnotation NonHeapClass;
|
|||
extern CustomTypeAnnotation HeapClass;
|
||||
extern CustomTypeAnnotation NonTemporaryClass;
|
||||
extern CustomTypeAnnotation TemporaryClass;
|
||||
extern CustomTypeAnnotation StaticLocalClass;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,6 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
AllocationVariety Variety = AV_None;
|
||||
SourceLocation Loc;
|
||||
QualType T;
|
||||
bool isStaticLocal = false;
|
||||
|
||||
if (const ParmVarDecl *D =
|
||||
Result.Nodes.getNodeAs<ParmVarDecl>("node")) {
|
||||
|
@ -67,7 +66,6 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
T = D->getType();
|
||||
Loc = D->getBeginLoc();
|
||||
isStaticLocal = D->isStaticLocal();
|
||||
} else if (const CXXNewExpr *E = Result.Nodes.getNodeAs<CXXNewExpr>("node")) {
|
||||
// New allocates things on the heap.
|
||||
// We don't consider placement new to do anything, as it doesn't actually
|
||||
|
@ -128,8 +126,6 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
const char *NonHeap = "variable of type %0 is not valid on the heap";
|
||||
const char *NonTemporary = "variable of type %0 is not valid in a temporary";
|
||||
const char *Temporary = "variable of type %0 is only valid as a temporary";
|
||||
const char *StaticLocal = "variable of type %0 is only valid as a static "
|
||||
"local";
|
||||
|
||||
const char *StackNote =
|
||||
"value incorrectly allocated in an automatic variable";
|
||||
|
@ -146,18 +142,12 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
StackClass.reportErrorIfPresent(*this, T, Loc, Stack, GlobalNote);
|
||||
HeapClass.reportErrorIfPresent(*this, T, Loc, Heap, GlobalNote);
|
||||
TemporaryClass.reportErrorIfPresent(*this, T, Loc, Temporary, GlobalNote);
|
||||
if (!isStaticLocal) {
|
||||
StaticLocalClass.reportErrorIfPresent(*this, T, Loc, StaticLocal,
|
||||
GlobalNote);
|
||||
}
|
||||
break;
|
||||
|
||||
case AV_Automatic:
|
||||
GlobalClass.reportErrorIfPresent(*this, T, Loc, Global, StackNote);
|
||||
HeapClass.reportErrorIfPresent(*this, T, Loc, Heap, StackNote);
|
||||
TemporaryClass.reportErrorIfPresent(*this, T, Loc, Temporary, StackNote);
|
||||
StaticLocalClass.reportErrorIfPresent(*this, T, Loc, StaticLocal,
|
||||
StackNote);
|
||||
break;
|
||||
|
||||
case AV_Temporary:
|
||||
|
@ -165,8 +155,6 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
HeapClass.reportErrorIfPresent(*this, T, Loc, Heap, TemporaryNote);
|
||||
NonTemporaryClass.reportErrorIfPresent(*this, T, Loc, NonTemporary,
|
||||
TemporaryNote);
|
||||
StaticLocalClass.reportErrorIfPresent(*this, T, Loc, StaticLocal,
|
||||
TemporaryNote);
|
||||
break;
|
||||
|
||||
case AV_Heap:
|
||||
|
@ -174,7 +162,6 @@ void ScopeChecker::check(const MatchFinder::MatchResult &Result) {
|
|||
StackClass.reportErrorIfPresent(*this, T, Loc, Stack, HeapNote);
|
||||
NonHeapClass.reportErrorIfPresent(*this, T, Loc, NonHeap, HeapNote);
|
||||
TemporaryClass.reportErrorIfPresent(*this, T, Loc, Temporary, HeapNote);
|
||||
StaticLocalClass.reportErrorIfPresent(*this, T, Loc, StaticLocal, HeapNote);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "TrivialDtorChecker.h"
|
||||
#include "CustomMatchers.h"
|
||||
|
||||
void TrivialDtorChecker::registerMatchers(MatchFinder *AstMatcher) {
|
||||
AstMatcher->addMatcher(cxxRecordDecl(hasTrivialDtor()).bind("node"),
|
||||
this);
|
||||
}
|
||||
|
||||
void TrivialDtorChecker::check(const MatchFinder::MatchResult &Result) {
|
||||
const char *Error = "class %0 must have a trivial destructor";
|
||||
const CXXRecordDecl *Node = Result.Nodes.getNodeAs<CXXRecordDecl>("node");
|
||||
|
||||
if (!Node->hasDefinition()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool BadDtor = !Node->hasTrivialDestructor();
|
||||
if (BadDtor)
|
||||
diag(Node->getBeginLoc(), Error, DiagnosticIDs::Error) << Node;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef TrivialDtorChecker_h__
|
||||
#define TrivialDtorChecker_h__
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
class TrivialDtorChecker : public BaseCheck {
|
||||
public:
|
||||
TrivialDtorChecker(StringRef CheckName, ContextType *Context = nullptr)
|
||||
: BaseCheck(CheckName, Context) {}
|
||||
void registerMatchers(MatchFinder *AstMatcher) override;
|
||||
void check(const MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -40,7 +40,6 @@ HOST_SOURCES += [
|
|||
'ScopeChecker.cpp',
|
||||
'SprintfLiteralChecker.cpp',
|
||||
'TrivialCtorDtorChecker.cpp',
|
||||
'TrivialDtorChecker.cpp',
|
||||
'VariableUsageHelpers.cpp',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
#define MOZ_STATIC_LOCAL_CLASS __attribute__((annotate("moz_static_local_class")))
|
||||
#include <stddef.h>
|
||||
|
||||
struct MOZ_STATIC_LOCAL_CLASS StaticLocal {
|
||||
int i;
|
||||
void *operator new(size_t x) throw() { return 0; }
|
||||
void *operator new(size_t blah, char *buffer) { return buffer; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct MOZ_STATIC_LOCAL_CLASS TemplateClass {
|
||||
T i;
|
||||
};
|
||||
|
||||
void gobble(void *) { }
|
||||
|
||||
void misuseStaticLocalClass(int len) {
|
||||
StaticLocal notValid; // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated in an automatic variable}}
|
||||
StaticLocal alsoNotValid[2]; // expected-error {{variable of type 'StaticLocal [2]' is only valid as a static-local}} expected-note {{'StaticLocal [2]' is a static-local type because it is an array of static-local type 'StaticLocal'}} expected-note {{value incorrectly allocated in an automatic variable}}
|
||||
static StaticLocal valid;
|
||||
static StaticLocal alsoValid[2];
|
||||
|
||||
gobble(¬Valid);
|
||||
gobble(&valid);
|
||||
gobble(&alsoValid[0]);
|
||||
|
||||
gobble(new StaticLocal); // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated on the heap}}
|
||||
gobble(new StaticLocal[10]); // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated on the heap}}
|
||||
gobble(new TemplateClass<int>); // expected-error {{variable of type 'TemplateClass<int>' is only valid as a static-local}} expected-note {{value incorrectly allocated on the heap}}
|
||||
gobble(len <= 5 ? &valid : new StaticLocal); // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated on the heap}}
|
||||
|
||||
char buffer[sizeof(StaticLocal)];
|
||||
gobble(new (buffer) StaticLocal);
|
||||
}
|
||||
|
||||
StaticLocal notValid; // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated in a global variable}}
|
||||
|
||||
struct RandomClass {
|
||||
StaticLocal nonstaticMember; // expected-note {{'RandomClass' is a static-local type because member 'nonstaticMember' is a static-local type 'StaticLocal'}}
|
||||
static StaticLocal staticMember; // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated in a global variable}}
|
||||
};
|
||||
|
||||
struct MOZ_STATIC_LOCAL_CLASS RandomStaticLocalClass {
|
||||
StaticLocal nonstaticMember;
|
||||
static StaticLocal staticMember; // expected-error {{variable of type 'StaticLocal' is only valid as a static-local}} expected-note {{value incorrectly allocated in a global variable}}
|
||||
};
|
||||
|
||||
struct BadInherit : StaticLocal {}; // expected-note {{'BadInherit' is a static-local type because it inherits from a static-local type 'StaticLocal'}}
|
||||
struct MOZ_STATIC_LOCAL_CLASS GoodInherit : StaticLocal {};
|
||||
|
||||
void misuseStaticLocalClassEvenMore(int len) {
|
||||
BadInherit moreInvalid; // expected-error {{variable of type 'BadInherit' is only valid as a static-local}} expected-note {{value incorrectly allocated in an automatic variable}}
|
||||
RandomClass evenMoreInvalid; // expected-error {{variable of type 'RandomClass' is only valid as a static-local}} expected-note {{value incorrectly allocated in an automatic variable}}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
#define MOZ_TRIVIAL_DTOR __attribute__((annotate("moz_trivial_dtor")))
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR EmptyClass{};
|
||||
|
||||
template <class T>
|
||||
struct MOZ_TRIVIAL_DTOR TemplateEmptyClass{};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR NonEmptyClass {
|
||||
void *m;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct MOZ_TRIVIAL_DTOR TemplateNonEmptyClass {
|
||||
T* m;
|
||||
};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR BadUserDefinedDtor { // expected-error {{class 'BadUserDefinedDtor' must have a trivial destructor}}
|
||||
~BadUserDefinedDtor() {}
|
||||
};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR BadVirtualDtor { // expected-error {{class 'BadVirtualDtor' must have a trivial destructor}}
|
||||
virtual ~BadVirtualDtor() {}
|
||||
};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR OkVirtualMember {
|
||||
virtual void f();
|
||||
};
|
||||
|
||||
void foo();
|
||||
struct MOZ_TRIVIAL_DTOR BadNonEmptyCtorDtor { // expected-error {{class 'BadNonEmptyCtorDtor' must have a trivial destructor}}
|
||||
BadNonEmptyCtorDtor() { foo(); }
|
||||
~BadNonEmptyCtorDtor() { foo(); }
|
||||
};
|
||||
|
||||
struct NonTrivialDtor {
|
||||
~NonTrivialDtor() { foo(); }
|
||||
};
|
||||
|
||||
struct VirtualMember {
|
||||
virtual void f();
|
||||
};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR BadNonTrivialDtorInBase : NonTrivialDtor { // expected-error {{class 'BadNonTrivialDtorInBase' must have a trivial destructor}}
|
||||
};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR BadNonTrivialDtorInMember { // expected-error {{class 'BadNonTrivialDtorInMember' must have a trivial destructor}}
|
||||
NonTrivialDtor m;
|
||||
};
|
||||
|
||||
struct MOZ_TRIVIAL_DTOR OkVirtualMemberInMember {
|
||||
VirtualMember m;
|
||||
};
|
||||
|
|
@ -43,10 +43,8 @@ SOURCES += [
|
|||
'TestRefCountedCopyConstructor.cpp',
|
||||
'TestSprintfLiteral.cpp',
|
||||
'TestStackClass.cpp',
|
||||
'TestStaticLocalClass.cpp',
|
||||
'TestTemporaryClass.cpp',
|
||||
'TestTrivialCtorDtor.cpp',
|
||||
'TestTrivialDtor.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
|
|
|
@ -576,14 +576,6 @@
|
|||
* class, or if another class inherits from this class, then it is considered
|
||||
* to be a static class as well, although this attribute need not be provided
|
||||
* in such cases.
|
||||
* MOZ_STATIC_LOCAL_CLASS: Applies to all classes. Any class with this
|
||||
* annotation is expected to be a static local variable, so it is
|
||||
* a compile-time error to use it, or an array of such objects, or as a
|
||||
* temporary object, or as the type of a new expression. If another class
|
||||
* inherits from this class then it is considered to be a static local
|
||||
* class as well, although this attribute need not be provided in such cases.
|
||||
* It is also a compile-time error for any class with this annotation to have
|
||||
* a non-trivial destructor.
|
||||
* MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is
|
||||
* expected to live on the stack, so it is a compile-time error to use it, or
|
||||
* an array of such objects, as a global or static variable, or as the type of
|
||||
|
@ -774,9 +766,6 @@
|
|||
__attribute__((annotate("moz_can_run_script_boundary")))
|
||||
# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override")))
|
||||
# define MOZ_STATIC_CLASS __attribute__((annotate("moz_global_class")))
|
||||
# define MOZ_STATIC_LOCAL_CLASS \
|
||||
__attribute__((annotate("moz_static_local_class"))) \
|
||||
__attribute__((annotate("moz_trivial_dtor")))
|
||||
# define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))
|
||||
# define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
|
||||
# define MOZ_HEAP_CLASS __attribute__((annotate("moz_heap_class")))
|
||||
|
@ -847,7 +836,6 @@
|
|||
# define MOZ_CAN_RUN_SCRIPT_BOUNDARY /* nothing */
|
||||
# define MOZ_MUST_OVERRIDE /* nothing */
|
||||
# define MOZ_STATIC_CLASS /* nothing */
|
||||
# define MOZ_STATIC_LOCAL_CLASS /* nothing */
|
||||
# define MOZ_STACK_CLASS /* nothing */
|
||||
# define MOZ_NONHEAP_CLASS /* nothing */
|
||||
# define MOZ_HEAP_CLASS /* nothing */
|
||||
|
|
Загрузка…
Ссылка в новой задаче