This commit is contained in:
parent
b80d06b69e
commit
1d677c57a8
|
@ -32,7 +32,7 @@ namespace Ui {
|
|||
|
||||
class HelpBrowser : public QTextBrowser {
|
||||
public:
|
||||
HelpBrowser(QWidget* parent = nullptr) : QTextBrowser(parent), mHelpEngine(nullptr) {}
|
||||
explicit HelpBrowser(QWidget* parent = nullptr) : QTextBrowser(parent), mHelpEngine(nullptr) {}
|
||||
void setHelpEngine(QHelpEngine *helpEngine);
|
||||
QVariant loadResource(int type, const QUrl& name) override;
|
||||
private:
|
||||
|
|
|
@ -130,7 +130,7 @@ struct Analyzer {
|
|||
enum class Terminate { None, Bail, Escape, Modified, Inconclusive, Conditional };
|
||||
|
||||
struct Result {
|
||||
Result(Action action = Action::None, Terminate terminate = Terminate::None)
|
||||
explicit Result(Action action = Action::None, Terminate terminate = Terminate::None)
|
||||
: action(action), terminate(terminate)
|
||||
{}
|
||||
Action action;
|
||||
|
|
|
@ -353,7 +353,8 @@ void CheckClass::checkExplicitConstructors()
|
|||
continue;
|
||||
|
||||
if (!func.isExplicit() &&
|
||||
func.minArgCount() == 1 &&
|
||||
func.argCount() > 0 && func.minArgCount() < 2 &&
|
||||
func.argumentList.front().getTypeName() != "std::initializer_list" &&
|
||||
func.type != Function::eCopyConstructor &&
|
||||
func.type != Function::eMoveConstructor) {
|
||||
noExplicitConstructorError(func.tokenDef, scope->className, scope->type == Scope::eStruct);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
int type;
|
||||
int reallocedFromType = -1;
|
||||
const Token * allocTok;
|
||||
AllocInfo(int type_ = 0, AllocStatus status_ = NOALLOC, const Token* allocTok_ = nullptr) : status(status_), type(type_), allocTok(allocTok_) {}
|
||||
explicit AllocInfo(int type_ = 0, AllocStatus status_ = NOALLOC, const Token* allocTok_ = nullptr) : status(status_), type(type_), allocTok(allocTok_) {}
|
||||
|
||||
bool managed() const {
|
||||
return status < 0;
|
||||
|
|
|
@ -68,7 +68,7 @@ struct ForwardTraversal {
|
|||
}
|
||||
|
||||
struct Branch {
|
||||
Branch(Token* tok = nullptr) : endBlock(tok) {}
|
||||
explicit Branch(Token* tok = nullptr) : endBlock(tok) {}
|
||||
Token* endBlock = nullptr;
|
||||
Analyzer::Action action = Analyzer::Action::None;
|
||||
bool check = false;
|
||||
|
@ -857,12 +857,12 @@ Analyzer::Result valueFlowGenericForward(Token* start, const Token* end, const V
|
|||
{
|
||||
ForwardTraversal ft{a, settings};
|
||||
ft.updateRange(start, end);
|
||||
return {ft.actions, ft.terminate};
|
||||
return Analyzer::Result{ ft.actions, ft.terminate };
|
||||
}
|
||||
|
||||
Analyzer::Result valueFlowGenericForward(Token* start, const ValuePtr<Analyzer>& a, const Settings* settings)
|
||||
{
|
||||
ForwardTraversal ft{a, settings};
|
||||
ft.updateRecursive(start);
|
||||
return {ft.actions, ft.terminate};
|
||||
return Analyzer::Result{ ft.actions, ft.terminate };
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
const Token * typeEnd;
|
||||
MathLib::bigint sizeOf;
|
||||
|
||||
Type(const Token* classDef_ = nullptr, const Scope* classScope_ = nullptr, const Scope* enclosingScope_ = nullptr) :
|
||||
explicit Type(const Token* classDef_ = nullptr, const Scope* classScope_ = nullptr, const Scope* enclosingScope_ = nullptr) :
|
||||
classDef(classDef_),
|
||||
classScope(classScope_),
|
||||
enclosingScope(enclosingScope_),
|
||||
|
|
|
@ -480,6 +480,19 @@ private:
|
|||
" explicit constexpr Baz(int) {}\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkExplicitConstructors("class Token;\n" // #11126
|
||||
"struct Branch {\n"
|
||||
" Branch(Token* tok = nullptr) : endBlock(tok) {}\n"
|
||||
" Token* endBlock = nullptr;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Struct 'Branch' has a constructor with 1 argument that is not explicit.\n", errout.str());
|
||||
|
||||
checkExplicitConstructors("struct S {\n"
|
||||
" S(std::initializer_list<int> il) : v(il) {}\n"
|
||||
" std::vector<int> v;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
#define checkDuplInheritedMembers(code) checkDuplInheritedMembers_(code, __FILE__, __LINE__)
|
||||
|
|
Loading…
Reference in New Issue