if_diff/src/idfMatchSmt.cxx
//============================================================================
// is_match(idfSmt *, idfSmt *, const idfModel &, const idfModel &)
//----------------------------------------------------------------------------
// Compare two SMT nodes that are suspected to match, to attempt one small
// step in the process of matching the entire SMT node list.
//============================================================================
is_match(idfSmt *, idfSmt *, const idfModel &, const idfModel &)
Compare two SMT nodes that are suspected to match, to attempt one small
step in the process of matching the entire SMT node list.
is_match ( idfSmt * idfSmt * const idfModel & const idfModel & ) Compare two SMT nodes that are suspected to match to attempt one small step in the process of matching the entire SMT node list .
static boolean is_match(idfSmt *smt1, idfSmt *smt2,
      	      	      	const idfModel &model1, const idfModel &model2)
{
  locationStruct *comp1 = comparable(smt1);
  locationStruct *comp2 = comparable(smt2);
  genString sr1;
  idf_location_str(comp1, sr1);
  genString sr2;
  idf_location_str(comp2, sr2);
#if 0
  cout << "checking is_match at " << sr1.str() << " & " << sr2.str() << endl;
#endif
  if (comp1 == NULL || comp2 == NULL) {
    return false;
  }
  {
    locationStruct loc1 = *comp1;
    locationStruct loc2 = *comp2;
    int smt1_vs_smt2;
    if (   loc1.end_line == 0 && loc1.end_column == 0
        && smt1->isKeyword() && smt1->getName() != NULL) {
      loc1.end_column = strlen(smt1->getName());
    }
    if (   loc2.end_line == 0 && loc2.end_column == 0
      	&& smt2->isKeyword() && smt2->getName() != NULL) {
      loc2.end_column = strlen(smt2->getName());
    }
    boolean comparable = idf_compare_locations(&loc1, &loc2, false, smt1_vs_smt2);
    if (comparable && smt1_vs_smt2 == 0) {
      return true;
    }
  }
  boolean have_macro = is_macro(smt1, model1) || is_macro(smt2, model2);
  boolean allow_loc_omission = have_macro
    && idf_configuration.contains("SMT of macro differs in omitting end location.");
  int smt1_vs_smt2;
  if (idf_compare_locations(comp1, comp2, allow_loc_omission, smt1_vs_smt2)) {
    if (smt1_vs_smt2 == 0) {
      return true;
    }
#if 0
    cout << "Locations are comparable." << endl;
#endif
    if (idf_destructor_location_match(*smt1, *smt2, model1, model2)) {
      return true;
    }
    return false;
  }
  if (smt1->isKeyword() != smt2->isKeyword()) {
    return false;
  }
  if (smt1->isId() != smt2->isId()) {
    return false;
  }
  const char *nm1 = smt1->getName();
  const char *nm2 = smt2->getName();
  if (nm1 != NULL && nm2 != NULL) {
    return strcmp(nm1, nm2) == 0;
  }
  return false;
}
static boolean is_match ( idfSmt * smt1 , idfSmt * smt2 , const idfModel & model1 , const idfModel & model2 ) { locationStruct * comp1 = comparable ( smt1 ) ; locationStruct * comp2 = comparable ( smt2 ) ; genString sr1 ; idf_location_str ( comp1 , sr1 ) ; genString sr2 ; idf_location_str ( comp2 , sr2 ) ; #if 0 cout << " " << sr1 . str ( ) << " " << sr2 . str ( ) << endl ; #endif if ( comp1 == NULL || comp2 == NULL ) { return false ; } { locationStruct loc1 = * comp1 ; locationStruct loc2 = * comp2 ; int smt1_vs_smt2 ; if ( loc1 . end_line == 0 && loc1 . end_column == 0 && smt1 -> isKeyword ( ) && smt1 -> getName ( ) != NULL ) { loc1 . end_column = strlen ( smt1 -> getName ( ) ) ; } if ( loc2 . end_line == 0 && loc2 . end_column == 0 && smt2 -> isKeyword ( ) && smt2 -> getName ( ) != NULL ) { loc2 . end_column = strlen ( smt2 -> getName ( ) ) ; } boolean comparable = idf_compare_locations ( & loc1 , & loc2 , false , smt1_vs_smt2 ) ; if ( comparable && smt1_vs_smt2 == 0 ) { return true ; } } boolean have_macro = is_macro ( smt1 , model1 ) || is_macro ( smt2 , model2 ) ; boolean allow_loc_omission = have_macro && idf_configuration . contains ( " " ) ; int smt1_vs_smt2 ; if ( idf_compare_locations ( comp1 , comp2 , allow_loc_omission , smt1_vs_smt2 ) ) { if ( smt1_vs_smt2 == 0 ) { return true ; } #if 0 cout << " " << endl ; #endif if ( idf_destructor_location_match ( * smt1 , * smt2 , model1 , model2 ) ) { return true ; } return false ; } if ( smt1 -> isKeyword ( ) != smt2 -> isKeyword ( ) ) { return false ; } if ( smt1 -> isId ( ) != smt2 -> isId ( ) ) { return false ; } const char * nm1 = smt1 -> getName ( ) ; const char * nm2 = smt2 -> getName ( ) ; if ( nm1 != NULL && nm2 != NULL ) { return strcmp ( nm1 , nm2 ) == 0 ; } return false ; }
is_match(idfSmt *, idfSmt *, const idfModel &, const idfModel &)
Compare two SMT nodes that are suspected to match, to attempt one small
step in the process of matching the entire SMT node list.
is_match ( idfSmt * idfSmt * const idfModel & const idfModel & ) Compare two SMT nodes that are suspected to match to attempt one small step in the process of matching the entire SMT node list .
// Sometimes the length is omitted on a keyword which // is stated explicitly. // Could not get a useful comparison of locations. // Assume that we wouldn't be comparing these 2 nodes unless they were // reasonable to match up on the basis of content.  Look at content.