From 7edbe59c6c70cd085fc68c4317c3a71a40ac21e5 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 21 Aug 2020 03:23:04 +0100 Subject: style(tvix): Replace remaining typedefs with using statements Change (mostly) created via: fd . -e hh -e cc | parallel clang-tidy -p ~/builds/nix --fix "'--checks=-*,modernize-use-using'" Change-Id: I90ad6e64a5399f2005dfb9956074ec51c2c78cea Reviewed-on: https://cl.tvl.fyi/c/depot/+/1830 Tested-by: BuildkiteCI Reviewed-by: glittershark --- third_party/nix/src/libexpr/eval.hh | 8 +++---- third_party/nix/src/libexpr/get-drvs.hh | 2 +- third_party/nix/src/libstore/builtins/buildenv.cc | 4 ++-- third_party/nix/src/libstore/derivations.hh | 2 +- third_party/nix/src/libstore/local-store.hh | 8 +++---- third_party/nix/src/libstore/serve-protocol.hh | 4 ++-- third_party/nix/src/libutil/args.hh | 2 +- third_party/nix/src/libutil/config.hh | 2 +- .../nix/src/libutil/istringstream_nocopy.hh | 27 ++++++++++++---------- third_party/nix/src/libutil/pool.hh | 2 +- third_party/nix/src/libutil/serialise.hh | 2 +- third_party/nix/src/libutil/types.hh | 10 ++++---- third_party/nix/src/libutil/util.hh | 4 ++-- third_party/nix/src/nix-env/nix-env.cc | 10 ++++---- third_party/nix/src/nix/command.hh | 4 ++-- third_party/nix/src/nix/legacy.hh | 2 +- 16 files changed, 48 insertions(+), 45 deletions(-) (limited to 'third_party/nix') diff --git a/third_party/nix/src/libexpr/eval.hh b/third_party/nix/src/libexpr/eval.hh index aa7af777a1f1..f36d11b92b99 100644 --- a/third_party/nix/src/libexpr/eval.hh +++ b/third_party/nix/src/libexpr/eval.hh @@ -54,7 +54,7 @@ void copyContext(const Value& v, PathSet& context); /* Cache for calls to addToStore(); maps source paths to the store paths. */ -typedef std::map SrcToStore; +using SrcToStore = std::map; std::ostream& operator<<(std::ostream& str, const Value& v); @@ -298,15 +298,15 @@ class EvalState { std::function file_access_trace_fn = nullptr; Path last_traced_file = ""; - typedef std::map PrimOpCalls; + using PrimOpCalls = std::map; PrimOpCalls primOpCalls; - typedef std::map FunctionCalls; + using FunctionCalls = std::map; FunctionCalls functionCalls; void incrFunctionCall(ExprLambda* fun); - typedef std::map AttrSelects; + using AttrSelects = std::map; AttrSelects attrSelects; friend struct ExprOpUpdate; diff --git a/third_party/nix/src/libexpr/get-drvs.hh b/third_party/nix/src/libexpr/get-drvs.hh index b17efe8b3355..3de266d0c0e7 100644 --- a/third_party/nix/src/libexpr/get-drvs.hh +++ b/third_party/nix/src/libexpr/get-drvs.hh @@ -69,7 +69,7 @@ struct DrvInfo { bool hasFailed() { return failed; }; }; -typedef std::list DrvInfos; +using DrvInfos = std::list; /* If value `v' denotes a derivation, return a DrvInfo object describing it. Otherwise return nothing. */ diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc index 7ef7e2c25a59..0d1c59e6b5b7 100644 --- a/third_party/nix/src/libstore/builtins/buildenv.cc +++ b/third_party/nix/src/libstore/builtins/buildenv.cc @@ -120,7 +120,7 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) { } } -typedef std::set FileProp; +using FileProp = std::set; static FileProp done; static FileProp postponed = FileProp{}; @@ -158,7 +158,7 @@ struct Package { : path{path}, active{active}, priority{priority} {} }; -typedef std::vector Packages; +using Packages = std::vector; void builtinBuildenv(const BasicDerivation& drv) { auto getAttr = [&](const std::string& name) { diff --git a/third_party/nix/src/libstore/derivations.hh b/third_party/nix/src/libstore/derivations.hh index 3e26d5fa6f4e..8d46b58b5c0d 100644 --- a/third_party/nix/src/libstore/derivations.hh +++ b/third_party/nix/src/libstore/derivations.hh @@ -112,7 +112,7 @@ extern DrvHashes drvHashes; // FIXME: global, not thread-safe /* Split a string specifying a derivation and a set of outputs (/nix/store/hash-foo!out1,out2,...) into the derivation path and the outputs. */ -typedef std::pair > DrvPathWithOutputs; +using DrvPathWithOutputs = std::pair >; DrvPathWithOutputs parseDrvPathWithOutputs(absl::string_view path); Path makeDrvPathWithOutputs(const Path& drvPath, diff --git a/third_party/nix/src/libstore/local-store.hh b/third_party/nix/src/libstore/local-store.hh index 669b878b6601..193050e538b2 100644 --- a/third_party/nix/src/libstore/local-store.hh +++ b/third_party/nix/src/libstore/local-store.hh @@ -172,7 +172,7 @@ class LocalStore : public LocalFSStore { private: typedef std::shared_ptr FDPtr; - typedef std::list FDs; + using FDs = std::list; void findTempRoots(FDs& fds, Roots& roots, bool censor); @@ -270,7 +270,7 @@ class LocalStore : public LocalFSStore { void checkDerivationOutputs(const Path& drvPath, const Derivation& drv); - typedef std::unordered_set InodeHash; + using InodeHash = std::unordered_set; InodeHash loadInodeHash(); static Strings readDirectoryIgnoringInodes(const Path& path, @@ -295,8 +295,8 @@ class LocalStore : public LocalFSStore { friend class SubstitutionGoal; }; -typedef std::pair Inode; -typedef std::set InodesSeen; +using Inode = std::pair; +using InodesSeen = std::set; /* "Fix", or canonicalise, the meta-data of the files in a store path after it has been built. In particular: diff --git a/third_party/nix/src/libstore/serve-protocol.hh b/third_party/nix/src/libstore/serve-protocol.hh index a07a7ef97425..04c92e63f6de 100644 --- a/third_party/nix/src/libstore/serve-protocol.hh +++ b/third_party/nix/src/libstore/serve-protocol.hh @@ -9,7 +9,7 @@ namespace nix { #define GET_PROTOCOL_MAJOR(x) ((x)&0xff00) #define GET_PROTOCOL_MINOR(x) ((x)&0x00ff) -typedef enum { +using ServeCommand = enum { cmdQueryValidPaths = 1, cmdQueryPathInfos = 2, cmdDumpStorePath = 3, @@ -19,6 +19,6 @@ typedef enum { cmdQueryClosure = 7, cmdBuildDerivation = 8, cmdAddToStoreNar = 9, -} ServeCommand; +}; } // namespace nix diff --git a/third_party/nix/src/libutil/args.hh b/third_party/nix/src/libutil/args.hh index 409ea80f2d45..3057f3d2ab46 100644 --- a/third_party/nix/src/libutil/args.hh +++ b/third_party/nix/src/libutil/args.hh @@ -212,7 +212,7 @@ Strings argvToStrings(int argc, char** argv); std::string renderLabels(const Strings& labels); /* Helper function for printing 2-column tables. */ -typedef std::vector> Table2; +using Table2 = std::vector >; void printTable(std::ostream& out, const Table2& table); diff --git a/third_party/nix/src/libutil/config.hh b/third_party/nix/src/libutil/config.hh index 0441e3b9e848..027a6be2982a 100644 --- a/third_party/nix/src/libutil/config.hh +++ b/third_party/nix/src/libutil/config.hh @@ -203,7 +203,7 @@ class PathSetting : public BaseSetting { }; struct GlobalConfig : public AbstractConfig { - typedef std::vector ConfigRegistrations; + using ConfigRegistrations = std::vector; static ConfigRegistrations* configRegistrations; bool set(const std::string& name, const std::string& value) override; diff --git a/third_party/nix/src/libutil/istringstream_nocopy.hh b/third_party/nix/src/libutil/istringstream_nocopy.hh index 997965630b6c..31683d37c91b 100644 --- a/third_party/nix/src/libutil/istringstream_nocopy.hh +++ b/third_party/nix/src/libutil/istringstream_nocopy.hh @@ -12,15 +12,15 @@ template , class Allocator = std::allocator> class basic_istringbuf_nocopy : public std::basic_streambuf { public: - typedef std::basic_string string_type; + using string_type = std::basic_string; - typedef typename std::basic_streambuf::off_type off_type; + using off_type = typename std::basic_streambuf::off_type; - typedef typename std::basic_streambuf::pos_type pos_type; + using pos_type = typename std::basic_streambuf::pos_type; - typedef typename std::basic_streambuf::int_type int_type; + using int_type = typename std::basic_streambuf::int_type; - typedef typename std::basic_streambuf::traits_type traits_type; + using traits_type = typename std::basic_streambuf::traits_type; private: const string_type& s; @@ -28,7 +28,7 @@ class basic_istringbuf_nocopy : public std::basic_streambuf { off_type off; public: - basic_istringbuf_nocopy(const string_type& s) : s{s}, off{0} {} + explicit basic_istringbuf_nocopy(const string_type& s) : s{s}, off{0} {} private: pos_type seekoff(off_type off, std::ios_base::seekdir dir, @@ -49,20 +49,23 @@ class basic_istringbuf_nocopy : public std::basic_streambuf { std::streamsize showmanyc() { return s.size() - off; } int_type underflow() { - if (typename string_type::size_type(off) == s.size()) + if (typename string_type::size_type(off) == s.size()) { return traits_type::eof(); + } return traits_type::to_int_type(s[off]); } int_type uflow() { - if (typename string_type::size_type(off) == s.size()) + if (typename string_type::size_type(off) == s.size()) { return traits_type::eof(); + } return traits_type::to_int_type(s[off++]); } int_type pbackfail(int_type ch) { - if (off == 0 || (ch != traits_type::eof() && ch != s[off - 1])) + if (off == 0 || (ch != traits_type::eof() && ch != s[off - 1])) { return traits_type::eof(); + } return traits_type::to_int_type(s[--off]); } @@ -71,12 +74,12 @@ class basic_istringbuf_nocopy : public std::basic_streambuf { template , class Allocator = std::allocator> class basic_istringstream_nocopy : public std::basic_iostream { - typedef basic_istringbuf_nocopy buf_type; + using buf_type = basic_istringbuf_nocopy; buf_type buf; public: - basic_istringstream_nocopy(const typename buf_type::string_type& s) + explicit basic_istringstream_nocopy(const typename buf_type::string_type& s) : std::basic_iostream(&buf), buf(s){}; }; -typedef basic_istringstream_nocopy istringstream_nocopy; +using istringstream_nocopy = basic_istringstream_nocopy; diff --git a/third_party/nix/src/libutil/pool.hh b/third_party/nix/src/libutil/pool.hh index fe6d5c28004e..56a579b269cd 100644 --- a/third_party/nix/src/libutil/pool.hh +++ b/third_party/nix/src/libutil/pool.hh @@ -36,7 +36,7 @@ class Pool { /* A function that checks whether an instance of R is still usable. Unusable instances are removed from the pool. */ - typedef std::function&)> Validator; + using Validator = std::function&)>; private: Factory factory; diff --git a/third_party/nix/src/libutil/serialise.hh b/third_party/nix/src/libutil/serialise.hh index d088252fb69e..04f672781015 100644 --- a/third_party/nix/src/libutil/serialise.hh +++ b/third_party/nix/src/libutil/serialise.hh @@ -195,7 +195,7 @@ struct LambdaSink : Sink { /* Convert a function into a source. */ struct LambdaSource : Source { - typedef std::function lambda_t; + using lambda_t = std::function; lambda_t lambda; diff --git a/third_party/nix/src/libutil/types.hh b/third_party/nix/src/libutil/types.hh index dae81fb94b6a..b8e7a3c9d5c7 100644 --- a/third_party/nix/src/libutil/types.hh +++ b/third_party/nix/src/libutil/types.hh @@ -107,12 +107,12 @@ class SysError : public Error { }; typedef std::list Strings; -typedef std::set StringSet; -typedef std::map StringMap; +using StringSet = std::set; +using StringMap = std::map; /* Paths are just strings. */ -typedef std::string Path; -typedef std::list Paths; -typedef std::set PathSet; +using Path = std::string; +using Paths = std::list; +using PathSet = std::set; } // namespace nix diff --git a/third_party/nix/src/libutil/util.hh b/third_party/nix/src/libutil/util.hh index d9fc1a27b134..9331fca7f30b 100644 --- a/third_party/nix/src/libutil/util.hh +++ b/third_party/nix/src/libutil/util.hh @@ -201,7 +201,7 @@ struct DIRDeleter { void operator()(DIR* dir) const { closedir(dir); } }; -typedef std::unique_ptr AutoCloseDir; +using AutoCloseDir = std::unique_ptr; class Pid { pid_t pid = -1; @@ -457,7 +457,7 @@ struct MaintainCount { std::pair getWindowSize(); /* Used in various places. */ -typedef std::function PathFilter; +using PathFilter = std::function; extern PathFilter defaultPathFilter; diff --git a/third_party/nix/src/nix-env/nix-env.cc b/third_party/nix/src/nix-env/nix-env.cc index 9c0931e7f4ad..830bd514dafb 100644 --- a/third_party/nix/src/nix-env/nix-env.cc +++ b/third_party/nix/src/nix-env/nix-env.cc @@ -32,14 +32,14 @@ using namespace nix; using std::cout; -typedef enum { +using InstallSourceType = enum { srcNixExprDrvs, srcNixExprs, srcStorePaths, srcProfile, srcAttrPath, srcUnknown -} InstallSourceType; +}; struct InstallSourceInfo { InstallSourceType type; @@ -229,7 +229,7 @@ static DrvInfos filterBySelector(EvalState& state, const DrvInfos& allElems, std::set done; for (auto& i : selectors) { - typedef std::list > Matches; + using Matches = std::list >; Matches matches; unsigned int n = 0; for (auto j = allElems.begin(); j != allElems.end(); ++j, ++n) { @@ -249,7 +249,7 @@ static DrvInfos filterBySelector(EvalState& state, const DrvInfos& allElems, arbitrarily pick the first one. */ if (newestOnly) { /* Map from package names to derivations. */ - typedef std::map > Newest; + using Newest = std::map >; Newest newest; StringSet multiple; @@ -834,7 +834,7 @@ void printTable(Table& table) { least one element with a higher version in the set. `cvUnavail' means that there are no elements with the same name in the set. */ -typedef enum { cvLess, cvEqual, cvGreater, cvUnavail } VersionDiff; +using VersionDiff = enum { cvLess, cvEqual, cvGreater, cvUnavail }; static VersionDiff compareVersionAgainstSet(const DrvInfo& elem, const DrvInfos& elems, diff --git a/third_party/nix/src/nix/command.hh b/third_party/nix/src/nix/command.hh index 01c1ed69d61d..87e2fbe9d28d 100644 --- a/third_party/nix/src/nix/command.hh +++ b/third_party/nix/src/nix/command.hh @@ -51,7 +51,7 @@ struct Buildable { std::map outputs; }; -typedef std::vector Buildables; +using Buildables = std::vector; struct Installable { virtual std::string what() = 0; @@ -140,7 +140,7 @@ struct StorePathCommand : public InstallablesCommand { void run(ref store) override; }; -typedef std::map> Commands; +using Commands = std::map>; /* An argument parser that supports multiple subcommands, i.e. ‘ ’. */ diff --git a/third_party/nix/src/nix/legacy.hh b/third_party/nix/src/nix/legacy.hh index a9bc65c02e76..a0fc88da244c 100644 --- a/third_party/nix/src/nix/legacy.hh +++ b/third_party/nix/src/nix/legacy.hh @@ -9,7 +9,7 @@ namespace nix { typedef std::function MainFunction; struct RegisterLegacyCommand { - typedef std::map Commands; + using Commands = std::map; static Commands* commands; RegisterLegacyCommand(const std::string& name, MainFunction fun) { -- cgit 1.4.1