hppa: Fix pr110279-1.c on hppa
[official-gcc.git] / gcc / analyzer / known-function-manager.h
blob04f49ceb768fc1fe8ca375bd0414a9b3894c16dd
1 /* Support for plugin-supplied behaviors of known functions.
2 Copyright (C) 2022-2023 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_ANALYZER_KNOWN_FUNCTION_MANAGER_H
22 #define GCC_ANALYZER_KNOWN_FUNCTION_MANAGER_H
24 #include "analyzer/analyzer-logging.h"
26 namespace ana {
28 /* Instances of known_function are registered with the known_function_manager
29 when the analyzer starts.
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").
37 The known_function subclasses themselves have responsibility for
38 determining the outcome(s) of the call. */
40 class known_function_manager : public log_user
42 public:
43 known_function_manager (logger *logger);
44 ~known_function_manager ();
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);
50 const known_function *get_match (tree fndecl, const call_details &cd) const;
51 const known_function *get_internal_fn (enum internal_fn) const;
53 private:
54 DISABLE_COPY_AND_ASSIGN (known_function_manager);
56 const known_function *get_normal_builtin (enum built_in_function name) const;
57 const known_function *
58 get_normal_builtin (const builtin_known_function *builtin_kf) const;
59 const known_function *get_by_identifier (tree identifier) const;
61 /* Map from identifier to known_function instance.
62 Has ownership of the latter. */
63 hash_map<tree, known_function *> m_map_id_to_kf;
65 /* Array of known builtins. */
66 known_function *m_combined_fns_arr[CFN_LAST];
69 extern std::unique_ptr<known_function> make_kf_strlen ();
71 } // namespace ana
73 #endif /* GCC_ANALYZER_KNOWN_FUNCTION_MANAGER_H */