GCC Middle and Back End API Reference
known-function-manager.h
Go to the documentation of this file.
1/* Support for plugin-supplied behaviors of known functions.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_KNOWN_FUNCTION_MANAGER_H
22#define GCC_ANALYZER_KNOWN_FUNCTION_MANAGER_H
23
25
26namespace ana {
27
28/* Instances of known_function are registered with the known_function_manager
29 when the analyzer starts.
30
31 The known_function_manager has responsibility for determining which
32 known_function instance (if any) is relevant at a call site, by checking
33 name or id, and by calling known_function::matches_call_types_p to ensure
34 that the known_function's preconditions hold (typically assumptions about
35 types e.g. that "has 3 args, and that arg 0 is of pointer type").
36
37 The known_function subclasses themselves have responsibility for
38 determining the outcome(s) of the call. */
39
41{
42public:
45
46 void add (const char *name, std::unique_ptr<known_function> kf);
47 void add (enum built_in_function name, std::unique_ptr<known_function> kf);
48 void add (enum internal_fn ifn, std::unique_ptr<known_function> kf);
49
50 const known_function *get_match (tree fndecl, const call_details &cd) const;
52
53private:
55
57 const known_function *
60
61 /* Map from identifier to known_function instance.
62 Has ownership of the latter. */
64
65 /* Array of known builtins. */
67};
68
69extern std::unique_ptr<known_function> make_kf_strlen ();
70
71} // namespace ana
72
73#endif /* GCC_ANALYZER_KNOWN_FUNCTION_MANAGER_H */
Definition analyzer.h:298
Definition call-details.h:29
Definition known-function-manager.h:41
known_function_manager(logger *logger)
const known_function * get_normal_builtin(const builtin_known_function *builtin_kf) const
const known_function * get_by_identifier(tree identifier) const
void add(enum internal_fn ifn, std::unique_ptr< known_function > kf)
DISABLE_COPY_AND_ASSIGN(known_function_manager)
void add(enum built_in_function name, std::unique_ptr< known_function > kf)
const known_function * get_internal_fn(enum internal_fn) const
known_function * m_combined_fns_arr[CFN_LAST]
Definition known-function-manager.h:66
hash_map< tree, known_function * > m_map_id_to_kf
Definition known-function-manager.h:63
void add(const char *name, std::unique_ptr< known_function > kf)
const known_function * get_normal_builtin(enum built_in_function name) const
const known_function * get_match(tree fndecl, const call_details &cd) const
Definition analyzer.h:278
Definition analyzer-logging.h:147
Definition analyzer-logging.h:34
Definition hash-map.h:40
union tree_node * tree
Definition coretypes.h:97
built_in_function
Definition genmatch.cc:354
@ CFN_LAST
Definition genmatch.cc:374
internal_fn
Definition genmatch.cc:360
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Definition access-diagram.h:30
std::unique_ptr< known_function > make_kf_strlen()
static control_dependences * cd
Definition tree-ssa-dce.cc:102