about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/attr-path.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T19·47+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T19·51+0100
commit39087321811e81e26a1a47d6967df1088dcf0e95 (patch)
tree57110be423eeb7869e9960466f4b17c0ea7cd961 /third_party/nix/src/libexpr/attr-path.cc
parentcf40d08908ede4061eb15513b770c98877844b8b (diff)
style(3p/nix): Final act in the brace-wrapping saga r/777
This last change set was generated by a full clang-tidy run (including
compilation):

    clang-tidy -p ~/projects/nix-build/ \
      -checks=-*,readability-braces-around-statements -fix src/*/*.cc

Actually running clang-tidy requires some massaging to make it play
nice with Nix + meson, I'll be adding a wrapper or something for that soon.
Diffstat (limited to 'third_party/nix/src/libexpr/attr-path.cc')
-rw-r--r--third_party/nix/src/libexpr/attr-path.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/third_party/nix/src/libexpr/attr-path.cc b/third_party/nix/src/libexpr/attr-path.cc
index edab0b6df97f..3d4e9c1e1096 100644
--- a/third_party/nix/src/libexpr/attr-path.cc
+++ b/third_party/nix/src/libexpr/attr-path.cc
@@ -16,16 +16,18 @@ static Strings parseAttrPath(const string& s) {
     } else if (*i == '"') {
       ++i;
       while (1) {
-        if (i == s.end())
+        if (i == s.end()) {
           throw Error(format("missing closing quote in selection path '%1%'") %
                       s);
+        }
         if (*i == '"') {
           break;
         }
         cur.push_back(*i++);
       }
-    } else
+    } else {
       cur.push_back(*i);
+    }
     ++i;
   }
   if (!cur.empty()) {
@@ -62,33 +64,38 @@ Value* findAlongAttrPath(EvalState& state, const string& attrPath,
        according to what is specified in the attrPath. */
 
     if (apType == apAttr) {
-      if (v->type != tAttrs)
+      if (v->type != tAttrs) {
         throw TypeError(format("the expression selected by the selection path "
                                "'%1%' should be a set but is %2%") %
                         attrPath % showType(*v));
+      }
 
-      if (attr.empty())
+      if (attr.empty()) {
         throw Error(format("empty attribute name in selection path '%1%'") %
                     attrPath);
+      }
 
       Bindings::iterator a = v->attrs->find(state.symbols.create(attr));
-      if (a == v->attrs->end())
+      if (a == v->attrs->end()) {
         throw Error(
             format("attribute '%1%' in selection path '%2%' not found") % attr %
             attrPath);
+      }
       v = &*a->value;
     }
 
     else if (apType == apIndex) {
-      if (!v->isList())
+      if (!v->isList()) {
         throw TypeError(format("the expression selected by the selection path "
                                "'%1%' should be a list but is %2%") %
                         attrPath % showType(*v));
+      }
 
-      if (attrIndex >= v->listSize())
+      if (attrIndex >= v->listSize()) {
         throw Error(
             format("list index %1% in selection path '%2%' is out of range") %
             attrIndex % attrPath);
+      }
 
       v = v->listElems()[attrIndex];
     }