style(3p/nix): Add braces around single-line for-loops
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
			
			
This commit is contained in:
		
							parent
							
								
									867055133d
								
							
						
					
					
						commit
						1841d93ccb
					
				
					 45 changed files with 426 additions and 142 deletions
				
			
		
							
								
								
									
										4
									
								
								third_party/nix/src/libexpr/attr-set.hh
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/libexpr/attr-set.hh
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										36
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										36
									
								
								third_party/nix/src/libexpr/eval.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								third_party/nix/src/libexpr/get-drvs.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/libexpr/get-drvs.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								third_party/nix/src/libexpr/json-to-value.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								third_party/nix/src/libexpr/json-to-value.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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++;
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								third_party/nix/src/libexpr/names.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/libexpr/names.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										20
									
								
								third_party/nix/src/libexpr/nixexpr.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								third_party/nix/src/libexpr/nixexpr.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										8
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								third_party/nix/src/libexpr/primops.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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;
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								third_party/nix/src/libexpr/symbol-table.hh
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/libexpr/symbol-table.hh
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								third_party/nix/src/libexpr/value-to-json.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/libexpr/value-to-json.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								third_party/nix/src/libexpr/value-to-xml.cc
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								third_party/nix/src/libexpr/value-to-xml.cc
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -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)));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue