about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T18·04+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T18·04+0100
commit1841d93ccbe5792a17f5b9a22e65ec898c7c2668 (patch)
treef31155746ad5a21a6f10172b3edaf79b74b56819 /third_party/nix/src/libexpr
parent867055133d3f487e52dd44149f76347c2c28bf10 (diff)
style(3p/nix): Add braces around single-line for-loops r/772
These were not caught by the previous clang-tidy invocation, but were
instead sorted out using amber[0] as such:

    ambr --regex 'for (\(.+\))\s([a-z].*;)' 'for $1 { $2 }'

[0]: https://github.com/dalance/amber
Diffstat (limited to 'third_party/nix/src/libexpr')
-rw-r--r--third_party/nix/src/libexpr/attr-set.hh4
-rw-r--r--third_party/nix/src/libexpr/eval.cc36
-rw-r--r--third_party/nix/src/libexpr/get-drvs.cc4
-rw-r--r--third_party/nix/src/libexpr/json-to-value.cc8
-rw-r--r--third_party/nix/src/libexpr/names.cc4
-rw-r--r--third_party/nix/src/libexpr/nixexpr.cc20
-rw-r--r--third_party/nix/src/libexpr/primops.cc8
-rw-r--r--third_party/nix/src/libexpr/primops/context.cc4
-rw-r--r--third_party/nix/src/libexpr/symbol-table.hh4
-rw-r--r--third_party/nix/src/libexpr/value-to-json.cc4
-rw-r--r--third_party/nix/src/libexpr/value-to-xml.cc4
11 files changed, 75 insertions, 25 deletions
diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh
index 74a41a7e5d..c62c3c690d 100644
--- a/third_party/nix/src/libexpr/attr-set.hh
+++ b/third_party/nix/src/libexpr/attr-set.hh
@@ -70,7 +70,9 @@ class Bindings {
   std::vector<const Attr*> lexicographicOrder() const {
     std::vector<const Attr*> res;
     res.reserve(size_);
-    for (size_t n = 0; n < size_; n++) res.emplace_back(&attrs[n]);
+    for (size_t n = 0; n < size_; n++) {
+      res.emplace_back(&attrs[n]);
+    }
     std::sort(res.begin(), res.end(), [](const Attr* a, const Attr* b) {
       return (const string&)a->name < (const string&)b->name;
     });
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index a1965e0805..0ceb4d750b 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -334,8 +334,12 @@ EvalState::EvalState(const Strings& _searchPath, ref<Store> store)
   /* Initialise the Nix expression search path. */
   if (!evalSettings.pureEval) {
     Strings paths = parseNixPath(getEnv("NIX_PATH", ""));
-    for (auto& i : _searchPath) addToSearchPath(i);
-    for (auto& i : paths) addToSearchPath(i);
+    for (auto& i : _searchPath) {
+      addToSearchPath(i);
+    }
+    for (auto& i : paths) {
+      addToSearchPath(i);
+    }
   }
   addToSearchPath("nix=" +
                   canonPath(settings.nixDataDir + "/nix/corepkgs", true));
@@ -354,7 +358,9 @@ EvalState::EvalState(const Strings& _searchPath, ref<Store> store)
       if (store->isInStore(r.second)) {
         PathSet closure;
         store->computeFSClosure(store->toStorePath(r.second), closure);
-        for (auto& path : closure) allowedPaths->insert(path);
+        for (auto& path : closure) {
+          allowedPaths->insert(path);
+        }
       } else
         allowedPaths->insert(r.second);
     }
@@ -558,7 +564,9 @@ Value& mkString(Value& v, const string& s, const PathSet& context) {
     size_t n = 0;
     v.string.context =
         (const char**)allocBytes((context.size() + 1) * sizeof(char*));
-    for (auto& i : context) v.string.context[n++] = dupString(i.c_str());
+    for (auto& i : context) {
+      v.string.context[n++] = dupString(i.c_str());
+    }
     v.string.context[n] = 0;
   }
   return v;
@@ -1415,7 +1423,9 @@ void EvalState::forceValueDeep(Value& v) {
           throw;
         }
     } else if (v.isList()) {
-      for (size_t n = 0; n < v.listSize(); ++n) recurse(*v.listElems()[n]);
+      for (size_t n = 0; n < v.listSize(); ++n) {
+        recurse(*v.listElems()[n]);
+      }
     }
   };
 
@@ -1477,7 +1487,9 @@ string EvalState::forceString(Value& v, const Pos& pos) {
 
 void copyContext(const Value& v, PathSet& context) {
   if (v.string.context)
-    for (const char** p = v.string.context; *p; ++p) context.insert(*p);
+    for (const char** p = v.string.context; *p; ++p) {
+      context.insert(*p);
+    }
 }
 
 string EvalState::forceString(Value& v, PathSet& context, const Pos& pos) {
@@ -1807,7 +1819,9 @@ void EvalState::printStats() {
     if (countCalls) {
       {
         auto obj = topObj.object("primops");
-        for (auto& i : primOpCalls) obj.attr(i.first, i.second);
+        for (auto& i : primOpCalls) {
+          obj.attr(i.first, i.second);
+        }
       }
       {
         auto list = topObj.list("functions");
@@ -1872,7 +1886,9 @@ size_t valueSize(Value& v) {
       case tString:
         sz += doString(v.string.s);
         if (v.string.context)
-          for (const char** p = v.string.context; *p; ++p) sz += doString(*p);
+          for (const char** p = v.string.context; *p; ++p) {
+            sz += doString(*p);
+          }
         break;
       case tPath:
         sz += doString(v.path);
@@ -1881,7 +1897,9 @@ size_t valueSize(Value& v) {
         if (seen.find(v.attrs) == seen.end()) {
           seen.insert(v.attrs);
           sz += sizeof(Bindings) + sizeof(Attr) * v.attrs->capacity();
-          for (auto& i : *v.attrs) sz += doValue(*i.value);
+          for (auto& i : *v.attrs) {
+            sz += doValue(*i.value);
+          }
         }
         break;
       case tList1:
diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc
index ccbb09951f..8897db4be9 100644
--- a/third_party/nix/src/libexpr/get-drvs.cc
+++ b/third_party/nix/src/libexpr/get-drvs.cc
@@ -171,7 +171,9 @@ StringSet DrvInfo::queryMetaNames() {
   if (!getMeta()) {
     return res;
   }
-  for (auto& i : *meta) res.insert(i.name);
+  for (auto& i : *meta) {
+    res.insert(i.name);
+  }
   return res;
 }
 
diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc
index a7d9c4904c..51d001d8a5 100644
--- a/third_party/nix/src/libexpr/json-to-value.cc
+++ b/third_party/nix/src/libexpr/json-to-value.cc
@@ -82,7 +82,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
     }
     s++;
     state.mkList(v, values.size());
-    for (size_t n = 0; n < values.size(); ++n) v.listElems()[n] = values[n];
+    for (size_t n = 0; n < values.size(); ++n) {
+      v.listElems()[n] = values[n];
+    }
   }
 
   else if (*s == '{') {
@@ -111,7 +113,9 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
       s++;
     }
     state.mkAttrs(v, attrs.size());
-    for (auto& i : attrs) v.attrs->push_back(Attr(i.first, i.second));
+    for (auto& i : attrs) {
+      v.attrs->push_back(Attr(i.first, i.second));
+    }
     v.attrs->sort();
     s++;
   }
diff --git a/third_party/nix/src/libexpr/names.cc b/third_party/nix/src/libexpr/names.cc
index 92bd06308c..f83ed9fe64 100644
--- a/third_party/nix/src/libexpr/names.cc
+++ b/third_party/nix/src/libexpr/names.cc
@@ -99,7 +99,9 @@ int compareVersions(const string& v1, const string& v2) {
 
 DrvNames drvNamesFromArgs(const Strings& opArgs) {
   DrvNames result;
-  for (auto& i : opArgs) result.push_back(DrvName(i));
+  for (auto& i : opArgs) {
+    result.push_back(DrvName(i));
+  }
   return result;
 }
 
diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc
index 4c0536f35c..bd171f8166 100644
--- a/third_party/nix/src/libexpr/nixexpr.cc
+++ b/third_party/nix/src/libexpr/nixexpr.cc
@@ -97,7 +97,9 @@ void ExprAttrs::show(std::ostream& str) const {
 
 void ExprList::show(std::ostream& str) const {
   str << "[ ";
-  for (auto& i : elems) str << "(" << *i << ") ";
+  for (auto& i : elems) {
+    str << "(" << *i << ") ";
+  }
   str << "]";
 }
 
@@ -294,7 +296,9 @@ void ExprAttrs::bindVars(const StaticEnv& env) {
 }
 
 void ExprList::bindVars(const StaticEnv& env) {
-  for (auto& i : elems) i->bindVars(env);
+  for (auto& i : elems) {
+    i->bindVars(env);
+  }
 }
 
 void ExprLambda::bindVars(const StaticEnv& env) {
@@ -324,7 +328,9 @@ void ExprLet::bindVars(const StaticEnv& env) {
   StaticEnv newEnv(false, &env);
 
   unsigned int displ = 0;
-  for (auto& i : attrs->attrs) newEnv.vars[i.first] = i.second.displ = displ++;
+  for (auto& i : attrs->attrs) {
+    newEnv.vars[i.first] = i.second.displ = displ++;
+  }
 
   for (auto& i : attrs->attrs)
     i.second.e->bindVars(i.second.inherited ? env : newEnv);
@@ -365,7 +371,9 @@ void ExprAssert::bindVars(const StaticEnv& env) {
 void ExprOpNot::bindVars(const StaticEnv& env) { e->bindVars(env); }
 
 void ExprConcatStrings::bindVars(const StaticEnv& env) {
-  for (auto& i : *es) i->bindVars(env);
+  for (auto& i : *es) {
+    i->bindVars(env);
+  }
 }
 
 void ExprPos::bindVars(const StaticEnv& env) {}
@@ -389,7 +397,9 @@ string ExprLambda::showNamePos() const {
 
 size_t SymbolTable::totalSize() const {
   size_t n = 0;
-  for (auto& i : symbols) n += i.size();
+  for (auto& i : symbols) {
+    n += i.size();
+  }
   return n;
 }
 
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc
index dfcfdeae43..850d17a8f4 100644
--- a/third_party/nix/src/libexpr/primops.cc
+++ b/third_party/nix/src/libexpr/primops.cc
@@ -442,7 +442,9 @@ static void prim_genericClosure(EvalState& state, const Pos& pos, Value** args,
   /* Create the result list. */
   state.mkList(v, res.size());
   unsigned int n = 0;
-  for (auto& i : res) v.listElems()[n++] = i;
+  for (auto& i : res) {
+    v.listElems()[n++] = i;
+  }
 }
 
 static void prim_abort(EvalState& state, const Pos& pos, Value** args,
@@ -2061,7 +2063,9 @@ static void prim_replaceStrings(EvalState& state, const Pos& pos, Value** args,
         } else {
           p += i->size();
         }
-        for (auto& path : j->second) context.insert(path);
+        for (auto& path : j->second) {
+          context.insert(path);
+        }
         j->second.clear();
         break;
       }
diff --git a/third_party/nix/src/libexpr/primops/context.cc b/third_party/nix/src/libexpr/primops/context.cc
index 1ae3219f2c..347b7a0a52 100644
--- a/third_party/nix/src/libexpr/primops/context.cc
+++ b/third_party/nix/src/libexpr/primops/context.cc
@@ -35,7 +35,9 @@ static void prim_unsafeDiscardOutputDependency(EvalState& state, const Pos& pos,
   string s = state.coerceToString(pos, *args[0], context);
 
   PathSet context2;
-  for (auto& p : context) context2.insert(p.at(0) == '=' ? string(p, 1) : p);
+  for (auto& p : context) {
+    context2.insert(p.at(0) == '=' ? string(p, 1) : p);
+  }
 
   mkString(v, s, context2);
 }
diff --git a/third_party/nix/src/libexpr/symbol-table.hh b/third_party/nix/src/libexpr/symbol-table.hh
index 61a43ab978..8c27cf8ec7 100644
--- a/third_party/nix/src/libexpr/symbol-table.hh
+++ b/third_party/nix/src/libexpr/symbol-table.hh
@@ -54,7 +54,9 @@ class SymbolTable {
 
   template <typename T>
   void dump(T callback) {
-    for (auto& s : symbols) callback(s);
+    for (auto& s : symbols) {
+      callback(s);
+    }
   }
 };
 
diff --git a/third_party/nix/src/libexpr/value-to-json.cc b/third_party/nix/src/libexpr/value-to-json.cc
index 3da47dc2f8..e4f1c28537 100644
--- a/third_party/nix/src/libexpr/value-to-json.cc
+++ b/third_party/nix/src/libexpr/value-to-json.cc
@@ -50,7 +50,9 @@ void printValueAsJSON(EvalState& state, bool strict, Value& v,
       if (i == v.attrs->end()) {
         auto obj(out.object());
         StringSet names;
-        for (auto& j : *v.attrs) names.insert(j.name);
+        for (auto& j : *v.attrs) {
+          names.insert(j.name);
+        }
         for (auto& j : names) {
           Attr& a(*v.attrs->find(state.symbols.create(j)));
           auto placeholder(obj.placeholder(j));
diff --git a/third_party/nix/src/libexpr/value-to-xml.cc b/third_party/nix/src/libexpr/value-to-xml.cc
index 0e955c4ce2..a03924aa63 100644
--- a/third_party/nix/src/libexpr/value-to-xml.cc
+++ b/third_party/nix/src/libexpr/value-to-xml.cc
@@ -29,7 +29,9 @@ static void showAttrs(EvalState& state, bool strict, bool location,
                       PathSet& drvsSeen) {
   StringSet names;
 
-  for (auto& i : attrs) names.insert(i.name);
+  for (auto& i : attrs) {
+    names.insert(i.name);
+  }
 
   for (auto& i : names) {
     Attr& a(*attrs.find(state.symbols.create(i)));