about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/get-drvs.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-20T03·33+0100
committerVincent Ambo <tazjin@google.com>2020-05-20T03·33+0100
commitd331d3a0b5c497a46e2636f308234be66566c04c (patch)
tree92526b2f99456c09c5cc81233ed5a4311abe3d2b /third_party/nix/src/libexpr/get-drvs.cc
parentfed31b2c9b364fc1ed0b724c21b068cdedf46ee7 (diff)
refactor(3p/nix): Apply clang-tidy's modernize-* fixes r/787
This applies the modernization fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html

The 'modernize-use-trailing-return-type' fix was excluded due to my
personal preference (more specifically, I think the 'auto' keyword is
misleading in that position).
Diffstat (limited to 'third_party/nix/src/libexpr/get-drvs.cc')
-rw-r--r--third_party/nix/src/libexpr/get-drvs.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc
index c62e05d4541c..aa73c01fd1f2 100644
--- a/third_party/nix/src/libexpr/get-drvs.cc
+++ b/third_party/nix/src/libexpr/get-drvs.cc
@@ -2,6 +2,7 @@
 
 #include <cstring>
 #include <regex>
+#include <utility>
 
 #include <glog/logging.h>
 
@@ -11,12 +12,12 @@
 
 namespace nix {
 
-DrvInfo::DrvInfo(EvalState& state, const string& attrPath, Bindings* attrs)
-    : state(&state), attrs(attrs), attrPath(attrPath) {}
+DrvInfo::DrvInfo(EvalState& state, string attrPath, Bindings* attrs)
+    : state(&state), attrs(attrs), attrPath(std::move(attrPath)) {}
 
 DrvInfo::DrvInfo(EvalState& state, ref<Store> store,
                  const std::string& drvPathWithOutputs)
-    : state(&state), attrs(nullptr), attrPath("") {
+    : state(&state), attrPath("") {
   auto spec = parseDrvPathWithOutputs(drvPathWithOutputs);
 
   drvPath = spec.first;
@@ -158,11 +159,11 @@ Bindings* DrvInfo::getMeta() {
     return meta;
   }
   if (!attrs) {
-    return 0;
+    return nullptr;
   }
   Bindings::iterator a = attrs->find(state->sMeta);
   if (a == attrs->end()) {
-    return 0;
+    return nullptr;
   }
   state->forceAttrs(*a->value, *a->pos);
   meta = a->value->attrs;
@@ -208,11 +209,11 @@ bool DrvInfo::checkMeta(Value& v) {
 
 Value* DrvInfo::queryMeta(const string& name) {
   if (!getMeta()) {
-    return 0;
+    return nullptr;
   }
   Bindings::iterator a = meta->find(state->symbols.create(name));
   if (a == meta->end() || !checkMeta(*a->value)) {
-    return 0;
+    return nullptr;
   }
   return a->value;
 }
@@ -303,7 +304,7 @@ void DrvInfo::setMeta(const string& name, Value* v) {
 }
 
 /* Cache for already considered attrsets. */
-typedef set<Bindings*> Done;
+using Done = set<Bindings*>;
 
 /* Evaluate value `v'.  If it evaluates to a set of type `derivation',
    then put information about it in `drvs' (unless it's already in `done').