Fix invalid iterator comparisons (#2349)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Wed, 22 Aug 2018 15:37:50 +0000 (10:37 -0500)
committerGitHub <noreply@github.com>
Wed, 22 Aug 2018 15:37:50 +0000 (10:37 -0500)
src/theory/quantifiers/conjecture_generator.cpp
src/theory/quantifiers/fmf/bounded_integers.cpp
src/theory/quantifiers/sygus/ce_guided_single_inv.cpp
src/theory/sep/theory_sep.cpp
src/theory/sets/theory_sets_private.cpp

index a079017cdca2eda138b836756903f411c54b453b..e82ab617ad602962e33db220df21b57bf89d8888 100644 (file)
@@ -882,9 +882,12 @@ unsigned ConjectureGenerator::flushWaitingConjectures( unsigned& addedLemmas, in
               d_conj_count++;
             }else{
               std::vector< Node > bvs;
-              for( std::map< TypeNode, unsigned >::iterator it = d_pattern_var_id[lhs].begin(); it != d_pattern_var_id[lhs].end(); ++it ){
-                for( unsigned i=0; i<=it->second; i++ ){
-                  bvs.push_back( getFreeVar( it->first, i ) );
+              for (const std::pair<TypeNode, unsigned>& lhs_pattern :
+                   d_pattern_var_id[lhs])
+              {
+                for (unsigned i = 0; i <= lhs_pattern.second; i++)
+                {
+                  bvs.push_back(getFreeVar(lhs_pattern.first, i));
                 }
               }
               Node rsg;
index f0789a50398d96f9855224fb01136c96311fea0c..8d8bf7f507d2c86864f9494d72454b5fad3e1e28 100644 (file)
@@ -459,18 +459,18 @@ void BoundedIntegers::checkOwnership(Node f)
           success = true;
           //set Attributes on literals
           for( unsigned b=0; b<2; b++ ){
-            if (bound_lit_map[b].find(v) != bound_lit_map[b].end())
+            std::map<Node, Node>& blm = bound_lit_map[b];
+            if (blm.find(v) != blm.end())
             {
+              std::map<Node, bool>& blmp = bound_lit_pol_map[b];
               // WARNING_CANDIDATE:
               // This assertion may fail. We intentionally do not enable this in
               // production as it is considered safe for this to fail. We fail
               // the assertion in debug mode to have this instance raised to
               // our attention.
-              Assert(bound_lit_pol_map[b].find(v)
-                     != bound_lit_pol_map[b].end());
+              Assert(blmp.find(v) != blmp.end());
               BoundIntLitAttribute bila;
-              bound_lit_map[b][v].setAttribute(bila,
-                                               bound_lit_pol_map[b][v] ? 1 : 0);
+              bound_lit_map[b][v].setAttribute(bila, blmp[v] ? 1 : 0);
             }
             else
             {
index 5f5a84a6bd42d49baef1cbd1a2f51060edaa2b22..39c3baf5cb62f4ef23bd5d338b96f2b75095b862 100644 (file)
@@ -1036,8 +1036,11 @@ int TransitionInference::incrementTrace( DetTrace& dt, Node loc, bool fwd ) {
     }
   }
   if( fwd ){
-    std::map< Node, std::map< Node, Node > >::iterator it = d_com[0].d_const_eq.find( loc );
-    if( it!=d_com[0].d_const_eq.end() ){
+    Component& cm = d_com[0];
+    std::map<Node, std::map<Node, Node> >::iterator it =
+        cm.d_const_eq.find(loc);
+    if (it != cm.d_const_eq.end())
+    {
       std::vector< Node > next;
       for( unsigned i=0; i<d_prime_vars.size(); i++ ){
         Node pv = d_prime_vars[i];
index 6c9c34123b39d8c1faeb903ca4982a2e07b84e21..6085b1f23f5119eae581bd208c7f58ef03f456e3 100644 (file)
@@ -646,7 +646,9 @@ void TheorySep::check(Effort e) {
             if( assert_active[fact] ){
               Assert( atom.getKind()==kind::SEP_LABEL );
               TNode s_lbl = atom[1];
-              if( d_label_map[s_atom].find( s_lbl )!=d_label_map[s_atom].end() ){
+              std::map<Node, std::map<int, Node> >& lms = d_label_map[s_atom];
+              if (lms.find(s_lbl) != lms.end())
+              {
                 Trace("sep-process-debug") << "Active lbl : " << s_lbl << std::endl;
                 active_lbl[s_lbl] = true;
               }
index 9346970d1fe50ebfbb17daeb95cac499ff5bfee6..ab9fa6d544b539a7563ad7d000f7a8ca6c7304aa 100644 (file)
@@ -611,11 +611,14 @@ void TheorySetsPrivate::fullEffortCheck(){
           }else{
             Node r1 = d_equalityEngine.getRepresentative( n[0] );
             Node r2 = d_equalityEngine.getRepresentative( n[1] );
-            if( d_bop_index[n.getKind()][r1].find( r2 )==d_bop_index[n.getKind()][r1].end() ){
-              d_bop_index[n.getKind()][r1][r2] = n;
+            std::map<Node, Node>& binr1 = d_bop_index[n.getKind()][r1];
+            std::map<Node, Node>::iterator itb = binr1.find(r2);
+            if (itb == binr1.end())
+            {
+              binr1[r2] = n;
               d_op_list[n.getKind()].push_back( n );
             }else{
-              d_congruent[n] = d_bop_index[n.getKind()][r1][r2];
+              d_congruent[n] = itb->second;
             }
           }
           d_nvar_sets[eqc].push_back( n );