From a0a5b36667c3b6b439619eeba5b090ca8943f387 Mon Sep 17 00:00:00 2001 From: Richard Quirk Date: Fri, 28 Oct 2011 22:10:19 +0200 Subject: [PATCH] Ensure single-argument constructors are explicit --- lib/check.h | 2 +- lib/checkbufferoverrun.cpp | 2 +- lib/checknullpointer.cpp | 2 +- lib/checkuninitvar.cpp | 2 +- lib/preprocessor.cpp | 2 +- lib/token.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/check.h b/lib/check.h index 2cf53b402..b438c79bf 100644 --- a/lib/check.h +++ b/lib/check.h @@ -38,7 +38,7 @@ class Check { public: /** This constructor is used when registering the CheckClass */ - Check(const std::string &aname); + explicit Check(const std::string &aname); /** This constructor is used when running checks. */ Check(const std::string &aname, const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 3985765d9..92081d767 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -191,7 +191,7 @@ public: /** * @param str Token::str() is compared against this. */ - TokenStrEquals(const std::string &str) + explicit TokenStrEquals(const std::string &str) : value(str) { } diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 8cc92bb28..15a0ee812 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -940,7 +940,7 @@ void CheckNullPointer::nullConstantDereference() class Nullpointer : public ExecutionPath { public: /** Startup constructor */ - Nullpointer(Check *c) : ExecutionPath(c, 0), null(false) { + explicit Nullpointer(Check *c) : ExecutionPath(c, 0), null(false) { } private: diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index a03da46cc..c43afbd71 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -41,7 +41,7 @@ namespace { class UninitVar : public ExecutionPath { public: /** Startup constructor */ - UninitVar(Check *c) + explicit UninitVar(Check *c) : ExecutionPath(c, 0), pointer(false), array(false), alloc(false), strncpy_(false), memset_nonzero(false) { } diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 4035876bb..5b3432044 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -2167,7 +2167,7 @@ public: * @param macro The code after define, until end of line, * e.g. "A(x) foo(x);" */ - PreprocessorMacro(const std::string ¯o) + explicit PreprocessorMacro(const std::string ¯o) : _macro(macro), _prefix("__cppcheck__") { tokenizer.setSettings(&settings); diff --git a/lib/token.h b/lib/token.h index 3d61fd07f..a1425ea5a 100644 --- a/lib/token.h +++ b/lib/token.h @@ -43,7 +43,7 @@ private: Token(); public: - Token(Token **tokensBack); + explicit Token(Token **tokensBack); ~Token(); void str(const std::string &s);