Backed out 3 changesets (bug 1569681) for causing build bustages. CLOSED TREE

Backed out changeset 075b818a46fe (bug 1569681)
Backed out changeset 2c543b239808 (bug 1569681)
Backed out changeset 21ea6fea046e (bug 1569681)
This commit is contained in:
Mihai Alexandru Michis 2019-07-29 22:53:13 +03:00
Родитель 567add1b38
Коммит ab5f499ef3
12 изменённых файлов: 0 добавлений и 188 удалений

Просмотреть файл

@ -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(&notValid);
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 */