diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-24 16:50:14 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-24 16:50:14 +0000 |
commit | d3cf195ab46d7effe806990aa6b7a409bf8e46df (patch) | |
tree | eb33d22a749417ad62a3fc87c2dc8cfb3452632a /libcpp/include/line-map.h | |
parent | 825a44b40ce6cfa76470e53d0746b1e64b99ee5b (diff) | |
parent | 2e77960b14527ff216fa188479de9142fbb9d34c (diff) | |
download | gcc-d3cf195ab46d7effe806990aa6b7a409bf8e46df.zip gcc-d3cf195ab46d7effe806990aa6b7a409bf8e46df.tar.gz gcc-d3cf195ab46d7effe806990aa6b7a409bf8e46df.tar.bz2 |
Merge #1498
1498: Merge from GCC upstream r=philberty a=philberty
Lets see if it builds.
Co-authored-by: GCC Administrator <gccadmin@gcc.gnu.org>
Co-authored-by: Dimitrije Milošević <dimitrije.milosevic@syrmia.com>
Co-authored-by: Aldy Hernandez <aldyh@redhat.com>
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Roger Sayle <roger@nextmovesoftware.com>
Co-authored-by: Sam Feifer <sfeifer@redhat.com>
Co-authored-by: Andrew Stubbs <ams@codesourcery.com>
Co-authored-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
Co-authored-by: David Malcolm <dmalcolm@redhat.com>
Co-authored-by: Richard Biener <rguenther@suse.de>
Co-authored-by: Immad Mir <mirimmad@outlook.com>
Diffstat (limited to 'libcpp/include/line-map.h')
-rw-r--r-- | libcpp/include/line-map.h | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 3f39eb4..9bdd5b9 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -22,6 +22,8 @@ along with this program; see the file COPYING3. If not see #ifndef LIBCPP_LINE_MAP_H #define LIBCPP_LINE_MAP_H +#include <utility> + #ifndef GTY #define GTY(x) /* nothing */ #endif @@ -792,6 +794,9 @@ public: /* If true, prints an include trace a la -H. */ bool trace_includes; + /* True if we've seen a #line or # 44 "file" directive. */ + bool seen_line_directive; + /* Highest location_t "given out". */ location_t highest_location; @@ -815,9 +820,6 @@ public: built-in tokens. */ location_t builtin_location; - /* True if we've seen a #line or # 44 "file" directive. */ - bool seen_line_directive; - /* The default value of range_bits in ordinary line maps. */ unsigned int default_range_bits; @@ -1816,16 +1818,16 @@ protected: int m_column_override; bool m_have_expanded_location; + bool m_seen_impossible_fixit; + bool m_fixits_cannot_be_auto_applied; + bool m_escape_on_output; + expanded_location m_expanded_location; static const int MAX_STATIC_FIXIT_HINTS = 2; semi_embedded_vec <fixit_hint *, MAX_STATIC_FIXIT_HINTS> m_fixit_hints; - bool m_seen_impossible_fixit; - bool m_fixits_cannot_be_auto_applied; - const diagnostic_path *m_path; - bool m_escape_on_output; }; /* A struct for the result of range_label::get_text: a NUL-terminated buffer @@ -1836,15 +1838,37 @@ class label_text { public: label_text () - : m_buffer (NULL), m_caller_owned (false) + : m_buffer (NULL), m_owned (false) {} - void maybe_free () + ~label_text () { - if (m_caller_owned) + if (m_owned) free (m_buffer); } + /* Move ctor. */ + label_text (label_text &&other) + : m_buffer (other.m_buffer), m_owned (other.m_owned) + { + other.release (); + } + + /* Move assignment. */ + label_text & operator= (label_text &&other) + { + if (m_owned) + free (m_buffer); + m_buffer = other.m_buffer; + m_owned = other.m_owned; + other.release (); + return *this; + } + + /* Delete the copy ctor and copy-assignment operator. */ + label_text (const label_text &) = delete; + label_text & operator= (const label_text &) = delete; + /* Create a label_text instance that borrows BUFFER from a longer-lived owner. */ static label_text borrow (const char *buffer) @@ -1858,21 +1882,28 @@ public: return label_text (buffer, true); } - /* Take ownership of the buffer, copying if necessary. */ - char *take_or_copy () + void release () { - if (m_caller_owned) - return m_buffer; - else - return xstrdup (m_buffer); + m_buffer = NULL; + m_owned = false; } - char *m_buffer; - bool m_caller_owned; + const char *get () const + { + return m_buffer; + } + + bool is_owner () const + { + return m_owned; + } private: + char *m_buffer; + bool m_owned; + label_text (char *buffer, bool owned) - : m_buffer (buffer), m_caller_owned (owned) + : m_buffer (buffer), m_owned (owned) {} }; |