PIPS
utils.c
Go to the documentation of this file.
1 /*
2 
3  $Id: utils.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #ifdef HAVE_CONFIG_H
26  #include "pips_config.h"
27 #endif
28 
29 #include <stdio.h>
30 
31 #include "genC.h"
32 #include "linear.h"
33 
34 #include "misc.h"
35 #include "pipsdbm.h"
36 
37 #include "ri.h"
38 #include "effects.h"
39 
40 #include "ri-util.h"
41 #include "effects-util.h"
42 #include "text-util.h"
43 #include "prettyprint.h"
44 
45 /* keep a count of spear issues
46  */
47 static int
50 
51 /* internal alist-level processing for spear warning & error logging
52  */
53 static void spear_log_alist(
54  const char * pips_func,
55  const char * pips_file,
56  const int pips_line,
58  statement stat,
59  const string hint,
60  const string format,
61  va_list * args)
62 {
63  pips_assert("spear log", tag == spear_warning_log || tag == spear_error_log);
64 
65  if (tag == spear_warning_log)
67  else if (tag == spear_error_log)
69 
71 
72  pips_assert("some current module", module != NULL);
73 
74  // where is the user code?
75  int ln = -1;
76  string sstat = NULL;
77  string stat_file = NULL;
78 
79  if (stat && !statement_undefined_p(stat))
80  {
81  // what is a really the statement number?
82  ln = statement_number(stat);
83  sstat = proper_statement_to_string(stat);
84  stat_file = db_get_memory_resource(DBR_INPUT_FILE_NAME, module, true);
85  }
86 
89  // where in pips
90  (const string) pips_func, (const string) pips_file, pips_line,
91  // where in user code
92  module, stat_file, ln, -1,
93  sstat, hint, format, args);
94 
95  free(sstat);
96 }
97 
98 /* generate a spear user warning or spear user error.
99  * this function is not expected to be called directly, but it should be
100  * redirected here from a macro "spear_error(stat, hing, fmt, ...)"
101  */
103  // automatically added parameters, see spear_warning & spear_error macros
104  const char * pips_func,
105  const char * pips_file,
106  const int pips_line,
107  pips_log_t tag,
108  // parameters to provide
109  statement stat,
110  const string hint,
111  const string format,
112  ...)
113 {
114  va_list args;
115  va_start(args, format);
116  spear_log_alist(pips_func, pips_file, pips_line, tag,
117  stat, hint, format, &args);
118  va_end(args);
119 }
void pips_log_alist(const pips_log_t tag, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line, const string user_func, const string user_file, const int user_line, const int user_line2, const string stmt, const string suggestion, const string format, va_list *args)
log entry with unprocessed format/alist arguments
Definition: message.c:1200
string get_pips_current_pass_name(void)
Export this piece of information to customize warning functions in passes.
Definition: message.c:77
string get_pips_current_module(void)
Definition: message.c:82
void free(void *)
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
pips_log_t
Definition: misc-local.h:31
@ spear_warning_log
Definition: misc-local.h:35
@ spear_error_log
Definition: misc-local.h:36
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
static int spear_warning_count
keep a count of spear issues
Definition: utils.c:48
static void spear_log_alist(const char *pips_func, const char *pips_file, const int pips_line, pips_log_t tag, statement stat, const string hint, const string format, va_list *args)
internal alist-level processing for spear warning & error logging
Definition: utils.c:53
void spear_log_func(const char *pips_func, const char *pips_file, const int pips_line, pips_log_t tag, statement stat, const string hint, const string format,...)
generate a spear user warning or spear user error.
Definition: utils.c:102
static int spear_error_count
Definition: utils.c:49
int tag
TAG.
Definition: newgen_types.h:92
static char * module
Definition: pips.c:74
string proper_statement_to_string(statement)
#define statement_undefined_p(x)
Definition: ri.h:2420
#define statement_number(x)
Definition: ri.h:2452