diff options
author | Vincent Ambo <mail@tazj.in> | 2020-08-21T02·23+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-08-21T03·55+0000 |
commit | 7edbe59c6c70cd085fc68c4317c3a71a40ac21e5 (patch) | |
tree | b036747e1c9615c2abbd58560353e704d51bc922 /third_party/nix | |
parent | 674d921202754661bfcc02ef8fe40ade227349cb (diff) |
style(tvix): Replace remaining typedefs with using statements r/1702
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 <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix')
-rw-r--r-- | third_party/nix/src/libexpr/eval.hh | 8 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/get-drvs.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/libstore/builtins/buildenv.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/libstore/derivations.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/libstore/local-store.hh | 8 | ||||
-rw-r--r-- | third_party/nix/src/libstore/serve-protocol.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/libutil/args.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/libutil/config.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/libutil/istringstream_nocopy.hh | 27 | ||||
-rw-r--r-- | third_party/nix/src/libutil/pool.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/libutil/serialise.hh | 2 | ||||
-rw-r--r-- | third_party/nix/src/libutil/types.hh | 10 | ||||
-rw-r--r-- | third_party/nix/src/libutil/util.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix-env/nix-env.cc | 10 | ||||
-rw-r--r-- | third_party/nix/src/nix/command.hh | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/legacy.hh | 2 |
16 files changed, 48 insertions, 45 deletions
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<Path, Path> SrcToStore; +using SrcToStore = std::map<Path, Path>; std::ostream& operator<<(std::ostream& str, const Value& v); @@ -298,15 +298,15 @@ class EvalState { std::function<void(const Path&)> file_access_trace_fn = nullptr; Path last_traced_file = ""; - typedef std::map<Symbol, size_t> PrimOpCalls; + using PrimOpCalls = std::map<Symbol, size_t>; PrimOpCalls primOpCalls; - typedef std::map<ExprLambda*, size_t> FunctionCalls; + using FunctionCalls = std::map<ExprLambda*, size_t>; FunctionCalls functionCalls; void incrFunctionCall(ExprLambda* fun); - typedef std::map<Pos, size_t> AttrSelects; + using AttrSelects = std::map<Pos, size_t>; 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<DrvInfo> DrvInfos; +using DrvInfos = std::list<DrvInfo>; /* 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<Path> FileProp; +using FileProp = std::set<Path>; static FileProp done; static FileProp postponed = FileProp{}; @@ -158,7 +158,7 @@ struct Package { : path{path}, active{active}, priority{priority} {} }; -typedef std::vector<Package> Packages; +using Packages = std::vector<Package>; 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<std::string, std::set<std::string> > DrvPathWithOutputs; +using DrvPathWithOutputs = std::pair<std::string, std::set<std::string> >; 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<AutoCloseFD> FDPtr; - typedef std::list<FDPtr> FDs; + using FDs = std::list<FDPtr>; 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<ino_t> InodeHash; + using InodeHash = std::unordered_set<ino_t>; InodeHash loadInodeHash(); static Strings readDirectoryIgnoringInodes(const Path& path, @@ -295,8 +295,8 @@ class LocalStore : public LocalFSStore { friend class SubstitutionGoal; }; -typedef std::pair<dev_t, ino_t> Inode; -typedef std::set<Inode> InodesSeen; +using Inode = std::pair<dev_t, ino_t>; +using InodesSeen = std::set<Inode>; /* "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<std::pair<std::string, std::string>> Table2; +using Table2 = std::vector<std::pair<std::string, std::string> >; 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<Path> { }; struct GlobalConfig : public AbstractConfig { - typedef std::vector<Config*> ConfigRegistrations; + using ConfigRegistrations = std::vector<Config*>; 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 CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>> class basic_istringbuf_nocopy : public std::basic_streambuf<CharT, Traits> { public: - typedef std::basic_string<CharT, Traits, Allocator> string_type; + using string_type = std::basic_string<CharT, Traits, Allocator>; - typedef typename std::basic_streambuf<CharT, Traits>::off_type off_type; + using off_type = typename std::basic_streambuf<CharT, Traits>::off_type; - typedef typename std::basic_streambuf<CharT, Traits>::pos_type pos_type; + using pos_type = typename std::basic_streambuf<CharT, Traits>::pos_type; - typedef typename std::basic_streambuf<CharT, Traits>::int_type int_type; + using int_type = typename std::basic_streambuf<CharT, Traits>::int_type; - typedef typename std::basic_streambuf<CharT, Traits>::traits_type traits_type; + using traits_type = typename std::basic_streambuf<CharT, Traits>::traits_type; private: const string_type& s; @@ -28,7 +28,7 @@ class basic_istringbuf_nocopy : public std::basic_streambuf<CharT, Traits> { 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<CharT, Traits> { 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<CharT, Traits> { template <class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>> class basic_istringstream_nocopy : public std::basic_iostream<CharT, Traits> { - typedef basic_istringbuf_nocopy<CharT, Traits, Allocator> buf_type; + using buf_type = basic_istringbuf_nocopy<CharT, Traits, Allocator>; 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<CharT, Traits>(&buf), buf(s){}; }; -typedef basic_istringstream_nocopy<char> istringstream_nocopy; +using istringstream_nocopy = basic_istringstream_nocopy<char>; 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<bool(const ref<R>&)> Validator; + using Validator = std::function<bool(const ref<R>&)>; 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<size_t(unsigned char*, size_t)> lambda_t; + using lambda_t = std::function<size_t(unsigned char*, size_t)>; 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<std::string> Strings; -typedef std::set<std::string> StringSet; -typedef std::map<std::string, std::string> StringMap; +using StringSet = std::set<std::string>; +using StringMap = std::map<std::string, std::string>; /* Paths are just strings. */ -typedef std::string Path; -typedef std::list<Path> Paths; -typedef std::set<Path> PathSet; +using Path = std::string; +using Paths = std::list<Path>; +using PathSet = std::set<Path>; } // 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<DIR, DIRDeleter> AutoCloseDir; +using AutoCloseDir = std::unique_ptr<DIR, DIRDeleter>; class Pid { pid_t pid = -1; @@ -457,7 +457,7 @@ struct MaintainCount { std::pair<unsigned short, unsigned short> getWindowSize(); /* Used in various places. */ -typedef std::function<bool(const Path& path)> PathFilter; +using PathFilter = std::function<bool(const Path&)>; 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<unsigned int> done; for (auto& i : selectors) { - typedef std::list<std::pair<DrvInfo, unsigned int> > Matches; + using Matches = std::list<std::pair<DrvInfo, unsigned int> >; 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<std::string, std::pair<DrvInfo, unsigned int> > Newest; + using Newest = std::map<std::string, std::pair<DrvInfo, unsigned int> >; 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<std::string, Path> outputs; }; -typedef std::vector<Buildable> Buildables; +using Buildables = std::vector<Buildable>; struct Installable { virtual std::string what() = 0; @@ -140,7 +140,7 @@ struct StorePathCommand : public InstallablesCommand { void run(ref<Store> store) override; }; -typedef std::map<std::string, ref<Command>> Commands; +using Commands = std::map<std::string, ref<Command>>; /* An argument parser that supports multiple subcommands, i.e. ‘<command> <subcommand>’. */ 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<void(int, char**)> MainFunction; struct RegisterLegacyCommand { - typedef std::map<std::string, MainFunction> Commands; + using Commands = std::map<std::string, MainFunction>; static Commands* commands; RegisterLegacyCommand(const std::string& name, MainFunction fun) { |