[PATCH][v5] RISC-V: add option -m(no-)autovec-segment
[official-gcc.git] / gcc / unique-argv.h
blob41cabac6b76251fe3358f4992568e404c0905479
1 /* C++11 wrapper around libiberty's argv.c
2 Copyright (C) 2024 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 under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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_UNIQUE_ARGV_H
22 #define GCC_UNIQUE_ARGV_H
24 /* C++11 wrapper around libiberty's argv.c, with
25 ownership of the underlying array and strings. */
27 struct unique_argv
29 /* Take ownership of argv. */
30 unique_argv (char **argv)
31 : m_argv (argv)
35 ~unique_argv ()
37 freeargv (m_argv);
40 unique_argv (const unique_argv &other) = delete;
41 unique_argv &operator= (const unique_argv &other) = delete;
43 unique_argv (unique_argv &&other)
44 : m_argv (other.m_argv)
46 other.m_argv = nullptr;
49 unique_argv &operator= (unique_argv &&other)
51 freeargv (m_argv);
52 m_argv = other.m_argv;
53 other.m_argv = nullptr;
54 return *this;
57 char **release ()
59 char **result = m_argv;
60 m_argv = nullptr;
61 return result;
64 char **m_argv;
67 #endif /* ! GCC_UNIQUE_ARGV_H */