about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-07-25T04·09-0700
committerkanepyork <rikingcoding@gmail.com>2020-07-27T21·16+0000
commitef54f5da9fa30b5c302f2a49595ee5d041f9706a (patch)
tree8d1da709a2e2d3b135d1e84eda9c402bde467726 /third_party/nix/src/libexpr/nixexpr.cc
parent69f402563a14d4b668980e4228d033d80e3bb05d (diff)
fix(3p/nix): apply all clang-tidy fixes r/1495
Change-Id: I265e763393422ee1881653527c91024458060825
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1432
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'third_party/nix/src/libexpr/nixexpr.cc')
-rw-r--r--third_party/nix/src/libexpr/nixexpr.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc
index 94e7d335cf..faf1020f85 100644
--- a/third_party/nix/src/libexpr/nixexpr.cc
+++ b/third_party/nix/src/libexpr/nixexpr.cc
@@ -18,7 +18,7 @@ std::ostream& operator<<(std::ostream& str, const Expr& e) {
 
 static void showString(std::ostream& str, const std::string& s) {
   str << '"';
-  for (auto c : (std::string)s) {
+  for (auto c : std::string(s)) {
     if (c == '"' || c == '\\' || c == '$') {
       str << "\\" << c;
     } else if (c == '\n') {
@@ -191,7 +191,7 @@ std::ostream& operator<<(std::ostream& str, const Pos& pos) {
     str << "undefined position";
   } else {
     str << (format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%") %
-            (std::string)pos.file.value() % pos.line % pos.column)
+            std::string(pos.file.value()) % pos.line % pos.column)
                .str();
   }
   return str;
@@ -232,8 +232,8 @@ void ExprPath::bindVars(const StaticEnv& env) {}
 void ExprVar::bindVars(const StaticEnv& env) {
   /* Check whether the variable appears in the environment.  If so,
      set its level and displacement. */
-  const StaticEnv* curEnv;
-  unsigned int level;
+  const StaticEnv* curEnv = nullptr;
+  unsigned int level = 0;
   int withLevel = -1;
   for (curEnv = &env, level = 0; curEnv != nullptr;
        curEnv = curEnv->up, level++) {
@@ -363,8 +363,8 @@ void ExprWith::bindVars(const StaticEnv& env) {
   /* Does this `with' have an enclosing `with'?  If so, record its
      level so that `lookupVar' can look up variables in the previous
      `with' if this one doesn't contain the desired attribute. */
-  const StaticEnv* curEnv;
-  unsigned int level;
+  const StaticEnv* curEnv = nullptr;
+  unsigned int level = 0;
   prevWith = 0;
   for (curEnv = &env, level = 1; curEnv != nullptr;
        curEnv = curEnv->up, level++) {
@@ -405,7 +405,7 @@ void ExprLambda::setName(Symbol& name) { this->name = name; }
 
 std::string ExprLambda::showNamePos() const {
   return (format("%1% at %2%") %
-          (name.has_value() ? "'" + (std::string)name.value() + "'"
+          (name.has_value() ? "'" + std::string(name.value()) + "'"
                             : "anonymous function") %
           pos)
       .str();