Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / edit-context.h
blob71735c8b9c6f87426c99d2b1255c15895a8cee3e
1 /* Determining the results of applying fix-it hints.
2 Copyright (C) 2016-2023 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_EDIT_CONTEXT_H
21 #define GCC_EDIT_CONTEXT_H
23 #include "typed-splay-tree.h"
25 class fixit_hint;
26 class edit_context;
27 class edited_file;
29 /* A set of changes to the source code.
31 The changes are "atomic" - if any changes can't be applied,
32 none of them can be (tracked by the m_valid flag).
33 Similarly, attempts to add the changes from a rich_location flagged
34 as containing invalid changes mean that the whole of the edit_context
35 is flagged as invalid.
37 A complication here is that fix-its are expressed relative to coordinates
38 in the files when they were parsed, before any changes have been made, and
39 so if there's more that one fix-it to be applied, we have to adjust
40 later fix-its to allow for the changes made by earlier ones. This
41 is done by the various "get_effective_column" methods. */
43 class edit_context
45 public:
46 edit_context (file_cache &);
48 bool valid_p () const { return m_valid; }
50 void add_fixits (rich_location *richloc);
52 char *get_content (const char *filename);
54 int get_effective_column (const char *filename, int line, int column);
56 char *generate_diff (bool show_filenames);
57 void print_diff (pretty_printer *pp, bool show_filenames);
59 file_cache &get_file_cache () const { return m_file_cache; }
61 private:
62 bool apply_fixit (const fixit_hint *hint);
63 edited_file *get_file (const char *filename);
64 edited_file &get_or_insert_file (const char *filename);
66 file_cache &m_file_cache;
67 bool m_valid;
68 typed_splay_tree<const char *, edited_file *> m_files;
71 #endif /* GCC_EDIT_CONTEXT_H. */