aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/sm-file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/analyzer/sm-file.cc')
-rw-r--r--gcc/analyzer/sm-file.cc95
1 files changed, 43 insertions, 52 deletions
diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc
index 1e41dc9..d7dbe2f 100644
--- a/gcc/analyzer/sm-file.cc
+++ b/gcc/analyzer/sm-file.cc
@@ -18,26 +18,16 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#include "config.h"
-#define INCLUDE_VECTOR
-#include "system.h"
-#include "coretypes.h"
-#include "make-unique.h"
-#include "tree.h"
-#include "function.h"
-#include "basic-block.h"
-#include "gimple.h"
-#include "options.h"
-#include "diagnostic-core.h"
-#include "diagnostic-path.h"
-#include "analyzer/analyzer.h"
+#include "analyzer/common.h"
+
#include "diagnostic-event-id.h"
+#include "selftest.h"
+
#include "analyzer/analyzer-logging.h"
#include "analyzer/sm.h"
#include "analyzer/pending-diagnostic.h"
#include "analyzer/function-set.h"
#include "analyzer/analyzer-selftests.h"
-#include "selftest.h"
#include "analyzer/call-string.h"
#include "analyzer/program-point.h"
#include "analyzer/store.h"
@@ -403,9 +393,9 @@ fileptr_state_machine::on_stmt (sm_context &sm_ctxt,
const gimple *stmt) const
{
if (const gcall *call = dyn_cast <const gcall *> (stmt))
- if (tree callee_fndecl = sm_ctxt.get_fndecl_for_call (call))
+ if (tree callee_fndecl = sm_ctxt.get_fndecl_for_call (*call))
{
- if (is_named_call_p (callee_fndecl, "fopen", call, 2))
+ if (is_named_call_p (callee_fndecl, "fopen", *call, 2))
{
tree lhs = gimple_call_lhs (call);
if (lhs)
@@ -417,7 +407,7 @@ fileptr_state_machine::on_stmt (sm_context &sm_ctxt,
return true;
}
- if (is_named_call_p (callee_fndecl, "fclose", call, 1))
+ if (is_named_call_p (callee_fndecl, "fclose", *call, 1))
{
tree arg = gimple_call_arg (call, 0);
@@ -433,7 +423,8 @@ fileptr_state_machine::on_stmt (sm_context &sm_ctxt,
{
tree diag_arg = sm_ctxt.get_diagnostic_tree (arg);
sm_ctxt.warn (node, stmt, arg,
- make_unique<double_fclose> (*this, diag_arg));
+ std::make_unique<double_fclose> (*this,
+ diag_arg));
sm_ctxt.set_next_state (stmt, arg, m_stop);
}
return true;
@@ -503,17 +494,17 @@ fileptr_state_machine::can_purge_p (state_t s) const
std::unique_ptr<pending_diagnostic>
fileptr_state_machine::on_leak (tree var) const
{
- return make_unique<file_leak> (*this, var);
+ return std::make_unique<file_leak> (*this, var);
}
} // anonymous namespace
/* Internal interface to this file. */
-state_machine *
+std::unique_ptr<state_machine>
make_fileptr_state_machine (logger *logger)
{
- return new fileptr_state_machine (logger);
+ return std::make_unique<fileptr_state_machine> (logger);
}
/* Handler for various stdio-related builtins that merely have external
@@ -655,40 +646,40 @@ public:
void
register_known_file_functions (known_function_manager &kfm)
{
- kfm.add (BUILT_IN_FPRINTF, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FPRINTF_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FPUTC, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FPUTC_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FPUTS, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FPUTS_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FWRITE, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_FWRITE_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PRINTF, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PRINTF_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PUTC, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PUTCHAR, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PUTCHAR_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PUTC_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PUTS, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_PUTS_UNLOCKED, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_VFPRINTF, make_unique<kf_stdio_output_fn> ());
- kfm.add (BUILT_IN_VPRINTF, make_unique<kf_stdio_output_fn> ());
-
- kfm.add ("ferror", make_unique<kf_ferror> ());
- kfm.add ("fgets", make_unique<kf_fgets> ());
- kfm.add ("fgets_unlocked", make_unique<kf_fgets> ()); // non-standard
- kfm.add ("fileno", make_unique<kf_fileno> ());
- kfm.add ("fread", make_unique<kf_fread> ());
- kfm.add ("getc", make_unique<kf_getc> ());
- kfm.add ("getchar", make_unique<kf_getchar> ());
+ kfm.add (BUILT_IN_FPRINTF, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FPRINTF_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FPUTC, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FPUTC_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FPUTS, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FPUTS_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FWRITE, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_FWRITE_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PRINTF, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PRINTF_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PUTC, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PUTCHAR, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PUTCHAR_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PUTC_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PUTS, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_PUTS_UNLOCKED, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_VFPRINTF, std::make_unique<kf_stdio_output_fn> ());
+ kfm.add (BUILT_IN_VPRINTF, std::make_unique<kf_stdio_output_fn> ());
+
+ kfm.add ("ferror", std::make_unique<kf_ferror> ());
+ kfm.add ("fgets", std::make_unique<kf_fgets> ());
+ kfm.add ("fgets_unlocked", std::make_unique<kf_fgets> ()); // non-standard
+ kfm.add ("fileno", std::make_unique<kf_fileno> ());
+ kfm.add ("fread", std::make_unique<kf_fread> ());
+ kfm.add ("getc", std::make_unique<kf_getc> ());
+ kfm.add ("getchar", std::make_unique<kf_getchar> ());
/* Some C++ implementations use the std:: copies of these functions
from <cstdio> for <stdio.h>, so we must match against these too. */
- kfm.add_std_ns ("ferror", make_unique<kf_ferror> ());
- kfm.add_std_ns ("fgets", make_unique<kf_fgets> ());
- kfm.add_std_ns ("fread", make_unique<kf_fread> ());
- kfm.add_std_ns ("getc", make_unique<kf_getc> ());
- kfm.add_std_ns ("getchar", make_unique<kf_getchar> ());
+ kfm.add_std_ns ("ferror", std::make_unique<kf_ferror> ());
+ kfm.add_std_ns ("fgets", std::make_unique<kf_fgets> ());
+ kfm.add_std_ns ("fread", std::make_unique<kf_fread> ());
+ kfm.add_std_ns ("getc", std::make_unique<kf_getc> ());
+ kfm.add_std_ns ("getchar", std::make_unique<kf_getchar> ());
}
#if CHECKING_P