Пример #1
0
bool
cilk_recognize_spawn (tree exp, tree *exp0)
{
  bool spawn_found = false;
  if (TREE_CODE (exp) == CILK_SPAWN_STMT)
    {
      /* Remove the CALL_EXPR from CILK_SPAWN_STMT wrapper.  */
      exp = CILK_SPAWN_FN (exp);
      walk_tree (exp0, unwrap_cilk_spawn_stmt, NULL, NULL);
      spawn_found = true;
    }
  /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR.  */
  else if (contains_cilk_spawn_stmt (exp))
    {
      location_t loc = EXPR_LOCATION (exp);
      if (loc == UNKNOWN_LOCATION)
	{
	  tree stmt = walk_tree (&exp,
				 contains_cilk_spawn_stmt_walker,
				 NULL,
				 NULL);
	  gcc_assert (stmt != NULL_TREE);
	  loc = EXPR_LOCATION (stmt);
	}
      error_at (loc, "invalid use of %<_Cilk_spawn%>");
    }
  return spawn_found;
}
Пример #2
0
// returns a pointer to a node to abort walking the tree
// returns NULL to continue walking the tree
// return value is driven proc
node_t *walk_tree(node_t *pNode, node_t *(*pProc)(node_t *pNode))
{
	node_t* left = NULL;
	node_t* right = NULL;
	node_t* result = NULL;

	// pProc may be destructive
	// cache left and right
	if (NULL != pNode) {
		left = pNode->left;
		right = pNode->right;
	}

	// walk left if possible and not done
	if (NULL != left && NULL == result) {
		result = walk_tree(left, pProc);
	}

	// proc current node if possible and not done
	if (NULL != pProc && NULL == result) {
		result = pProc(pNode);
	}

	// walk right if possible and not done
	if (NULL != right && NULL == result) {
		result = walk_tree(right, pProc);
	}

	return result;
}
Пример #3
0
tree
replace_invariant_exprs (tree *node)
{
  size_t ix = 0;
  tree node_list = NULL_TREE;
  tree t = NULL_TREE, new_var = NULL_TREE, new_node; 
  struct inv_list data;

  data.list_values = NULL;
  data.replacement = NULL;
  data.additional_tcodes = NULL;
  walk_tree (node, find_inv_trees, (void *)&data, NULL);

  if (vec_safe_length (data.list_values))
    {
      node_list = push_stmt_list ();
      for (ix = 0; vec_safe_iterate (data.list_values, ix, &t); ix++)
	{
	  new_var = build_decl (EXPR_LOCATION (t), VAR_DECL, NULL_TREE,
				TREE_TYPE (t));
	  gcc_assert (new_var != NULL_TREE && new_var != error_mark_node);
	  new_node = build2 (MODIFY_EXPR, TREE_TYPE (t), new_var, t);
	  add_stmt (new_node);
	  vec_safe_push (data.replacement, new_var);
	}
      walk_tree (node, replace_inv_trees, (void *)&data, NULL);
      node_list = pop_stmt_list (node_list);
    }
  return node_list;
}
Пример #4
0
void find_column_headers(IAccessible *pAccessible, char ***pHeaderNames, long *pColumns) {
	long columns = 0 ;

	walk_tree(pAccessible, NULL, &columns) ;

	char **pHeaders = (char **)malloc(sizeof(char *) * columns) ;
	walk_tree(pAccessible, pHeaders, &columns) ;

	*pHeaderNames = pHeaders ;
	*pColumns = columns ;
}
Пример #5
0
/*
 *  Tree walking with acending key order
 */
void walk_tree(int fd_in, int fd_out, compact_header_t * tree)
{
    if (tree->left != NULL) {
        walk_tree(fd_in, fd_out, tree->left);
    }
    write_node(fd_in, fd_out, tree, io_buf, IO_BUFFER_SZ);

    if (tree->right != NULL) {
        walk_tree(fd_in, fd_out, tree->right);
    }
    free(tree);
}
Пример #6
0
int next_file(const char *arg, seq_t seq)
{
	char *line;
	int errors = 0;

	if (strcmp(arg, "-") == 0) {
		while ((line = next_line(stdin)))
			errors = walk_tree(line, seq);
	} else {
		errors = walk_tree(arg, seq);
	}
	return errors ? 1 : 0;
}
Пример #7
0
int main (int argc, char *argv[])
{
	char *dir = ".";
	tick_t start;
	tick_t finish;
	tick_t total;

	if (argc > 1) dir = argv[1];

	NumFiles = 0;
	start = nsecs();
	nftw_walk_tree(dir);
	finish = nsecs();
	total = finish - start;
	printf("%lld nsecs %d\n", total, NumFiles);

	NumFiles = 0;
	start = nsecs();
	walk_dir(dir, donothing, NULL, 0);
	finish = nsecs();
	total = finish - start;
	printf("%lld nsecs %d\n", total, NumFiles);

	NumFiles = 0;
	start = nsecs();
	walk_tree(dir, prfile, NULL);
	finish = nsecs();
	total = finish - start;
	printf("%lld nsecs %d\n", total, NumFiles);

	return 0;
}
static void 
analyze_variable (struct varpool_node *vnode)
{
  tree global = vnode->decl;
  walk_tree (&DECL_INITIAL (global), scan_for_static_refs, 
             NULL, visited_nodes);
}
Пример #9
0
static void
analyze_function (struct cgraph_node *fn)
{
  ipa_reference_vars_info_t info 
    = xcalloc (1, sizeof (struct ipa_reference_vars_info_d));
  ipa_reference_local_vars_info_t l
    = xcalloc (1, sizeof (struct ipa_reference_local_vars_info_d));
  tree decl = fn->decl;

  /* Add the info to the tree's annotation.  */
  get_function_ann (fn->decl)->reference_vars_info = info;

  info->local = l;
  l->statics_read = BITMAP_ALLOC (&ipa_obstack);
  l->statics_written = BITMAP_ALLOC (&ipa_obstack);

  if (dump_file)
    fprintf (dump_file, "\n local analysis of %s\n", cgraph_node_name (fn));
  
  {
    struct function *this_cfun = DECL_STRUCT_FUNCTION (decl);
    basic_block this_block;

    FOR_EACH_BB_FN (this_block, this_cfun)
      {
        block_stmt_iterator bsi;
        for (bsi = bsi_start (this_block); !bsi_end_p (bsi); bsi_next (&bsi))
          walk_tree (bsi_stmt_ptr (bsi), scan_for_static_refs, 
                     fn, visited_nodes);
      }
  }
      /* Redirect references.  */
      FOR_EACH_VEC_ELT (references_to_redirect, i, ref)
	{
	  if (ref->use == IPA_REF_ADDR)
	    {
	      struct walk_stmt_info wi;
	      memset (&wi, 0, sizeof (wi));
	      wi.info = (void *)node->function_version ();

	      if (dyn_cast<varpool_node *> (ref->referring))
		{
		  hash_set<tree> visited_nodes;
		  walk_tree (&DECL_INITIAL (ref->referring->decl),
			     replace_function_decl, &wi, &visited_nodes);
		}
	      else
		{
		  gimple_stmt_iterator it = gsi_for_stmt (ref->stmt);
		  if (ref->referring->decl != resolver_decl)
		    walk_gimple_stmt (&it, NULL, replace_function_decl, &wi);
		}

	      symtab_node *source = ref->referring;
	      ref->remove_reference ();
	      source->create_reference (inode, IPA_REF_ADDR);
	    }
	  else if (ref->use == IPA_REF_ALIAS)
	    {
	      symtab_node *source = ref->referring;
	      ref->remove_reference ();
	      source->create_reference (inode, IPA_REF_ALIAS);
	      source->add_to_same_comdat_group (inode);
	    }
	  else
	    gcc_unreachable ();
	}
Пример #11
0
static gboolean snippets_load_finished_lcb(gpointer data) {
	xmlDocPtr doc = (xmlDocPtr)data;
	xmlNodePtr cur=NULL;
	DEBUG_SIG("snippets_load_finished_lcb, priority=%d\n",G_PRIORITY_LOW);
	DEBUG_MSG("snippets_load_finished_lcb, doc=%p, starting to load xml data into treestore\n", doc);
	if (doc) {
		cur = xmlDocGetRootElement(doc);
		if (cur) {
			if (xmlStrEqual(cur->name, (const xmlChar *) "snippets")) {
				snippets_v.doc = doc;
				walk_tree(cur, NULL);
				snippets_rebuild_accelerators();
				DEBUG_MSG("snippets_load_finished_lcb, finished walking tree\n");
				return FALSE;
			}
		}
		xmlFreeDoc(doc);
		doc = NULL;
	}
	if (doc == NULL) {
		snippets_v.doc = xmlNewDoc((const xmlChar *)"1.0");
		cur = xmlNewDocNode(snippets_v.doc,NULL, (const xmlChar *)"snippets",NULL);
		xmlDocSetRootElement(snippets_v.doc, cur);
		/* DEBUG_MSG("snippets_load_finished_lcb, loading from cmenu %p and %p\n",main_v->props.cmenu_insert, main_v->props.cmenu_replace); */
		/* now check if there is a custom menu  configuration. If there is one, parse it and build a xml tree */
/*		if (snippets_convert_cmenu(cur)) {
			walk_tree(cur, NULL);
		}*/
	}
	DEBUG_MSG("snippets_load_finished_lcb, finished empty tree\n");
	return FALSE;
}
Пример #12
0
void snippets_fill_tree_item_from_node(GtkTreeIter *iter, xmlNodePtr node) {
	gchar *title;
	gboolean recursive=FALSE;
	GdkPixbuf* pixmap=NULL;
	DEBUG_MSG("snippets_fill_tree_item_from_node, got node with type %s\n",node->name);
	title = (gchar *)xmlGetProp(node, (const xmlChar *)"title");
	DEBUG_MSG("snippets_fill_tree_item_from_node, node has title %s\n",title);
	if ((xmlStrEqual(node->name, (const xmlChar *)"branch"))) {
		pixmap = NULL;
		recursive = TRUE;
	} else /*if ((xmlStrEqual(cur->name, (const xmlChar *)"leaf")))*/ {
		xmlChar *type;
		type = xmlGetProp(node, (const xmlChar *)"type");
		if (xmlStrEqual(type, (const xmlChar *)"insert")) {
			pixmap = gdk_pixbuf_new_from_inline(-1, pixmap_insert, FALSE, NULL);
		} else if (xmlStrEqual(type, (const xmlChar *)"snr")) {
			pixmap = gdk_pixbuf_new_from_inline(-1, pixmap_snr, FALSE, NULL);
		}
		xmlFree(type);
	}
	gtk_tree_store_set(snippets_v.store, iter, PIXMAP_COLUMN, pixmap, TITLE_COLUMN, title,NODE_COLUMN, node,-1);
	if (pixmap) {
		g_object_unref(pixmap);
	}
	xmlFree(title);	
	if (recursive) {
		walk_tree(node, iter);
	}
	
}
Пример #13
0
int next_file(const char *arg, seq_t seq)
{
	char *line;
	int errors = 0;

	if (strcmp(arg, "-") == 0) {
		while ((line = next_line(stdin)))
			errors = walk_tree(line, walk_flags, 0, do_set, seq);
		if (!feof(stdin)) {
			fprintf(stderr, _("%s: Standard input: %s\n"),
				progname, strerror(errno));
			errors = 1;
		}
	} else {
		errors = walk_tree(arg, walk_flags, 0, do_set, seq);
	}
	return errors ? 1 : 0;
}
Пример #14
0
static int walk_tree(int path_len, watch_node* parent, bool recursive, array* mounts) {
  for (int j=0; j<array_size(mounts); j++) {
    char* mount = array_get(mounts, j);
    if (strncmp(path_buf, mount, strlen(mount)) == 0) {
      userlog(LOG_DEBUG, "watch path '%s' crossed mount point '%s' - skipping", path_buf, mount);
      return ERR_IGNORE;
    }
  }

  DIR* dir = NULL;
  if (recursive) {
    if ((dir = opendir(path_buf)) == NULL) {
      if (errno == EACCES || errno == ENOENT || errno == ENOTDIR) {
        userlog(LOG_DEBUG, "opendir(%s): %d", path_buf, errno);
        return ERR_IGNORE;
      }
      else {
        userlog(LOG_ERR, "opendir(%s): %s", path_buf, strerror(errno));
        return ERR_CONTINUE;
      }
    }
  }

  int id = add_watch(path_len, parent);

  if (dir == NULL) {
    return id;
  }
  else if (id < 0) {
    closedir(dir);
    return id;
  }

  path_buf[path_len] = '/';

  struct dirent* entry;
  while ((entry = readdir(dir)) != NULL) {
    if (entry->d_type != DT_DIR ||
        strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
      continue;
    }

    int name_len = strlen(entry->d_name);
    memcpy(path_buf + path_len + 1, entry->d_name, name_len + 1);

    int subdir_id = walk_tree(path_len + 1 + name_len, table_get(watches, id), recursive, mounts);
    if (subdir_id < 0 && subdir_id != ERR_IGNORE) {
      rm_watch(id, true);
      id = subdir_id;
      break;
    }
  }

  closedir(dir);
  return id;
}
Пример #15
0
int walk_tree(pTree *tree, struct pqNode **ps, int index)
{
    if (tree == NULL) return index;

    fprintf(err, "( ");
    index = walk_tree(tree->pLeft, ps, index);

    struct pqNode *l;
    for (l = tree->cell.list; l != NULL; l = l->neighbor)
    {
        //ps[index++] = l;
        fprintf(err, "%.2f ", l->r[0]);
    }

    index = walk_tree(tree->pRight, ps, index);
    fprintf(err, ") ");

    return index;
}
Пример #16
0
int walk_tree(pTree *tree, struct pqNode **ps, int index)
{
    if (tree == NULL) return index;

    fprintf(err, "( ");
    index = walk_tree(tree->pLeft, ps, index);

    if (tree->pLeft == NULL && tree->pRight == NULL)
    {
        int i;
        for (i=tree->iLower; i <= tree->iUpper; i++)
            fprintf(err, "%.2f ", ps[i]->r[0]);
    }

    index = walk_tree(tree->pRight, ps, index);

    fprintf(err, ") \n");

    return index;
}
Пример #17
0
static void 
analyze_variable (struct cgraph_varpool_node *vnode)
{
  tree global = vnode->decl;
  if (TREE_CODE (global) == VAR_DECL)
    {
      if (DECL_INITIAL (global)) 
        walk_tree (&DECL_INITIAL (global), scan_for_static_refs, 
                   NULL, visited_nodes);
    } 
  else gcc_unreachable ();
}
Пример #18
0
void walk_tree(GMenuTreeDirectory *root)
{
  GSList *list = gmenu_tree_directory_get_contents(root);

  while (list)
  {
    const char *category;
    const char *application;
    const char *exec;

    switch (gmenu_tree_item_get_type (list->data))
    {
      case GMENU_TREE_ITEM_DIRECTORY:
        category = gmenu_tree_directory_get_name (list->data);
        if (category)
        {
          printf("<menu name=\"%s\">\n", category);
          free((void *)category);
        }
        
        GMenuTreeDirectory *dir = (GMenuTreeDirectory*)list->data;
        walk_tree(dir);
        printf("</menu>\n");
        break;
      case GMENU_TREE_ITEM_ENTRY:
        if (!gmenu_tree_entry_get_is_excluded(list->data) &&
            !gmenu_tree_entry_get_is_nodisplay(list->data))
        {
          application = gmenu_tree_entry_get_name(list->data);
          if (application)
          {
            exec = filter(gmenu_tree_entry_get_exec(list->data));
            if (exec)
            {
              if (gmenu_tree_entry_get_launch_in_terminal(list->data))
              {
                printf("<command name=\"%s\" execute=\"xterm -title '%s' -e '%s' &amp;\" />\n", application, application, exec);
              }
              else
              {
                printf("<command name=\"%s\" execute=\"menuorg-execute-wrapper %s '%s'\" />\n", application, application, exec);
              }
              free((void *)application);
            }
          }
        }
        break;
      default:
        break;
    }
    list = g_slist_next(list);
  }
}
Пример #19
0
void
record_references_in_initializer (tree decl, bool only_vars)
{
  varpool_node *node = varpool_node::get_create (decl);
  hash_set<tree> visited_nodes;
  record_reference_ctx ctx = {false, NULL};

  ctx.varpool_node = node;
  ctx.only_vars = only_vars;
  walk_tree (&DECL_INITIAL (decl), record_reference,
             &ctx, &visited_nodes);
}
Пример #20
0
static int walk_tree(const char* path, watch_node* parent, array* ignores) {
  if (is_ignored(path, ignores)) {
    return ERR_IGNORE;
  }

  DIR* dir = opendir(path);
  if (dir == NULL) {
    if (errno == EACCES) {
      return ERR_IGNORE;
    }
    else if (errno == ENOTDIR) {  // flat root
      return add_watch(path, parent);
    }
    userlog(LOG_ERR, "opendir(%s): %s", path, strerror(errno));
    return ERR_CONTINUE;
  }

  int id = add_watch(path, parent);
  if (id < 0) {
    closedir(dir);
    return id;
  }

  struct dirent* entry;
  char subdir[PATH_MAX];
  strcpy(subdir, path);
  if (subdir[strlen(subdir) - 1] != '/') {
    strcat(subdir, "/");
  }
  char* p = subdir + strlen(subdir);

  while ((entry = readdir(dir)) != NULL) {
    if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
      continue;
    }

    strcpy(p, entry->d_name);
    if (!is_directory(entry, subdir)) {
      continue;
    }

    int subdir_id = walk_tree(subdir, table_get(watches, id), ignores);
    if (subdir_id < 0 && subdir_id != ERR_IGNORE) {
      rm_watch(id, true);
      id = subdir_id;
      break;
    }
  }

  closedir(dir);
  return id;
}
Пример #21
0
static Namfun_t *clone_tree(Namval_t *np, Namval_t *mp, int flags, Namfun_t *fp){
	Namfun_t	*dp;
	if ((flags&NV_MOVE) && nv_type(np))
		return(fp);
	dp = nv_clone_disc(fp,flags);
	if((flags&NV_COMVAR) && !(flags&NV_RAW))
	{
		walk_tree(np,mp,flags);
		if((flags&NV_MOVE) && !(fp->nofree&1))
			free((void*)fp);
	}
	return(dp);
}
Пример #22
0
Файл: cilk.c Проект: Soufien/gcc
static bool
recognize_spawn (tree exp, tree *exp0)
{
  bool spawn_found = false;
  if (TREE_CODE (exp) == CILK_SPAWN_STMT)
    {
      /* Remove the CALL_EXPR from CILK_SPAWN_STMT wrapper.  */
      exp = CILK_SPAWN_FN (exp);
      walk_tree (exp0, unwrap_cilk_spawn_stmt, NULL, NULL);
      spawn_found = true;
    }
  return spawn_found;
}
Пример #23
0
void
record_references_in_initializer (tree decl, bool only_vars)
{
  struct pointer_set_t *visited_nodes = pointer_set_create ();
  varpool_node *node = varpool_node_for_decl (decl);
  struct record_reference_ctx ctx = {false, NULL};

  ctx.varpool_node = node;
  ctx.only_vars = only_vars;
  walk_tree (&DECL_INITIAL (decl), record_reference,
             &ctx, visited_nodes);
  pointer_set_destroy (visited_nodes);
}
Пример #24
0
void reload_tree_from_doc(void) {
	if (snippets_v.doc) {
		xmlNodePtr cur = xmlDocGetRootElement(snippets_v.doc);
		if (cur) {
			if (xmlStrEqual(cur->name, (const xmlChar *) "snippets")) {
				/* the document is correct, first empty the treestore */
				gtk_tree_store_clear(snippets_v.store);
				
				/* now reload the tree */
				walk_tree(cur, NULL);
			}
		}
	}
}
Пример #25
0
void main(int argc, char *argv[])
{
  GMenuTree *tree = NULL;
  GMenuTreeDirectory *directory = NULL;
  GMenuTreeEntry *entry = NULL;
  const char *name = NULL;

  gtk_set_locale ();

  tree = gmenu_tree_lookup ("lxde-applications.menu", GMENU_TREE_FLAGS_NONE);
  directory = gmenu_tree_get_root_directory(tree);

  walk_tree(directory);
}
Пример #26
0
void
cp_genericize (tree fndecl)
{
  tree t;
  struct pointer_set_t *p_set;

  /* Fix up the types of parms passed by invisible reference.  */
  for (t = DECL_ARGUMENTS (fndecl); t; t = TREE_CHAIN (t))
    if (TREE_ADDRESSABLE (TREE_TYPE (t)))
      {
	/* If a function's arguments are copied to create a thunk,
	   then DECL_BY_REFERENCE will be set -- but the type of the
	   argument will be a pointer type, so we will never get
	   here.  */
	gcc_assert (!DECL_BY_REFERENCE (t));
	gcc_assert (DECL_ARG_TYPE (t) != TREE_TYPE (t));
	TREE_TYPE (t) = DECL_ARG_TYPE (t);
	DECL_BY_REFERENCE (t) = 1;
	TREE_ADDRESSABLE (t) = 0;
	relayout_decl (t);
      }

  /* Do the same for the return value.  */
  if (TREE_ADDRESSABLE (TREE_TYPE (DECL_RESULT (fndecl))))
    {
      t = DECL_RESULT (fndecl);
      TREE_TYPE (t) = build_reference_type (TREE_TYPE (t));
      DECL_BY_REFERENCE (t) = 1;
      TREE_ADDRESSABLE (t) = 0;
      relayout_decl (t);
    }

  /* If we're a clone, the body is already GIMPLE.  */
  if (DECL_CLONED_FUNCTION_P (fndecl))
    return;

  /* We do want to see every occurrence of the parms, so we can't just use
     walk_tree's hash functionality.  */
  p_set = pointer_set_create ();
  walk_tree (&DECL_SAVED_TREE (fndecl), cp_genericize_r, p_set, NULL);
  pointer_set_destroy (p_set);

  /* Do everything else.  */
  c_genericize (fndecl);

  gcc_assert (bc_label[bc_break] == NULL);
  gcc_assert (bc_label[bc_continue] == NULL);
}
Пример #27
0
static bool
recognize_spawn (tree exp, tree *exp0)
{
  bool spawn_found = false;
  if (TREE_CODE (exp) == CILK_SPAWN_STMT)
    {
      /* Remove the CALL_EXPR from CILK_SPAWN_STMT wrapper.  */
      exp = CILK_SPAWN_FN (exp);
      walk_tree (exp0, unwrap_cilk_spawn_stmt, NULL, NULL);
      spawn_found = true;
    }
  /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR.  */
  else if (contains_cilk_spawn_stmt (exp))
    error_at (EXPR_LOCATION (exp), "invalid use of %<_Cilk_spawn%>");
  return spawn_found;
}
Пример #28
0
/*
 * Generates the HBA logical ap_id from physical ap_id.
 */
scfga_ret_t
make_hba_logid(const char *hba_phys, char **hba_logpp, int *l_errnop)
{
	walkarg_t u;
	pathm_t pmt = {NULL};
	scfga_ret_t ret;


	if (*hba_logpp != NULL) {
		return (SCFGA_ERR);
	}

	/* A devlink for the HBA may or may not exist */
	if (get_hba_devlink(hba_phys, hba_logpp, l_errnop) == SCFGA_OK) {
		assert(*hba_logpp != NULL);
		return (SCFGA_OK);
	}

	/*
	 * No devlink based logical ap_id.
	 * Try driver name and instance number.
	 */
	u.minor_args.nodetype = DDI_NT_SCSI_ATTACHMENT_POINT;
	u.minor_args.fcn = drv_to_hba_logid;

	pmt.phys = (char *)hba_phys;
	pmt.ret = SCFGA_APID_NOEXIST;

	errno = 0;
	ret = walk_tree(pmt.phys, &pmt, DINFOMINOR | DINFOPROP, &u,
	    SCFGA_WALK_MINOR, &pmt.l_errno);
	if (ret == SCFGA_OK && (ret = pmt.ret) == SCFGA_OK) {
		assert(pmt.log != NULL);
		*hba_logpp = pmt.log;
		return (SCFGA_OK);
	}

	/* failed to create logical ap_id */
	if (pmt.log != NULL) {
		S_FREE(pmt.log);
	}


	*l_errnop = pmt.l_errno;
	return (ret);
}
Пример #29
0
static tree
ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
{
  hash_set<tree> *pset = (hash_set<tree> *) data;

  if (TREE_CODE (*tp) == BIND_EXPR)
    {
      /* Since walk_tree doesn't call the callback function on the decls
	 in BIND_EXPR_VARS, we have to walk them manually, so we can avoid
	 instrumenting DECL_INITIAL of TREE_STATIC vars.  */
      *walk_subtrees = 0;
      for (tree decl = BIND_EXPR_VARS (*tp); decl; decl = DECL_CHAIN (decl))
	{
	  if (TREE_STATIC (decl))
	    continue;
	  walk_tree (&DECL_INITIAL (decl), ubsan_walk_array_refs_r, pset,
		     pset);
	  walk_tree (&DECL_SIZE (decl), ubsan_walk_array_refs_r, pset, pset);
	  walk_tree (&DECL_SIZE_UNIT (decl), ubsan_walk_array_refs_r, pset,
		     pset);
	}
      walk_tree (&BIND_EXPR_BODY (*tp), ubsan_walk_array_refs_r, pset, pset);
    }
  else if (TREE_CODE (*tp) == ADDR_EXPR
	   && TREE_CODE (TREE_OPERAND (*tp, 0)) == ARRAY_REF)
    {
      ubsan_maybe_instrument_array_ref (&TREE_OPERAND (*tp, 0), true);
      /* Make sure ubsan_maybe_instrument_array_ref is not called again
	 on the ARRAY_REF, the above call might not instrument anything
	 as the index might be constant or masked, so ensure it is not
	 walked again and walk its subtrees manually.  */
      tree aref = TREE_OPERAND (*tp, 0);
      pset->add (aref);
      *walk_subtrees = 0;
      walk_tree (&TREE_OPERAND (aref, 0), ubsan_walk_array_refs_r, pset, pset);
      walk_tree (&TREE_OPERAND (aref, 1), ubsan_walk_array_refs_r, pset, pset);
      walk_tree (&TREE_OPERAND (aref, 2), ubsan_walk_array_refs_r, pset, pset);
      walk_tree (&TREE_OPERAND (aref, 3), ubsan_walk_array_refs_r, pset, pset);
    }
  else if (TREE_CODE (*tp) == ARRAY_REF)
    ubsan_maybe_instrument_array_ref (tp, false);
  return NULL_TREE;
}
Пример #30
0
int main(int argc, char *argv[])
{
    xmlDoc *doc = NULL;
    xmlNode *root_element = NULL;

    /*
     * this initialize the library and check potential ABI mismatches
     * between the version it was compiled for and the actual shared
     * library used.
     */
    LIBXML_TEST_VERSION

    /*parse the file and get the DOM */
    doc = xmlReadFile("test.html", NULL, 0);

    if (doc == NULL) {
        printf("error: could not parse file %s\n", argv[1]);
    }

    /*Get the root element node */
    root_element = xmlDocGetRootElement(doc);

    OMS_PAGE *p = oms_new_page();

	oms_add_string(p, "1/http://ya.ru/");
    oms_add_authcode(p, "c37c206d2c235978d086b64c39a2fc17df68dbdd5dc04dd8b199177f95be6181");
    oms_add_authprefix(p, "t19-12");
    oms_add_style(p, 0x02000002);
	
    walk_tree(root_element, p);
	oms_finalize_page(p);
    oms_free_page(p);

    /*free the document */
    xmlFreeDoc(doc);

    /*
     *Free the global variables that may
     *have been allocated by the parser.
     */
    xmlCleanupParser();

    return 0;
}