refactor(3p/nix): Apply clang-tidy's modernize-* fixes
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).
This commit is contained in:
parent
fed31b2c9b
commit
d331d3a0b5
59 changed files with 349 additions and 321 deletions
2
third_party/nix/src/libexpr/attr-path.cc
vendored
2
third_party/nix/src/libexpr/attr-path.cc
vendored
|
|
@ -15,7 +15,7 @@ static Strings parseAttrPath(const string& s) {
|
|||
cur.clear();
|
||||
} else if (*i == '"') {
|
||||
++i;
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (i == s.end()) {
|
||||
throw Error(format("missing closing quote in selection path '%1%'") %
|
||||
s);
|
||||
|
|
|
|||
25
third_party/nix/src/libexpr/eval.cc
vendored
25
third_party/nix/src/libexpr/eval.cc
vendored
|
|
@ -328,7 +328,7 @@ EvalState::EvalState(const Strings& _searchPath, ref<Store> store)
|
|||
repair(NoRepair),
|
||||
store(store),
|
||||
baseEnv(allocEnv(128)),
|
||||
staticBaseEnv(false, 0) {
|
||||
staticBaseEnv(false, nullptr) {
|
||||
countCalls = getEnv("NIX_COUNT_CALLS", "0") != "0";
|
||||
|
||||
assert(gcInitialised);
|
||||
|
|
@ -378,7 +378,7 @@ EvalState::EvalState(const Strings& _searchPath, ref<Store> store)
|
|||
createBaseEnv();
|
||||
}
|
||||
|
||||
EvalState::~EvalState() {}
|
||||
EvalState::~EvalState() = default;
|
||||
|
||||
Path EvalState::checkSourcePath(const Path& path_) {
|
||||
if (!allowedPaths) {
|
||||
|
|
@ -575,7 +575,7 @@ Value& mkString(Value& v, const string& s, const PathSet& context) {
|
|||
for (auto& i : context) {
|
||||
v.string.context[n++] = dupString(i.c_str());
|
||||
}
|
||||
v.string.context[n] = 0;
|
||||
v.string.context[n] = nullptr;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
@ -591,10 +591,10 @@ inline Value* EvalState::lookupVar(Env* env, const ExprVar& var, bool noEval) {
|
|||
return env->values[var.displ];
|
||||
}
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (env->type == Env::HasWithExpr) {
|
||||
if (noEval) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
Value* v = allocValue();
|
||||
evalAttrs(*env->up, (Expr*)env->values[0], *v);
|
||||
|
|
@ -656,7 +656,8 @@ void EvalState::mkList(Value& v, size_t size) {
|
|||
} else {
|
||||
v.type = tListN;
|
||||
v.bigList.size = size;
|
||||
v.bigList.elems = size ? (Value**)allocBytes(size * sizeof(Value*)) : 0;
|
||||
v.bigList.elems =
|
||||
size ? (Value**)allocBytes(size * sizeof(Value*)) : nullptr;
|
||||
}
|
||||
nrListElems += size;
|
||||
}
|
||||
|
|
@ -822,7 +823,7 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
|
|||
env2.up = &env;
|
||||
dynamicEnv = &env2;
|
||||
|
||||
AttrDefs::iterator overrides = attrs.find(state.sOverrides);
|
||||
auto overrides = attrs.find(state.sOverrides);
|
||||
bool hasOverrides = overrides != attrs.end();
|
||||
|
||||
/* The recursive attributes are evaluated in the new
|
||||
|
|
@ -858,7 +859,7 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
|
|||
newBnds->push_back(i);
|
||||
}
|
||||
for (auto& i : *vOverrides->attrs) {
|
||||
AttrDefs::iterator j = attrs.find(i.name);
|
||||
auto j = attrs.find(i.name);
|
||||
if (j != attrs.end()) {
|
||||
(*newBnds)[j->second.displ] = i;
|
||||
env2.values[j->second.displ] = i.value;
|
||||
|
|
@ -955,7 +956,7 @@ unsigned long nrLookups = 0;
|
|||
|
||||
void ExprSelect::eval(EvalState& state, Env& env, Value& v) {
|
||||
Value vTmp;
|
||||
Pos* pos2 = 0;
|
||||
Pos* pos2 = nullptr;
|
||||
Value* vAttrs = &vTmp;
|
||||
|
||||
e->eval(state, env, vTmp);
|
||||
|
|
@ -985,7 +986,7 @@ void ExprSelect::eval(EvalState& state, Env& env, Value& v) {
|
|||
}
|
||||
}
|
||||
|
||||
state.forceValue(*vAttrs, (pos2 != NULL ? *pos2 : this->pos));
|
||||
state.forceValue(*vAttrs, (pos2 != nullptr ? *pos2 : this->pos));
|
||||
|
||||
} catch (Error& e) {
|
||||
if (pos2 && pos2->file != state.sDerivationNix) {
|
||||
|
|
@ -1334,7 +1335,7 @@ void EvalState::concatLists(Value& v, size_t nrLists, Value** lists,
|
|||
const Pos& pos) {
|
||||
nrListConcats++;
|
||||
|
||||
Value* nonEmpty = 0;
|
||||
Value* nonEmpty = nullptr;
|
||||
size_t len = 0;
|
||||
for (size_t n = 0; n < nrLists; ++n) {
|
||||
forceList(*lists[n], pos);
|
||||
|
|
@ -1796,7 +1797,7 @@ void EvalState::printStats() {
|
|||
|
||||
#if HAVE_BOEHMGC
|
||||
GC_word heapSize, totalBytes;
|
||||
GC_get_heap_usage_safe(&heapSize, 0, 0, 0, &totalBytes);
|
||||
GC_get_heap_usage_safe(&heapSize, nullptr, nullptr, nullptr, &totalBytes);
|
||||
#endif
|
||||
if (showStats) {
|
||||
auto outPath = getEnv("NIX_SHOW_STATS_PATH", "-");
|
||||
|
|
|
|||
17
third_party/nix/src/libexpr/get-drvs.cc
vendored
17
third_party/nix/src/libexpr/get-drvs.cc
vendored
|
|
@ -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').
|
||||
|
|
|
|||
2
third_party/nix/src/libexpr/get-drvs.hh
vendored
2
third_party/nix/src/libexpr/get-drvs.hh
vendored
|
|
@ -33,7 +33,7 @@ struct DrvInfo {
|
|||
string attrPath; /* path towards the derivation */
|
||||
|
||||
DrvInfo(EvalState& state) : state(&state){};
|
||||
DrvInfo(EvalState& state, const string& attrPath, Bindings* attrs);
|
||||
DrvInfo(EvalState& state, string attrPath, Bindings* attrs);
|
||||
DrvInfo(EvalState& state, ref<Store> store,
|
||||
const std::string& drvPathWithOutputs);
|
||||
|
||||
|
|
|
|||
4
third_party/nix/src/libexpr/json-to-value.cc
vendored
4
third_party/nix/src/libexpr/json-to-value.cc
vendored
|
|
@ -66,7 +66,7 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
|
|||
ValueVector values;
|
||||
values.reserve(128);
|
||||
skipWhitespace(s);
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (values.empty() && *s == ']') {
|
||||
break;
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
|
|||
else if (*s == '{') {
|
||||
s++;
|
||||
ValueMap attrs;
|
||||
while (1) {
|
||||
while (true) {
|
||||
skipWhitespace(s);
|
||||
if (attrs.empty() && *s == '}') {
|
||||
break;
|
||||
|
|
|
|||
5
third_party/nix/src/libexpr/names.cc
vendored
5
third_party/nix/src/libexpr/names.cc
vendored
|
|
@ -1,5 +1,7 @@
|
|||
#include "names.hh"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "util.hh"
|
||||
|
||||
namespace nix {
|
||||
|
|
@ -26,8 +28,7 @@ DrvName::DrvName(const string& s) : hits(0) {
|
|||
bool DrvName::matches(DrvName& n) {
|
||||
if (name != "*") {
|
||||
if (!regex) {
|
||||
regex = std::unique_ptr<std::regex>(
|
||||
new std::regex(name, std::regex::extended));
|
||||
regex = std::make_unique<std::regex>(name, std::regex::extended);
|
||||
}
|
||||
if (!std::regex_match(n.name, *regex)) {
|
||||
return false;
|
||||
|
|
|
|||
2
third_party/nix/src/libexpr/nixexpr.cc
vendored
2
third_party/nix/src/libexpr/nixexpr.cc
vendored
|
|
@ -239,7 +239,7 @@ void ExprVar::bindVars(const StaticEnv& env) {
|
|||
withLevel = level;
|
||||
}
|
||||
} else {
|
||||
StaticEnv::Vars::const_iterator i = curEnv->vars.find(name);
|
||||
auto i = curEnv->vars.find(name);
|
||||
if (i != curEnv->vars.end()) {
|
||||
fromWith = false;
|
||||
this->level = level;
|
||||
|
|
|
|||
12
third_party/nix/src/libexpr/primops.cc
vendored
12
third_party/nix/src/libexpr/primops.cc
vendored
|
|
@ -62,7 +62,7 @@ void EvalState::realiseContext(const PathSet& context) {
|
|||
paths. */
|
||||
if (allowedPaths) {
|
||||
auto drv = store->derivationFromPath(decoded.first);
|
||||
DerivationOutputs::iterator i = drv.outputs.find(decoded.second);
|
||||
auto i = drv.outputs.find(decoded.second);
|
||||
if (i == drv.outputs.end()) {
|
||||
throw Error("derivation '%s' does not have an output named '%s'",
|
||||
decoded.first, decoded.second);
|
||||
|
|
@ -160,7 +160,7 @@ static void prim_scopedImport(EvalState& state, const Pos& pos, Value** args,
|
|||
|
||||
/* Want reasonable symbol names, so extern C */
|
||||
/* !!! Should we pass the Pos or the file name too? */
|
||||
extern "C" typedef void (*ValueInitializer)(EvalState& state, Value& v);
|
||||
extern "C" using ValueInitializer = void(*)(EvalState&, Value&);
|
||||
|
||||
/* Load a ValueInitializer from a DSO and return whatever it initializes */
|
||||
void prim_importNative(EvalState& state, const Pos& pos, Value** args,
|
||||
|
|
@ -186,7 +186,7 @@ void prim_importNative(EvalState& state, const Pos& pos, Value** args,
|
|||
}
|
||||
|
||||
dlerror();
|
||||
ValueInitializer func = (ValueInitializer)dlsym(handle, sym.c_str());
|
||||
auto func = (ValueInitializer)dlsym(handle, sym.c_str());
|
||||
if (!func) {
|
||||
char* message = dlerror();
|
||||
if (message) {
|
||||
|
|
@ -2090,7 +2090,7 @@ static void prim_replaceStrings(EvalState& state, const Pos& pos, Value** args,
|
|||
for (unsigned int n = 0; n < args[1]->listSize(); ++n) {
|
||||
PathSet ctx;
|
||||
auto s = state.forceString(*args[1]->listElems()[n], ctx, pos);
|
||||
to.push_back(std::make_pair(std::move(s), std::move(ctx)));
|
||||
to.emplace_back(std::move(s), std::move(ctx));
|
||||
}
|
||||
|
||||
PathSet context;
|
||||
|
|
@ -2253,7 +2253,7 @@ RegisterPrimOp::RegisterPrimOp(std::string name, size_t arity, PrimOpFun fun) {
|
|||
}
|
||||
|
||||
void EvalState::createBaseEnv() {
|
||||
baseEnv.up = 0;
|
||||
baseEnv.up = nullptr;
|
||||
|
||||
/* Add global constants such as `true' to the base environment. */
|
||||
Value v;
|
||||
|
|
@ -2281,7 +2281,7 @@ void EvalState::createBaseEnv() {
|
|||
};
|
||||
|
||||
if (!evalSettings.pureEval) {
|
||||
mkInt(v, time(0));
|
||||
mkInt(v, time(nullptr));
|
||||
addConstant("__currentTime", v);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue