+2014-11-18 Marek Polacek <polacek@redhat.com>
+
+ PR sanitizer/63866
+ * asan.c (asan_global_struct): Create a TYPE_DECL for "__asan_global",
+ put it into TYPE_NAME and TYPE_STUB_DECL.
+ * ubsan.c (ubsan_type_descriptor_type): New variable.
+ Function renamed to ...
+ (ubsan_get_type_descriptor_type): ... this. Cache
+ return value in ubsan_type_descriptor_type variable.
+ Create a TYPE_DECL for "__ubsan_type_descriptor", put it into
+ TYPE_NAME and TYPE_STUB_DECL.
+ (ubsan_get_source_location_type): Create a TYPE_DECL for
+ "__ubsan_source_location", put it into TYPE_NAME and TYPE_STUB_DECL.
+ (ubsan_type_descriptor, ubsan_create_data): Call
+ ubsan_get_type_descriptor_type instead of ubsan_type_descriptor_type.
+ Create a TYPE_DECL for name, put it into TYPE_NAME and TYPE_STUB_DECL.
+
2014-11-18 Felix Yang <felix.yang@huawei.com>
* config/aarch64/aarch64.c (doloop_end): New pattern.
}
}
+/* Cached ubsan_get_type_descriptor_type () return value. */
+static GTY(()) tree ubsan_type_descriptor_type;
+
/* Build
struct __ubsan_type_descriptor
{
type. */
static tree
-ubsan_type_descriptor_type (void)
+ubsan_get_type_descriptor_type (void)
{
static const char *field_names[3]
= { "__typekind", "__typeinfo", "__typename" };
tree fields[3], ret;
+
+ if (ubsan_type_descriptor_type)
+ return ubsan_type_descriptor_type;
+
tree itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
tree flex_arr_type = build_array_type (char_type_node, itype);
if (i)
DECL_CHAIN (fields[i - 1]) = fields[i];
}
+ tree type_decl = build_decl (input_location, TYPE_DECL,
+ get_identifier ("__ubsan_type_descriptor"),
+ ret);
+ DECL_IGNORED_P (type_decl) = 1;
+ DECL_ARTIFICIAL (type_decl) = 1;
TYPE_FIELDS (ret) = fields[0];
- TYPE_NAME (ret) = get_identifier ("__ubsan_type_descriptor");
+ TYPE_NAME (ret) = type_decl;
+ TYPE_STUB_DECL (ret) = type_decl;
layout_type (ret);
+ ubsan_type_descriptor_type = ret;
return ret;
}
if (i)
DECL_CHAIN (fields[i - 1]) = fields[i];
}
+ tree type_decl = build_decl (input_location, TYPE_DECL,
+ get_identifier ("__ubsan_source_location"),
+ ret);
+ DECL_IGNORED_P (type_decl) = 1;
+ DECL_ARTIFICIAL (type_decl) = 1;
TYPE_FIELDS (ret) = fields[0];
- TYPE_NAME (ret) = get_identifier ("__ubsan_source_location");
+ TYPE_NAME (ret) = type_decl;
+ TYPE_STUB_DECL (ret) = type_decl;
layout_type (ret);
ubsan_source_location_type = ret;
return ret;
if (decl != NULL_TREE && varpool_node::get (decl))
return build_fold_addr_expr (decl);
- tree dtype = ubsan_type_descriptor_type ();
+ tree dtype = ubsan_get_type_descriptor_type ();
tree type2 = type;
const char *tname = NULL;
char *pretty_name;
int j;
/* Firstly, create a pointer to type descriptor type. */
- tree td_type = ubsan_type_descriptor_type ();
- TYPE_READONLY (td_type) = 1;
+ tree td_type = ubsan_get_type_descriptor_type ();
td_type = build_pointer_type (td_type);
/* Create the structure type. */
}
va_end (args);
+ tree type_decl = build_decl (input_location, TYPE_DECL,
+ get_identifier (name), ret);
+ DECL_IGNORED_P (type_decl) = 1;
+ DECL_ARTIFICIAL (type_decl) = 1;
TYPE_FIELDS (ret) = fields[0];
- TYPE_NAME (ret) = get_identifier (name);
+ TYPE_NAME (ret) = type_decl;
+ TYPE_STUB_DECL (ret) = type_decl;
layout_type (ret);
/* Now, fill in the type. */