commit c1e0d1ddebddd59b5c843dc42be3908beed7628d
Author: Benjamin Lorenz <lorenz@math.tu-berlin.de>
Date:   Wed Feb 17 13:56:57 2021 +0100

    xcode12: adjust a few range loops for -Wrange-loop-analysis (add/remove ref)

diff --git a/apps/fan/include/compactification.h b/apps/fan/include/compactification.h
index 260beebf0c..86f8f12132 100644
--- a/apps/fan/include/compactification.h
+++ b/apps/fan/include/compactification.h
@@ -107,7 +107,7 @@ public:
     bool found = true;
     while (found) {
       found = false;
-      for (const auto& p : G.in_adjacent_nodes(currentNode)) {
+      for (const auto p : G.in_adjacent_nodes(currentNode)) {
         const BasicDecoration& decor = oldHasseDiagram.decoration(p);
         if (incl(a, decor.face) <= 0) {
           found = true;
diff --git a/apps/fan/src/secondary_fan.cc b/apps/fan/src/secondary_fan.cc
index 129bafa512..3d27abfcd8 100644
--- a/apps/fan/src/secondary_fan.cc
+++ b/apps/fan/src/secondary_fan.cc
@@ -51,7 +51,7 @@ boundary_of(const std::vector<Simplex>& S, const Simplex& ignore)
 {
    hash_map<Simplex, Int> multiplicity_of;
    for (const auto& sigma: S)
-      for (const Int& i: sigma)
+      for (const Int i: sigma)
          ++multiplicity_of[sigma - i];
    
    std::vector<Simplex> boundary;
diff --git a/apps/graph/include/LatticeTools.h b/apps/graph/include/LatticeTools.h
index 9b3825e14b..aec9df3d73 100644
--- a/apps/graph/include/LatticeTools.h
+++ b/apps/graph/include/LatticeTools.h
@@ -36,7 +36,7 @@ Int find_vertex_node(const LType& HD, Int v)
 template <typename LType, typename SetType>
 Int find_facet_node(const LType& HD, const GenericSet<SetType>& F)
 {
-   for (const auto& f: HD.nodes_of_rank(HD.rank()-1))
+   for (const auto f: HD.nodes_of_rank(HD.rank()-1))
       if (HD.face(f)==F)
          return f;
    throw no_match("facet node not found");
diff --git a/apps/group/include/action.h b/apps/group/include/action.h
index 9725f0fccb..ef8f1cc8af 100644
--- a/apps/group/include/action.h
+++ b/apps/group/include/action.h
@@ -387,7 +387,7 @@ struct action<TMap&, on_container, Perm, is_map, is_container, stores_ref> {
    {
       result_type img;
       const action<typename TMap::key_type, on_container, Perm> a(perm);
-      for (const auto e : m)
+      for (const auto& e : m)
          img[a(e.first)] = e.second;
       return img;
    }
diff --git a/apps/group/include/permlib.h b/apps/group/include/permlib.h
index a49b3270eb..b1051b8b19 100644
--- a/apps/group/include/permlib.h
+++ b/apps/group/include/permlib.h
@@ -256,7 +256,7 @@ public:
    SetType lex_min_representative(const SetType& dGamma_in) const
    {
       permlib::dset dGamma(permlib_group->n);
-      for (const auto& s : dGamma_in)
+      for (const auto s : dGamma_in)
          dGamma.set(s);
       permlib::dset image = smallestSetImage(*permlib_group, dGamma);
       SetType res(permlib_group->n);
diff --git a/apps/group/include/sparse_isotypic_components.h b/apps/group/include/sparse_isotypic_components.h
index 585072c797..45abe6c0a7 100644
--- a/apps/group/include/sparse_isotypic_components.h
+++ b/apps/group/include/sparse_isotypic_components.h
@@ -154,7 +154,7 @@ sparse_isotypic_spanning_set_and_support_impl(Int order,
          if (new_hash_eq == old_hash_eq) continue; // guard against the most trivial repetition
          old_hash_eq = new_hash_eq;
          if (calculate_support) {
-            for (const auto m: old_hash_eq)
+            for (const auto& m: old_hash_eq)
                if (!is_zero(m.second))
                   support += m.first;            
          } else  {
@@ -179,7 +179,7 @@ augment_index_of(hash_map<SparseSet, Int>& index_of,
 {
    Int index = index_of.size();
    for (const auto& sgen: subspace_generators)
-      for (const auto m: sgen)
+      for (const auto& m: sgen)
          if (!index_of.exists(m.first))
             index_of[m.first] = index++;
 }
@@ -192,7 +192,7 @@ list_matrix_representation(const hash_map<SparseSet, Int>& index_of,
   ListMatrix<SparseVector<Rational>> sgen_matrix(0, index_of.size());
    for (const auto& sgen: subspace_generators) {
       SparseVector<Rational> new_sgen(index_of.size());
-      for (const auto m: sgen)
+      for (const auto& m: sgen)
          new_sgen[index_of.at(m.first)] = m.second;
       sgen_matrix /= new_sgen;
    }
@@ -212,7 +212,7 @@ spans_invariant_subspace_impl(const Array<Array<Int>>& group_generators,
    for (const auto& sgen: subspace_generators) {
       for (const auto& o_sgen: unordered_orbit<on_container>(group_generators, sgen)) {
          SparseVector<Rational> new_sgen(index_of.size());
-         for (const auto m: o_sgen) {
+         for (const auto& m: o_sgen) {
             try {
                new_sgen[index_of.at(m.first)] = m.second;
             } catch (const no_match&) {
diff --git a/apps/matroid/src/laminar.cc b/apps/matroid/src/laminar.cc
index 23a2a6f609..90675a212c 100644
--- a/apps/matroid/src/laminar.cc
+++ b/apps/matroid/src/laminar.cc
@@ -32,7 +32,7 @@ bool check_circuit_compatibility(const Set<Int>& c1, const Set<Int>& c2, const L
 {
   const auto relevant_faces = hd.nodes_of_rank(c2.size()-1);
   Set<Int> closure;
-  for (const auto& rf : relevant_faces) {
+  for (const auto rf : relevant_faces) {
     const auto& rf_face = hd.face(rf);
     // Check if the flat contains c2
     if (incl(c2, rf_face) <= 0) {
diff --git a/apps/polytope/src/symmetrized_cocircuit_equations.cc b/apps/polytope/src/symmetrized_cocircuit_equations.cc
index 4efca522aa..3e6ad4330e 100644
--- a/apps/polytope/src/symmetrized_cocircuit_equations.cc
+++ b/apps/polytope/src/symmetrized_cocircuit_equations.cc
@@ -134,7 +134,7 @@ cocircuit_equations_support_reps(const Matrix<Scalar>& points,
    for (Int i = 0; i < representative_interior_ridge_simplices.size(); ++i) {
       const group::SparseSimplexVector<SetType> cocircuit_equation = cocircuit_equation_of_ridge_impl(points, representative_interior_ridge_simplices[i]);
       Set<Int> support;
-      for (const auto m: cocircuit_equation)
+      for (const auto& m: cocircuit_equation)
          if (!is_zero(m.second))
             support += index_of_maximal.at(Gamma.lex_min_representative(m.first));
       if (filename.size())
diff --git a/apps/polytope/src/truncation.cc b/apps/polytope/src/truncation.cc
index 4ec17894e4..a6fcf04cf6 100644
--- a/apps/polytope/src/truncation.cc
+++ b/apps/polytope/src/truncation.cc
@@ -92,7 +92,7 @@ BigObject truncation(BigObject p_in, const GenericSet<TSet>& trunc_vertices, Opt
       copy_range(entire(rows(VIF.minor(All,~keys(vertex_map)))), rows(VIF_out).begin());
 
    Int new_facet = n_facets;
-   for (const auto vm : vertex_map) {
+   for (const auto& vm : vertex_map) {
       Int new_vertex = vm.second;
       for (auto nb = entire(G.adjacent_nodes(vm.first));  !nb.at_end();  ++nb, ++new_vertex) {
          // the new vertex inherits the ridge from the truncated vertex,
@@ -146,7 +146,7 @@ BigObject truncation(BigObject p_in, const GenericSet<TSet>& trunc_vertices, Opt
       if (orth.cols() != 0) orth.col(0).fill(0);
 
       auto new_facet_it = rows(F_out).begin() + n_facets;
-      for (const auto vm : vertex_map) {
+      for (const auto& vm : vertex_map) {
          const Int v_cut_off = vm.first;
          Matrix<Scalar> basis(G.out_degree(v_cut_off), V.cols());
          const bool simple_vertex = basis.rows()+AH.rows() == V.cols()-1;
diff --git a/apps/tropical/include/double_description.h b/apps/tropical/include/double_description.h
index 32a2ff7137..fe5cb2c92c 100644
--- a/apps/tropical/include/double_description.h
+++ b/apps/tropical/include/double_description.h
@@ -259,7 +259,7 @@ monoextremals(const GenericMatrix<Matrix1, TropicalNumber<Addition, Scalar>>& ge
 
    // check for all generators if they are contained in the halfspace given by the pair
    // (feasible_side, infeasible_side)
-   for (const auto& r : rows(generators)) {
+   for (const auto r : rows(generators)) {
       if (Addition::orientation()*(feasible_side*r).compare(infeasible_side*r) <= 0)
          remaining_generators += r_index;
       ++r_index;
diff --git a/bundled/atint/apps/tropical/include/divisor.h b/bundled/atint/apps/tropical/include/divisor.h
index 9626b5c269..f78558678d 100644
--- a/bundled/atint/apps/tropical/include/divisor.h
+++ b/bundled/atint/apps/tropical/include/divisor.h
@@ -188,7 +188,7 @@ BigObject divisorByValueMatrix(BigObject complex, const Matrix<Rational>& values
     for (Int co = 0; co < codimOneCones.rows(); ++co) {
       if (!unbalancedFaces.contains(co)) { // Only compute values at balanced codim-1-cones
         Rational coweight(0); // Have to take rational since intermediate values may be rational
-        for (const auto& mc : coneIncidences.row(co)) {
+        for (const auto mc : coneIncidences.row(co)) {
           coweight += weights[mc] * lnFunctionVector[std::make_pair(co,mc)] * currentValues;
         }
         // Now substract the value of the lattice normal sum
diff --git a/lib/core/include/internal/assoc.h b/lib/core/include/internal/assoc.h
index 73db8e63c1..6fe686bebd 100644
--- a/lib/core/include/internal/assoc.h
+++ b/lib/core/include/internal/assoc.h
@@ -220,7 +220,7 @@ struct hash_func<TMap, is_map> {
       size_t a(1);
       // we cannot depend on the keys being visited in any particular order because
       // the Map might be a hash_map, so we need a commutative and associative operation
-      for (const auto e : m)
+      for (const auto& e : m)
          a += key_hasher(e.first) + mapped_hasher(e.second);
       return a;
    }
diff --git a/lib/core/include/permutations.h b/lib/core/include/permutations.h
index 55c918e7bc..75dfbea4c3 100644
--- a/lib/core/include/permutations.h
+++ b/lib/core/include/permutations.h
@@ -701,7 +701,7 @@ permutation_subgroup_generators(const Array<Permutation>& gens,
 {
    Map<Int, Int> index_of;
    Int index = 0;
-   for (const auto& s: subdomain)
+   for (const auto s: subdomain)
       index_of[s] = index++;
    
    Set<Array<Int>> subgens;
@@ -710,7 +710,7 @@ permutation_subgroup_generators(const Array<Permutation>& gens,
    for (const auto& g: gens) {
       Array<Int> candidate_gen(subdomain.size());
       bool candidate_ok(true);
-      for (const auto& i: subdomain) {
+      for (const auto i: subdomain) {
          if (!index_of.exists(g[i])) {
             candidate_ok = false;
             break;

commit 4d335760e6aaef54dc97d720db83ab0ce9db6645
Author: Benjamin Lorenz <lorenz@math.tu-berlin.de>
Date:   Wed Feb 17 13:57:42 2021 +0100

    xcode12: suppress range-loop-analysis in normaliz
    
    xcode 12 corresponds to clang 10 but apple has some special version
    that has some extra warnings enabled by default...

diff --git a/bundled/libnormaliz/apps/polytope/src/libnormaliz_inst.cc b/bundled/libnormaliz/apps/polytope/src/libnormaliz_inst.cc
index 1155496dc8..3d67d65003 100644
--- a/bundled/libnormaliz/apps/polytope/src/libnormaliz_inst.cc
+++ b/bundled/libnormaliz/apps/polytope/src/libnormaliz_inst.cc
@@ -138,6 +138,9 @@ inline bool int_quotient(long long& Quot, const pm::Integer& Num, const pm::Inte
 #if __clang_major__ >= (defined(__APPLE__) ? 9 : 4)
 #pragma clang diagnostic ignored "-Winstantiation-after-specialization"
 #endif
+#if defined(__APPLE__) && __clang_major__ >= 12
+#pragma clang diagnostic ignored "-Wrange-loop-analysis"
+#endif
 #elif defined(__GNUC__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-variable"
diff --git a/bundled/libnormaliz/apps/polytope/src/normaliz_interface.cc b/bundled/libnormaliz/apps/polytope/src/normaliz_interface.cc
index 6f6aa75ff7..0dc430a538 100644
--- a/bundled/libnormaliz/apps/polytope/src/normaliz_interface.cc
+++ b/bundled/libnormaliz/apps/polytope/src/normaliz_interface.cc
@@ -20,6 +20,9 @@
 #pragma clang diagnostic ignored "-Wshadow"
 #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
 #pragma clang diagnostic ignored "-Wconversion"
+#if defined(__APPLE__) && __clang_major__ >= 12
+#pragma clang diagnostic ignored "-Wrange-loop-analysis"
+#endif
 #elif defined(__GNUC__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wshadow"

commit 8a58989986ae76067e94580041df8c63f926d44f
Author: Benjamin Lorenz <lorenz@math.tu-berlin.de>
Date:   Wed Feb 17 14:16:14 2021 +0100

    xcode12: corresponds to clang 10

diff --git a/perllib/Polymake/ConfigureStandalone.pm b/perllib/Polymake/ConfigureStandalone.pm
index 6feaa515a8..4039865e85 100644
--- a/perllib/Polymake/ConfigureStandalone.pm
+++ b/perllib/Polymake/ConfigureStandalone.pm
@@ -437,6 +437,7 @@ build \${build.file}: phony | $depends \${builddir}/targets.ninja
 # https://en.wikipedia.org/wiki/Xcode#Toolchain_versions
 sub xcode2clang_version {
    my $ver = eval "v$XcodeVersion";
+   return "10.0" if $ver ge v12.0;
    return "8.0" if $ver ge v11.0;
    return "7.0" if $ver ge v10.2;
    return "6.0" if $ver ge v10.0;

commit 695a15bb6b96fb9f8a3c0b1825ccb3cce8a8eab4
Author: Benjamin Lorenz <lorenz@math.tu-berlin.de>
Date:   Wed Feb 17 14:17:07 2021 +0100

    configure: allow darwin.arm64 for Apple M1

diff --git a/support/configure.pl b/support/configure.pl
index 5fbeefd8bd..c004b72de2 100644
--- a/support/configure.pl
+++ b/support/configure.pl
@@ -904,12 +904,10 @@ sub determine_architecture {
    print "determining architecture ... ";
    if ($^O eq "darwin") {
       if ( !defined($FinkBase) && !defined($BrewBase) ) {
-         if (defined $Arch) {
-            if ($Arch ne "i386" && $Arch ne "x86_64") {
-               die "Invalid architecture $Arch for Mac OS: allowed values are i386 and x86_64.\n";
-            }
-         } else {
-            $Arch = "x86_64";
+         $Arch //= `uname -m`;
+         chomp $Arch;
+         if ($Arch ne "arm64" && $Arch ne "i386" && $Arch ne "x86_64") {
+            die "Invalid architecture $Arch for Mac OS: allowed values are i386, x86_64 and arm64.\n";
          }
       }
       $ARCHFLAGS= $NeedsArchFlag ? "-arch $Arch" : "";
