]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/c-mudflap.c
c-common.c (verify_sequence_points): Export.
[thirdparty/gcc.git] / gcc / c-mudflap.c
CommitLineData
6de9cd9a
DN
1/* Mudflap: narrow-pointer bounds-checking by tree rewriting:
2 C front-end interface.
3
4 Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
5 Contributed by Frank Ch. Eigler <fche@redhat.com>
6 and Graydon Hoare <graydon@redhat.com>
7
8This file is part of GCC.
9
10GCC is free software; you can redistribute it and/or modify it under
11the terms of the GNU General Public License as published by the Free
12Software Foundation; either version 2, or (at your option) any later
13version.
14
15GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18for more details.
19
20You should have received a copy of the GNU General Public License
21along with GCC; see the file COPYING. If not, write to the Free
22Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2302111-1307, USA. */
24
25
26#include "config.h"
27#include "errors.h"
28#include "system.h"
29#include "coretypes.h"
30#include "tm.h"
31#include "tree.h"
32#include "tree-inline.h"
33#include "c-tree.h"
34#include "c-common.h"
35#include "diagnostic.h"
36#include "output.h"
37#include "varray.h"
38#include "tree-mudflap.h"
39#include "target.h"
40#include "flags.h"
41#include "rtl.h"
42#include "toplev.h"
43#include "function.h"
44
45
46
47/* ------------------------------------------------------------------------ */
48
49
50/* Initialize the global tree nodes that correspond to mf-runtime.h
51 declarations. */
52tree
53mflang_lookup_decl (const char* name)
54{
55 tree decl = lookup_name (get_identifier (name));
56 if (decl == NULL_TREE)
57 internal_error ("mudflap: cannot find declaration of `%s' from mf-runtime.h",
58 name);
59
60 return decl;
61}
62
63
64/* Emit a synthetic CTOR function for the current file. Populate it from
65 the enqueued __mf_register calls. Compile the function. */
66
67void
68mflang_flush_calls (tree enqueued_call_stmt_chain)
69{
325c3691 70 tree fnname, t1, t2, cs;
6de9cd9a
DN
71
72 /* Short-circuit! */
73 if (enqueued_call_stmt_chain == NULL_TREE)
74 return;
75
76 fnname = get_identifier ("__mudflap_static_initializer");
77 t1 = build_tree_list (NULL_TREE, void_type_node);
78 t2 = tree_cons (NULL, NULL, t1);
79 start_function (t1, build_nt (CALL_EXPR, fnname, t2, NULL), NULL);
80 store_parm_decls ();
81
82 DECL_STATIC_CONSTRUCTOR (current_function_decl) = 1;
83 TREE_PUBLIC (current_function_decl) = 0;
84 TREE_USED (current_function_decl) = 1;
85 mf_mark (current_function_decl);
86
325c3691 87 cs = c_begin_compound_stmt (true);
3a5b9284 88 c_finish_expr_stmt (enqueued_call_stmt_chain);
325c3691 89 add_stmt (c_end_compound_stmt (cs, true));
6de9cd9a 90
6de9cd9a
DN
91 finish_function ();
92}