//Required function for printing debug information
string PointerAliasLattice::str(string indent)
{
        ostringstream oss;
	oss << "State:" << state <<" known:" << aliasDeterminate;
        oss<< " Aliases:{ ";
        for(set<varID>::iterator al = aliasedVariables.begin(); al!=aliasedVariables.end(); al++){             
             oss << *al;
             if(al != aliasedVariables.end())
                oss<<"  ";
        }      
        oss<<" }";

        oss << "{";        
        for(set< std::pair<aliasDerefCount, aliasDerefCount> >::iterator alRel = aliasRelations.begin(); alRel!=aliasRelations.end(); alRel++){
            if((alRel->first).var != NULL && (alRel->second).var !=NULL) 
                oss << "(" << isSgVariableSymbol((alRel->first).var)->get_name() 
                    << "," <<(alRel->first).vID
                    << "," << (alRel->first).derefLevel
                    << ") ("
                    << isSgVariableSymbol((alRel->second).var)->get_name() 
                    << "," <<(alRel->second).vID
                    << "," <<(alRel->second).derefLevel 
                    << ")";
            else
                ROSE_ASSERT(((alRel->first).var == NULL && (alRel->second).var ==NULL));
        }
        oss << "}";
        return oss.str();
}
Ejemplo n.º 2
0
/*
 * Constructor for registering an array
 */
RegisterPointers::RegisterPointers(SgInitializedName* p_varName, bool p_isGlobal) :
	expression(NULL),
	varName(p_varName),
	varSymbol(NULL),
	isGlobal(p_isGlobal),
	definedInSystemHeader(false),
	compilerGenerated(false),
	addrUsedInIO(false)
{
	definedInSystemHeader = isDefinedInSystemHeaders(varName);
	varSymbol = isSgVariableSymbol(varName->search_for_symbol_from_symbol_table());
	ROSE_ASSERT(varSymbol != NULL);
	compilerGenerated = isCompilerGenerated(varSymbol);
}
Ejemplo n.º 3
0
void Driver<Sage>::addPointerToTopParentDeclaration(SgSymbol * symbol, unsigned file_id) {
  SgSymbol * parent = symbol;
  std::map<SgSymbol *, SgSymbol *>::const_iterator it_parent = p_parent_map.find(symbol);
  assert(it_parent != p_parent_map.end());
  while (it_parent->second != NULL) {
    parent = it_parent->second;
    it_parent = p_parent_map.find(parent);
    assert(it_parent != p_parent_map.end());
  }
  assert(parent != NULL);

  SgDeclarationStatement * decl_to_add = NULL;
  SgVariableSymbol * var_sym = isSgVariableSymbol(parent);
  if (var_sym != NULL) {
    assert(var_sym == symbol);

    SgInitializedName * init_name = isSgInitializedName(var_sym->get_symbol_basis());
    assert(init_name != NULL);

    // TODO
  }
  else
    decl_to_add = isSgDeclarationStatement(parent->get_symbol_basis());
  assert(decl_to_add != NULL);

  std::map<unsigned, SgSourceFile *>::iterator it_file = id_to_file_map.find(file_id);
  assert(it_file != id_to_file_map.end());
  SgSourceFile * file = it_file->second;
  assert(file != NULL);

  SgGlobal * global_scope = file->get_globalScope();
  assert(global_scope != NULL);

  const std::vector<SgDeclarationStatement *> & declaration_list = global_scope->getDeclarationList();
  if (find(declaration_list.begin(), declaration_list.end(), decl_to_add) == declaration_list.end())
    SageInterface::prependStatement(decl_to_add, global_scope);
}