From d1f9551e05c9d341149eb490e05b1465d3d6b711 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 22 Dec 2022 14:45:50 +0200 Subject: [PATCH] Use default member initializers and constructor delegation --- source/analyzer.cpp | 5 +---- source/analyzer.h | 6 +++--- source/androidmanifestfile.cpp | 3 +-- source/androidmanifestfile.h | 2 +- source/apkbuilder.cpp | 3 +-- source/apkbuilder.h | 2 +- source/architecture.cpp | 4 +--- source/architecture.h | 4 ++-- source/builder.cpp | 6 +----- source/builder.h | 8 ++++---- source/buildercli.cpp | 14 +------------- source/buildercli.h | 24 ++++++++++++------------ source/buildinfo.cpp | 11 ----------- source/buildinfo.h | 32 +++++++++++++++----------------- source/cache.cpp | 3 +-- source/cache.h | 2 +- source/chainedtask.cpp | 4 +--- source/chainedtask.h | 4 ++-- source/component.cpp | 4 +--- source/component.h | 4 ++-- source/config.cpp | 3 +-- source/config.h | 2 +- source/externaltask.cpp | 8 +------- source/externaltask.h | 12 ++++++------ source/feature.cpp | 4 +--- source/feature.h | 4 ++-- source/filetarget.cpp | 21 +++++++-------------- source/filetarget.h | 8 ++++---- source/gnulinker.h | 4 ++-- source/importlibrary.cpp | 3 +-- source/importlibrary.h | 2 +- source/internaltask.cpp | 5 ----- source/internaltask.h | 4 ++-- source/objectfile.cpp | 3 +-- source/objectfile.h | 2 +- source/package.cpp | 4 +--- source/package.h | 4 ++-- source/packagemanager.cpp | 5 +---- source/packagemanager.h | 6 +++--- source/sharedlibrary.cpp | 3 +-- source/sharedlibrary.h | 2 +- source/sourcepackage.cpp | 1 - source/sourcepackage.h | 2 +- source/target.cpp | 7 +------ source/target.h | 10 +++++----- source/task.cpp | 4 ---- source/task.h | 4 ++-- source/tool.cpp | 18 +++++++----------- source/tool.h | 12 +++++++----- 49 files changed, 115 insertions(+), 197 deletions(-) diff --git a/source/analyzer.cpp b/source/analyzer.cpp index 94f7782..b3b1f21 100644 --- a/source/analyzer.cpp +++ b/source/analyzer.cpp @@ -14,10 +14,7 @@ using namespace std; using namespace Msp; Analyzer::Analyzer(Builder &b): - builder(b), - mode(DEPS), - max_depth(0), - full_paths(false) + builder(b) { } void Analyzer::analyze() diff --git a/source/analyzer.h b/source/analyzer.h index 4c9e146..5827480 100644 --- a/source/analyzer.h +++ b/source/analyzer.h @@ -27,10 +27,10 @@ private: using TableRow = std::vector; Builder &builder; - Mode mode; + Mode mode = DEPS; std::vector table; - unsigned max_depth; - bool full_paths; + unsigned max_depth = 0; + bool full_paths = false; std::map > rdepends; public: diff --git a/source/androidmanifestfile.cpp b/source/androidmanifestfile.cpp index 527bfac..2dd1c96 100644 --- a/source/androidmanifestfile.cpp +++ b/source/androidmanifestfile.cpp @@ -8,8 +8,7 @@ using namespace std; using namespace Msp; AndroidManifestFile::AndroidManifestFile(Builder &b, const AndroidApplicationComponent &a): - FileTarget(b, a.get_package(), a.get_package().get_temp_directory()/a.get_name()/"AndroidManifest.xml"), - native_lib(0) + FileTarget(b, a.get_package(), a.get_package().get_temp_directory()/a.get_name()/"AndroidManifest.xml") { component = &a; tool = &builder.get_toolchain().get_tool("AMG"); diff --git a/source/androidmanifestfile.h b/source/androidmanifestfile.h index cd02df0..9c0ed21 100644 --- a/source/androidmanifestfile.h +++ b/source/androidmanifestfile.h @@ -13,7 +13,7 @@ Metadata file for an Android application. class AndroidManifestFile: public FileTarget { private: - SharedLibrary *native_lib; + SharedLibrary *native_lib = 0; std::vector permissions; std::string orientation; diff --git a/source/apkbuilder.cpp b/source/apkbuilder.cpp index 0e14163..d232a6f 100644 --- a/source/apkbuilder.cpp +++ b/source/apkbuilder.cpp @@ -15,8 +15,7 @@ using namespace Msp; // TODO Separate jar into its own tool and have this one just chain the two ApkBuilder::ApkBuilder(Builder &b): - Tool(b, "APK"), - jarsigner(0) + Tool(b, "APK") { set_command("jar"); } diff --git a/source/apkbuilder.h b/source/apkbuilder.h index 7346b75..4a8c16b 100644 --- a/source/apkbuilder.h +++ b/source/apkbuilder.h @@ -6,7 +6,7 @@ class ApkBuilder: public Tool { private: - Tool *jarsigner; + Tool *jarsigner = 0; public: ApkBuilder(Builder &); diff --git a/source/architecture.cpp b/source/architecture.cpp index 48c6a20..9662bba 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -96,9 +96,7 @@ const char *aliases[] = } Architecture::Architecture(Builder &b, const string &spec): - builder(b), - bits(0), - native(false) + builder(b) { if(spec.empty()) { diff --git a/source/architecture.h b/source/architecture.h index a31ad9f..4642080 100644 --- a/source/architecture.h +++ b/source/architecture.h @@ -27,10 +27,10 @@ private: std::string cpu; std::string fpu; std::string system; - unsigned bits; + unsigned bits = 0; std::string toolchain; std::string name; - bool native; + bool native = false; std::string cross_prefix; std::map> filename_patterns; diff --git a/source/builder.cpp b/source/builder.cpp index 2392581..9968792 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -32,13 +32,9 @@ using namespace Msp; Builder::Builder(): package_manager(*this), native_arch(*this, string()), - current_arch(0), - build_type(0), vfs(*this), build_graph(*this), - logger(&default_logger), - tempdir("temp"), - top_loader(0) + logger(&default_logger) { set_architecture(string()); } diff --git a/source/builder.h b/source/builder.h index 5d62a9a..331c50a 100644 --- a/source/builder.h +++ b/source/builder.h @@ -47,9 +47,9 @@ private: PackageManager package_manager; Architecture native_arch; - Architecture *current_arch; + Architecture *current_arch = 0; std::map build_types; - BuildType *build_type; + BuildType *build_type = 0; Toolchain toolchain; VirtualFileSystem vfs; BuildGraph build_graph; @@ -57,9 +57,9 @@ private: const Logger *logger; Msp::FS::Path prefix; - Msp::FS::Path tempdir; + Msp::FS::Path tempdir = "temp"; - Loader *top_loader; + Loader *top_loader = 0; public: Builder(); diff --git a/source/buildercli.cpp b/source/buildercli.cpp index 688a1db..bc18eed 100644 --- a/source/buildercli.cpp +++ b/source/buildercli.cpp @@ -15,19 +15,7 @@ using namespace std; using namespace Msp; BuilderCLI::BuilderCLI(int argc, char **argv): - RegisteredApplication("builder"), - analyzer(0), - build(false), - clean(0), - dry_run(false), - help(false), - show_progress(false), - build_file("Build"), - jobs(1), - conf_all(false), - conf_only(false), - build_all(false), - create_makefile(false) + RegisteredApplication("builder") { string analyze_mode; string work_dir; diff --git a/source/buildercli.h b/source/buildercli.h index 4fcdb03..3b15541 100644 --- a/source/buildercli.h +++ b/source/buildercli.h @@ -18,20 +18,20 @@ private: Builder builder; Logger logger; - Analyzer *analyzer; - bool build; - unsigned clean; - bool dry_run; - bool help; + Analyzer *analyzer = 0; + bool build = false; + unsigned clean = 0; + bool dry_run = false; + bool help = false; std::string helpmsg; - bool show_progress; - std::string build_file; - unsigned jobs; + bool show_progress = false; + std::string build_file = "Build"; + unsigned jobs = 1; std::vector what_if; - bool conf_all; - bool conf_only; - bool build_all; - bool create_makefile; + bool conf_all = false; + bool conf_only = false; + bool build_all = false; + bool create_makefile = false; public: BuilderCLI(int, char **); diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 8ca9af8..8e11670 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -26,17 +26,6 @@ void unique(vector &v) } -BuildInfo::BuildInfo(): - libmode(DYNAMIC), - rpath_mode(NO_RPATH), - threads(false), - debug(false), - optimize(0), - strip(false), - warning_level(0), - fatal_warnings(false) -{ } - BuildInfo::LibraryMode BuildInfo::get_libmode_for(const string &lib) const { auto i = libmodes.find(lib); diff --git a/source/buildinfo.h b/source/buildinfo.h index 203ba5f..26afabf 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -54,9 +54,9 @@ public: struct LanguageStandard { std::string type; - unsigned year; + unsigned year = 0; - LanguageStandard(): year(0) { } + LanguageStandard() = default; LanguageStandard(const std::string &); std::string str() const; @@ -76,13 +76,13 @@ public: using LoadType = T; private: - T value; - bool set; + T value{}; + bool set = false; public: - Tracked(): value(T()), set(false) { } - Tracked(T v): value(v), set(false) { } - Tracked(const Tracked &t): value(t.value), set(t.set) { } + Tracked() = default; + Tracked(T v): value(v) { } + Tracked(const Tracked &t) = default; Tracked &operator=(const Tracked &v) { if(v.set) { value = v.value; set = true; } return *this; } Tracked &operator=(const T &v) { value = v; set = true; return *this; } @@ -95,19 +95,17 @@ public: std::vector local_incpath; std::vector libpath; std::vector libs; - Tracked libmode; - Tracked rpath_mode; + Tracked libmode = DYNAMIC; + Tracked rpath_mode = NO_RPATH; std::map libmodes; std::vector keep_symbols; std::map standards; - Tracked threads; - Tracked debug; - Tracked optimize; - Tracked strip; - Tracked warning_level; - Tracked fatal_warnings; - - BuildInfo(); + Tracked threads = false; + Tracked debug = false; + Tracked optimize = 0; + Tracked strip = false; + Tracked warning_level = 0; + Tracked fatal_warnings = false; /** Returns the library mode for linking a particular library. If no mode has been specified for that library, the the global library mode is diff --git a/source/cache.cpp b/source/cache.cpp index 30f3fc3..6baacce 100644 --- a/source/cache.cpp +++ b/source/cache.cpp @@ -59,8 +59,7 @@ void write_string(IO::Base &out, const string &str) Cache::Cache(SourcePackage &p): package(p), - filename(package.get_temp_directory()/"../cache"), - changed(false) + filename(package.get_temp_directory()/"../cache") { } void Cache::set_value(const Target *tgt, const string &k, const string &v) diff --git a/source/cache.h b/source/cache.h index f3a2c13..9193dac 100644 --- a/source/cache.h +++ b/source/cache.h @@ -28,7 +28,7 @@ private: Msp::FS::Path filename; std::map data; Msp::Time::TimeStamp mtime; - mutable bool changed; + mutable bool changed = false; public: Cache(SourcePackage &p); diff --git a/source/chainedtask.cpp b/source/chainedtask.cpp index a5a6d86..4e0decb 100644 --- a/source/chainedtask.cpp +++ b/source/chainedtask.cpp @@ -4,9 +4,7 @@ using namespace std; using namespace Msp; -ChainedTask::ChainedTask(Task *t): - current(0), - final_status(RUNNING) +ChainedTask::ChainedTask(Task *t) { add_task(t); } diff --git a/source/chainedtask.h b/source/chainedtask.h index 4cb677c..2986e8e 100644 --- a/source/chainedtask.h +++ b/source/chainedtask.h @@ -12,8 +12,8 @@ class ChainedTask: public Task { private: std::vector tasks; - unsigned current; - Status final_status; + unsigned current = 0; + Status final_status = RUNNING; public: ChainedTask(Task *); diff --git a/source/component.cpp b/source/component.cpp index e3f80fb..0186f3e 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -13,9 +13,7 @@ using namespace Msp; Component::Component(SourcePackage &p, const string &n): package(p), - name(n), - install(false), - deflt(true) + name(n) { } void Component::prepare() diff --git a/source/component.h b/source/component.h index bde558d..5479cc5 100644 --- a/source/component.h +++ b/source/component.h @@ -37,10 +37,10 @@ protected: std::string name; std::vector sources; std::vector overlays; - bool install; + bool install = false; BuildInfo build_info; Package::Requirements requires; - bool deflt; + bool deflt = true; InstallMap install_map; std::vector problems; diff --git a/source/config.cpp b/source/config.cpp index 74d582e..48864a9 100644 --- a/source/config.cpp +++ b/source/config.cpp @@ -13,8 +13,7 @@ using namespace std; using namespace Msp; Config::Config(SourcePackage &p): - package(p), - changed(false) + package(p) { } const Config::Option &Config::add_option(const Feature &f) diff --git a/source/config.h b/source/config.h index a82e536..37508b0 100644 --- a/source/config.h +++ b/source/config.h @@ -40,7 +40,7 @@ private: std::map options; InputOptions pending_options; Msp::Time::TimeStamp mtime; - mutable bool changed; + mutable bool changed = false; public: Config(SourcePackage &); diff --git a/source/externaltask.cpp b/source/externaltask.cpp index 33ffceb..37a36d3 100644 --- a/source/externaltask.cpp +++ b/source/externaltask.cpp @@ -11,13 +11,7 @@ using namespace Msp; ExternalTask::ExternalTask(const Arguments &a, const FS::Path &wd): argv(a), - work_dir(wd), - process(0), - exit_code(-1), - stdin_action(PASSTHROUGH), - stdout_action(PASSTHROUGH), - stderr_action(PASSTHROUGH), - capture_pipe(0) + work_dir(wd) { if(argv.empty()) throw invalid_argument("ExternalTask::ExternalTask"); diff --git a/source/externaltask.h b/source/externaltask.h index 3de1e4a..9b9bc43 100644 --- a/source/externaltask.h +++ b/source/externaltask.h @@ -29,14 +29,14 @@ public: private: Arguments argv; Msp::FS::Path work_dir; - Msp::Process *process; - int exit_code; - StreamAction stdin_action; + Msp::Process *process = 0; + int exit_code = -1; + StreamAction stdin_action = PASSTHROUGH; Msp::FS::Path stdin_file; - StreamAction stdout_action; + StreamAction stdout_action = PASSTHROUGH; Msp::FS::Path stdout_file; - StreamAction stderr_action; - Msp::IO::Pipe *capture_pipe; + StreamAction stderr_action = PASSTHROUGH; + Msp::IO::Pipe *capture_pipe = 0; std::string output; public: diff --git a/source/feature.cpp b/source/feature.cpp index 7bf9a57..891ba72 100644 --- a/source/feature.cpp +++ b/source/feature.cpp @@ -4,9 +4,7 @@ using namespace std; using namespace Msp; Feature::Feature(const string &n): - name(n), - default_value("no"), - exported(false) + name(n) { } diff --git a/source/feature.h b/source/feature.h index 2ab2081..f8ec334 100644 --- a/source/feature.h +++ b/source/feature.h @@ -16,9 +16,9 @@ struct Feature std::string name; std::string description; - std::string default_value; + std::string default_value = "no"; std::vector choices; - bool exported; + bool exported = false; Feature(const std::string &); }; diff --git a/source/filetarget.cpp b/source/filetarget.cpp index 1434372..07be2c9 100644 --- a/source/filetarget.cpp +++ b/source/filetarget.cpp @@ -14,25 +14,18 @@ using namespace std; using namespace Msp; FileTarget::FileTarget(Builder &b, const FS::Path &a): - Target(b, generate_name(b, 0, a)), - path(a) -{ - init(0); -} + FileTarget(b, 0, a) +{ } FileTarget::FileTarget(Builder &b, const SourcePackage &p, const FS::Path &a): - Target(b, generate_name(b, &p, a)), - path(a) -{ - init(&p); -} + FileTarget(b, &p, a) +{ } -void FileTarget::init(const SourcePackage *p) +FileTarget::FileTarget(Builder &b, const SourcePackage *p, const FS::Path &a): + Target(b, generate_name(b, p, a)), + path(a) { - size = 0; package = p; - nested_build_sig = false; - arch_in_build_sig = false; builder.get_vfs().register_path(path, this); diff --git a/source/filetarget.h b/source/filetarget.h index 5c11b5c..aff1fb7 100644 --- a/source/filetarget.h +++ b/source/filetarget.h @@ -13,16 +13,16 @@ class FileTarget: public Target protected: Msp::FS::Path path; Msp::Time::TimeStamp mtime; - unsigned size; + unsigned size = 0; Msp::FS::Path install_location; std::string install_filename; - bool nested_build_sig; - bool arch_in_build_sig; + bool nested_build_sig = false; + bool arch_in_build_sig = false; FileTarget(Builder &, const Msp::FS::Path &); FileTarget(Builder &, const SourcePackage &, const Msp::FS::Path &); private: - void init(const SourcePackage *); + FileTarget(Builder &, const SourcePackage *, const Msp::FS::Path &); void stat(); static std::string generate_name(Builder &, const SourcePackage *, const Msp::FS::Path &); diff --git a/source/gnulinker.h b/source/gnulinker.h index 0644e94..821f746 100644 --- a/source/gnulinker.h +++ b/source/gnulinker.h @@ -28,8 +28,8 @@ private: Task *run(const Target &) const override; }; - Linker *default_linker; - Linker *cxx_linker; + Linker *default_linker = 0; + Linker *cxx_linker = 0; public: GnuLinker(Builder &, const Architecture &); diff --git a/source/importlibrary.cpp b/source/importlibrary.cpp index 3cdc103..9d2ea8f 100644 --- a/source/importlibrary.cpp +++ b/source/importlibrary.cpp @@ -11,8 +11,7 @@ using namespace std; using namespace Msp; ImportLibrary::ImportLibrary(Builder &b, const FS::Path &p): - FileTarget(b, p), - shared_lib(0) + FileTarget(b, p) { } ImportLibrary::ImportLibrary(Builder &b, const Component &c, SharedLibrary &sl, ExportDefinitions &exp): diff --git a/source/importlibrary.h b/source/importlibrary.h index 26c116d..e985be7 100644 --- a/source/importlibrary.h +++ b/source/importlibrary.h @@ -13,7 +13,7 @@ platforms with no true dynamic linking support. class ImportLibrary: public FileTarget { private: - SharedLibrary *shared_lib; + SharedLibrary *shared_lib = 0; public: ImportLibrary(Builder &, const Msp::FS::Path &); diff --git a/source/internaltask.cpp b/source/internaltask.cpp index 5cbbd09..0f3cbc2 100644 --- a/source/internaltask.cpp +++ b/source/internaltask.cpp @@ -30,8 +30,3 @@ Task::Status InternalTask::wait() while((result = check())==RUNNING) ; return result; } - - -InternalTask::Worker::Worker(): - status(Task::RUNNING) -{ } diff --git a/source/internaltask.h b/source/internaltask.h index db3294b..98b76a0 100644 --- a/source/internaltask.h +++ b/source/internaltask.h @@ -17,9 +17,9 @@ public: friend class InternalTask; protected: - volatile Status status; + volatile Status status = Task::RUNNING; - Worker(); + Worker() = default; public: Status get_status() const { return status; } diff --git a/source/objectfile.cpp b/source/objectfile.cpp index a2f8072..00fa679 100644 --- a/source/objectfile.cpp +++ b/source/objectfile.cpp @@ -11,8 +11,7 @@ using namespace Msp; ObjectFile::ObjectFile(Builder &b, const Component &c, SourceFile &s): FileTarget(b, c.get_package(), generate_target_path(c, s.get_path())), - source(s), - used_in_shlib(false) + source(s) { component = &c; add_dependency(source); diff --git a/source/objectfile.h b/source/objectfile.h index 4f116e9..9e3ff90 100644 --- a/source/objectfile.h +++ b/source/objectfile.h @@ -12,7 +12,7 @@ class ObjectFile: public FileTarget { private: SourceFile &source; - bool used_in_shlib; + bool used_in_shlib = false; public: ObjectFile(Builder &, const Component &, SourceFile &); diff --git a/source/package.cpp b/source/package.cpp index 6e570c8..10c2db0 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -8,9 +8,7 @@ using namespace Msp; Package::Package(Builder &b, const string &n): builder(b), name(n), - label(string(1, toupper(n[0]))+n.substr(1)), - prepared(false), - use_pkgconfig(true) + label(string(1, toupper(n[0]))+n.substr(1)) { builder.get_package_manager().add_package(this); } diff --git a/source/package.h b/source/package.h index bb3c809..d13aa73 100644 --- a/source/package.h +++ b/source/package.h @@ -37,10 +37,10 @@ protected: Requirements requires; BuildInfo export_binfo; - bool prepared; + bool prepared = false; std::vector problems; - bool use_pkgconfig; + bool use_pkgconfig = true; Package(Builder &, const std::string &); public: diff --git a/source/packagemanager.cpp b/source/packagemanager.cpp index 31b2461..9e53bb4 100644 --- a/source/packagemanager.cpp +++ b/source/packagemanager.cpp @@ -17,10 +17,7 @@ using namespace std; using namespace Msp; PackageManager::PackageManager(Builder &b): - builder(b), - no_externals(false), - main_pkg(0), - env_set(false) + builder(b) { } PackageManager::~PackageManager() diff --git a/source/packagemanager.h b/source/packagemanager.h index d5cfb52..22f1eac 100644 --- a/source/packagemanager.h +++ b/source/packagemanager.h @@ -22,11 +22,11 @@ private: std::vector pkg_dirs; std::vector binpkg_path; std::vector binpkg_files; - bool no_externals; + bool no_externals = false; std::map packages; - Package *main_pkg; + Package *main_pkg = 0; std::set not_found; - bool env_set; + bool env_set = false; public: PackageManager(Builder &); diff --git a/source/sharedlibrary.cpp b/source/sharedlibrary.cpp index 4ef9bb6..0673a05 100644 --- a/source/sharedlibrary.cpp +++ b/source/sharedlibrary.cpp @@ -10,8 +10,7 @@ using namespace std; using namespace Msp; SharedLibrary::SharedLibrary(Builder &b, const Msp::FS::Path &p): - Binary(b, p), - import_lib(0) + Binary(b, p) { libname = FS::basepart(FS::basename(path)); if(!libname.compare(0, 3, "lib")) diff --git a/source/sharedlibrary.h b/source/sharedlibrary.h index 54822aa..564b210 100644 --- a/source/sharedlibrary.h +++ b/source/sharedlibrary.h @@ -19,7 +19,7 @@ class SharedLibrary: public Binary private: std::string libname; std::string soname; - ImportLibrary *import_lib; + ImportLibrary *import_lib = 0; public: SharedLibrary(Builder &, const Msp::FS::Path &); diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 40b098c..2c478a8 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -27,7 +27,6 @@ using namespace Msp; SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &f): Package(b, n), source_dir(FS::dirname(f)), - build_type(0), config(*this), cache(*this) { diff --git a/source/sourcepackage.h b/source/sourcepackage.h index 23e8f36..8be8ada 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -53,7 +53,7 @@ private: FileTarget *build_file; Msp::FS::Path source_dir; - const BuildType *build_type; + const BuildType *build_type = 0; Toolchain local_tools; std::vector features; BuildInfo build_info; diff --git a/source/target.cpp b/source/target.cpp index 055abb5..d701859 100644 --- a/source/target.cpp +++ b/source/target.cpp @@ -13,12 +13,7 @@ using namespace Msp; Target::Target(Builder &b, const string &n): builder(b), - package(0), - component(0), - name(n), - tool(0), - state(INIT), - primary_target(0) + name(n) { builder.get_build_graph().add_target(this); } diff --git a/source/target.h b/source/target.h index 2824e2a..6ef6457 100644 --- a/source/target.h +++ b/source/target.h @@ -46,19 +46,19 @@ public: protected: Builder &builder; - const SourcePackage *package; - const Component *component; + const SourcePackage *package = 0; + const Component *component = 0; std::string name; - Tool *tool; - State state; + Tool *tool = 0; + State state = INIT; std::string rebuild_reason; std::vector problems; Dependencies depends; Dependencies trans_depends; Dependencies side_effects; - Target *primary_target; + Target *primary_target = 0; Target(Builder &, const std::string &); public: diff --git a/source/task.cpp b/source/task.cpp index d969a7a..e72a741 100644 --- a/source/task.cpp +++ b/source/task.cpp @@ -6,10 +6,6 @@ using namespace std; using namespace Msp; -Task::Task(): - unlink(false) -{ } - void Task::add_file(const FS::Path &f) { files.push_back(f); diff --git a/source/task.h b/source/task.h index 97cf8d6..915ffe1 100644 --- a/source/task.h +++ b/source/task.h @@ -24,9 +24,9 @@ public: protected: std::vector files; - bool unlink; + bool unlink = false; - Task(); + Task() = default; public: virtual ~Task() { } diff --git a/source/tool.cpp b/source/tool.cpp index da7054a..5d0903a 100644 --- a/source/tool.cpp +++ b/source/tool.cpp @@ -10,21 +10,17 @@ using namespace std; using namespace Msp; Tool::Tool(Builder &b, const string &t): - builder(b), - architecture(0), - tag(t), - executable(0), - processing_unit(ONE_FILE), - prepared(false) + Tool(b, 0, t) { } Tool::Tool(Builder &b, const Architecture &a, const string &t): + Tool(b, &a, t) +{ } + +Tool::Tool(Builder &b, const Architecture *a, const string &t): builder(b), - architecture(&a), - tag(t), - executable(0), - processing_unit(ONE_FILE), - prepared(false) + architecture(a), + tag(t) { } void Tool::set_command(const string &cmd, bool cross) diff --git a/source/tool.h b/source/tool.h index ce08a00..e1bef2d 100644 --- a/source/tool.h +++ b/source/tool.h @@ -31,26 +31,28 @@ public: protected: Builder &builder; - const Architecture *architecture; + const Architecture *architecture = 0; std::string tag; std::string command; - FileTarget *executable; + FileTarget *executable = 0; std::vector input_suffixes; std::vector aux_suffixes; - ProcessingUnit processing_unit; + ProcessingUnit processing_unit = ONE_FILE; VirtualFileSystem::SearchPath system_path; BuildInfo build_info; - bool prepared; + bool prepared = false; std::vector problems; Tool(Builder &, const std::string &); Tool(Builder &, const Architecture &, const std::string &); +private: + Tool(Builder &, const Architecture *, const std::string &); public: virtual ~Tool() { } const std::string &get_tag() const { return tag; } - /** Returns the architecture this tool build for. May return null if the + /** Returns the architecture this tool builds for. May return null if the tool is architecture-agnostic. */ const Architecture *get_architecture() const { return architecture; } -- 2.43.0