mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 3e78fb4512a6 (bug 1187486) for static analysis failures.
This commit is contained in:
parent
8d12a449ea
commit
5a336f34d0
@ -111,11 +111,6 @@ private:
|
||||
virtual void run(const MatchFinder::MatchResult &Result);
|
||||
};
|
||||
|
||||
class ExplicitImplicitChecker : public MatchFinder::MatchCallback {
|
||||
public:
|
||||
virtual void run(const MatchFinder::MatchResult &Result);
|
||||
};
|
||||
|
||||
ScopeChecker stackClassChecker;
|
||||
ScopeChecker globalClassChecker;
|
||||
NonHeapClassChecker nonheapClassChecker;
|
||||
@ -128,7 +123,6 @@ private:
|
||||
NoDuplicateRefCntMemberChecker noDuplicateRefCntMemberChecker;
|
||||
NeedsNoVTableTypeChecker needsNoVTableTypeChecker;
|
||||
NonMemMovableChecker nonMemMovableChecker;
|
||||
ExplicitImplicitChecker explicitImplicitChecker;
|
||||
MatchFinder astMatcher;
|
||||
};
|
||||
|
||||
@ -187,6 +181,7 @@ bool isInIgnoredNamespaceForImplicitConversion(const Decl *decl) {
|
||||
}
|
||||
|
||||
bool isIgnoredPathForImplicitCtor(const Decl *decl) {
|
||||
decl = decl->getCanonicalDecl();
|
||||
SourceLocation Loc = decl->getLocation();
|
||||
const SourceManager &SM = decl->getASTContext().getSourceManager();
|
||||
SmallString<1024> FileName = SM.getFilename(Loc);
|
||||
@ -227,6 +222,11 @@ bool isIgnoredPathForImplicitConversion(const Decl *decl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isInterestingDeclForImplicitCtor(const Decl *decl) {
|
||||
return !isInIgnoredNamespaceForImplicitCtor(decl) &&
|
||||
!isIgnoredPathForImplicitCtor(decl);
|
||||
}
|
||||
|
||||
bool isInterestingDeclForImplicitConversion(const Decl *decl) {
|
||||
return !isInIgnoredNamespaceForImplicitConversion(decl) &&
|
||||
!isIgnoredPathForImplicitConversion(decl);
|
||||
@ -373,6 +373,34 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (!d->isAbstract() && isInterestingDeclForImplicitCtor(d)) {
|
||||
for (CXXRecordDecl::ctor_iterator ctor = d->ctor_begin(),
|
||||
e = d->ctor_end(); ctor != e; ++ctor) {
|
||||
// Ignore non-converting ctors
|
||||
if (!ctor->isConvertingConstructor(false)) {
|
||||
continue;
|
||||
}
|
||||
// Ignore copy or move constructors
|
||||
if (ctor->isCopyOrMoveConstructor()) {
|
||||
continue;
|
||||
}
|
||||
// Ignore deleted constructors
|
||||
if (ctor->isDeleted()) {
|
||||
continue;
|
||||
}
|
||||
// Ignore whitelisted constructors
|
||||
if (MozChecker::hasCustomAnnotation(*ctor, "moz_implicit")) {
|
||||
continue;
|
||||
}
|
||||
unsigned ctorID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Error, "bad implicit conversion constructor for %0");
|
||||
unsigned noteID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Note, "consider adding the explicit keyword to the constructor");
|
||||
Diag.Report(ctor->getLocation(), ctorID) << d->getDeclName();
|
||||
Diag.Report(ctor->getLocation(), noteID);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -784,29 +812,6 @@ AST_MATCHER(CXXRecordDecl, needsMemMovable) {
|
||||
return MozChecker::hasCustomAnnotation(&Node, "moz_needs_memmovable_type");
|
||||
}
|
||||
|
||||
AST_MATCHER(CXXConstructorDecl, isInterestingImplicitCtor) {
|
||||
const CXXConstructorDecl *decl = Node.getCanonicalDecl();
|
||||
return
|
||||
// Skip ignored namespaces and paths
|
||||
!isInIgnoredNamespaceForImplicitCtor(decl) &&
|
||||
!isIgnoredPathForImplicitCtor(decl) &&
|
||||
// We only want Converting constructors
|
||||
decl->isConvertingConstructor(false) &&
|
||||
// We don't want copy of move constructors, as those are allowed to be implicit
|
||||
!decl->isCopyOrMoveConstructor() &&
|
||||
// We don't want deleted constructors.
|
||||
!decl->isDeleted();
|
||||
}
|
||||
|
||||
// We can't call this "isImplicit" since it clashes with an existing matcher in clang.
|
||||
AST_MATCHER(CXXConstructorDecl, isMarkedImplicit) {
|
||||
return MozChecker::hasCustomAnnotation(&Node, "moz_implicit");
|
||||
}
|
||||
|
||||
AST_MATCHER(CXXRecordDecl, isConcreteClass) {
|
||||
return !Node.isAbstract();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1046,12 +1051,6 @@ DiagnosticsMatcher::DiagnosticsMatcher()
|
||||
hasAnyTemplateArgument(refersToType(isNonMemMovable())))
|
||||
).bind("specialization"),
|
||||
&nonMemMovableChecker);
|
||||
|
||||
astMatcher.addMatcher(
|
||||
constructorDecl(isInterestingImplicitCtor(),
|
||||
ofClass(allOf(isConcreteClass(), decl().bind("class"))),
|
||||
unless(isMarkedImplicit())).bind("ctor"),
|
||||
&explicitImplicitChecker);
|
||||
}
|
||||
|
||||
void DiagnosticsMatcher::ScopeChecker::run(
|
||||
@ -1326,23 +1325,6 @@ void DiagnosticsMatcher::NonMemMovableChecker::run(
|
||||
}
|
||||
}
|
||||
|
||||
void DiagnosticsMatcher::ExplicitImplicitChecker::run(
|
||||
const MatchFinder::MatchResult &Result) {
|
||||
DiagnosticsEngine &Diag = Result.Context->getDiagnostics();
|
||||
unsigned ErrorID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Error, "bad implicit conversion constructor for %0");
|
||||
unsigned NoteID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Note, "consider adding the explicit keyword to the constructor");
|
||||
|
||||
// We've already checked everything in the matcher, so we just have to report the error.
|
||||
|
||||
const CXXConstructorDecl *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
|
||||
const CXXRecordDecl *Decl = Result.Nodes.getNodeAs<CXXRecordDecl>("class");
|
||||
|
||||
Diag.Report(Ctor->getLocation(), ErrorID) << Decl->getDeclName();
|
||||
Diag.Report(Ctor->getLocation(), NoteID);
|
||||
}
|
||||
|
||||
class MozCheckAction : public PluginASTAction {
|
||||
public:
|
||||
ASTConsumerPtr CreateASTConsumer(CompilerInstance &CI, StringRef fileName) override {
|
||||
|
@ -4,8 +4,6 @@ struct Foo {
|
||||
Foo(int); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
|
||||
Foo(int, char=0); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
|
||||
Foo(...); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
|
||||
template<class T>
|
||||
Foo(float); // expected-error {{bad implicit conversion constructor for 'Foo'}} expected-note {{consider adding the explicit keyword to the constructor}}
|
||||
Foo(int, unsigned);
|
||||
Foo(Foo&);
|
||||
Foo(const Foo&);
|
||||
@ -41,10 +39,3 @@ struct Abstract {
|
||||
Abstract(...);
|
||||
virtual void f() = 0;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct Template {
|
||||
Template(int); // expected-error {{bad implicit conversion constructor for 'Template'}} expected-note {{consider adding the explicit keyword to the constructor}}
|
||||
template<class U>
|
||||
Template(float); // expected-error {{bad implicit conversion constructor for 'Template'}} expected-note {{consider adding the explicit keyword to the constructor}}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user