aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/include/llvm/Option
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/llvm12/include/llvm/Option
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/Option')
-rw-r--r--contrib/libs/llvm12/include/llvm/Option/Arg.h162
-rw-r--r--contrib/libs/llvm12/include/llvm/Option/ArgList.h536
-rw-r--r--contrib/libs/llvm12/include/llvm/Option/OptParser.td234
-rw-r--r--contrib/libs/llvm12/include/llvm/Option/OptSpecifier.h49
-rw-r--r--contrib/libs/llvm12/include/llvm/Option/OptTable.h275
-rw-r--r--contrib/libs/llvm12/include/llvm/Option/Option.h247
6 files changed, 1503 insertions, 0 deletions
diff --git a/contrib/libs/llvm12/include/llvm/Option/Arg.h b/contrib/libs/llvm12/include/llvm/Option/Arg.h
new file mode 100644
index 0000000000..abeae3b1a4
--- /dev/null
+++ b/contrib/libs/llvm12/include/llvm/Option/Arg.h
@@ -0,0 +1,162 @@
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- Arg.h - Parsed Argument Classes --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Defines the llvm::Arg class for parsed arguments.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPTION_ARG_H
+#define LLVM_OPTION_ARG_H
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Option/Option.h"
+#include <string>
+
+namespace llvm {
+
+class raw_ostream;
+
+namespace opt {
+
+class ArgList;
+
+/// A concrete instance of a particular driver option.
+///
+/// The Arg class encodes just enough information to be able to
+/// derive the argument values efficiently.
+class Arg {
+private:
+ /// The option this argument is an instance of.
+ const Option Opt;
+
+ /// The argument this argument was derived from (during tool chain
+ /// argument translation), if any.
+ const Arg *BaseArg;
+
+ /// How this instance of the option was spelled.
+ StringRef Spelling;
+
+ /// The index at which this argument appears in the containing
+ /// ArgList.
+ unsigned Index;
+
+ /// Was this argument used to effect compilation?
+ ///
+ /// This is used for generating "argument unused" diagnostics.
+ mutable unsigned Claimed : 1;
+
+ /// Does this argument own its values?
+ mutable unsigned OwnsValues : 1;
+
+ /// The argument values, as C strings.
+ SmallVector<const char *, 2> Values;
+
+ /// If this arg was created through an alias, this is the original alias arg.
+ /// For example, *this might be "-finput-charset=utf-8" and Alias might
+ /// point to an arg representing "/source-charset:utf-8".
+ std::unique_ptr<Arg> Alias;
+
+public:
+ Arg(const Option Opt, StringRef Spelling, unsigned Index,
+ const Arg *BaseArg = nullptr);
+ Arg(const Option Opt, StringRef Spelling, unsigned Index,
+ const char *Value0, const Arg *BaseArg = nullptr);
+ Arg(const Option Opt, StringRef Spelling, unsigned Index,
+ const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
+ Arg(const Arg &) = delete;
+ Arg &operator=(const Arg &) = delete;
+ ~Arg();
+
+ const Option &getOption() const { return Opt; }
+
+ /// Returns the used prefix and name of the option:
+ /// For `--foo=bar`, returns `--foo=`.
+ /// This is often the wrong function to call:
+ /// * Use `getValue()` to get `bar`.
+ /// * Use `getAsString()` to get a string suitable for printing an Arg in
+ /// a diagnostic.
+ StringRef getSpelling() const { return Spelling; }
+
+ unsigned getIndex() const { return Index; }
+
+ /// Return the base argument which generated this arg.
+ ///
+ /// This is either the argument itself or the argument it was
+ /// derived from during tool chain specific argument translation.
+ const Arg &getBaseArg() const {
+ return BaseArg ? *BaseArg : *this;
+ }
+ void setBaseArg(const Arg *BaseArg) { this->BaseArg = BaseArg; }
+
+ /// Args are converted to their unaliased form. For args that originally
+ /// came from an alias, this returns the alias the arg was produced from.
+ const Arg* getAlias() const { return Alias.get(); }
+ void setAlias(std::unique_ptr<Arg> Alias) { this->Alias = std::move(Alias); }
+
+ bool getOwnsValues() const { return OwnsValues; }
+ void setOwnsValues(bool Value) const { OwnsValues = Value; }
+
+ bool isClaimed() const { return getBaseArg().Claimed; }
+
+ /// Set the Arg claimed bit.
+ void claim() const { getBaseArg().Claimed = true; }
+
+ unsigned getNumValues() const { return Values.size(); }
+
+ const char *getValue(unsigned N = 0) const {
+ return Values[N];
+ }
+
+ SmallVectorImpl<const char *> &getValues() { return Values; }
+ const SmallVectorImpl<const char *> &getValues() const { return Values; }
+
+ bool containsValue(StringRef Value) const {
+ for (unsigned i = 0, e = getNumValues(); i != e; ++i)
+ if (Values[i] == Value)
+ return true;
+ return false;
+ }
+
+ /// Append the argument onto the given array as strings.
+ void render(const ArgList &Args, ArgStringList &Output) const;
+
+ /// Append the argument, render as an input, onto the given
+ /// array as strings.
+ ///
+ /// The distinction is that some options only render their values
+ /// when rendered as a input (e.g., Xlinker).
+ void renderAsInput(const ArgList &Args, ArgStringList &Output) const;
+
+ void print(raw_ostream &O) const;
+ void dump() const;
+
+ /// Return a formatted version of the argument and its values, for
+ /// diagnostics. Since this is for diagnostics, if this Arg was produced
+ /// through an alias, this returns the string representation of the alias
+ /// that the user wrote.
+ std::string getAsString(const ArgList &Args) const;
+};
+
+} // end namespace opt
+
+} // end namespace llvm
+
+#endif // LLVM_OPTION_ARG_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Option/ArgList.h b/contrib/libs/llvm12/include/llvm/Option/ArgList.h
new file mode 100644
index 0000000000..b6efeb641d
--- /dev/null
+++ b/contrib/libs/llvm12/include/llvm/Option/ArgList.h
@@ -0,0 +1,536 @@
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- ArgList.h - Argument List Management ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPTION_ARGLIST_H
+#define LLVM_OPTION_ARGLIST_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/OptSpecifier.h"
+#include "llvm/Option/Option.h"
+#include <algorithm>
+#include <cstddef>
+#include <initializer_list>
+#include <iterator>
+#include <list>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+namespace llvm {
+
+class raw_ostream;
+
+namespace opt {
+
+/// arg_iterator - Iterates through arguments stored inside an ArgList.
+template<typename BaseIter, unsigned NumOptSpecifiers = 0>
+class arg_iterator {
+ /// The current argument and the end of the sequence we're iterating.
+ BaseIter Current, End;
+
+ /// Optional filters on the arguments which will be match. To avoid a
+ /// zero-sized array, we store one specifier even if we're asked for none.
+ OptSpecifier Ids[NumOptSpecifiers ? NumOptSpecifiers : 1];
+
+ void SkipToNextArg() {
+ for (; Current != End; ++Current) {
+ // Skip erased elements.
+ if (!*Current)
+ continue;
+
+ // Done if there are no filters.
+ if (!NumOptSpecifiers)
+ return;
+
+ // Otherwise require a match.
+ const Option &O = (*Current)->getOption();
+ for (auto Id : Ids) {
+ if (!Id.isValid())
+ break;
+ if (O.matches(Id))
+ return;
+ }
+ }
+ }
+
+ using Traits = std::iterator_traits<BaseIter>;
+
+public:
+ using value_type = typename Traits::value_type;
+ using reference = typename Traits::reference;
+ using pointer = typename Traits::pointer;
+ using iterator_category = std::forward_iterator_tag;
+ using difference_type = std::ptrdiff_t;
+
+ arg_iterator(
+ BaseIter Current, BaseIter End,
+ const OptSpecifier (&Ids)[NumOptSpecifiers ? NumOptSpecifiers : 1] = {})
+ : Current(Current), End(End) {
+ for (unsigned I = 0; I != NumOptSpecifiers; ++I)
+ this->Ids[I] = Ids[I];
+ SkipToNextArg();
+ }
+
+ reference operator*() const { return *Current; }
+ pointer operator->() const { return Current; }
+
+ arg_iterator &operator++() {
+ ++Current;
+ SkipToNextArg();
+ return *this;
+ }
+
+ arg_iterator operator++(int) {
+ arg_iterator tmp(*this);
+ ++(*this);
+ return tmp;
+ }
+
+ friend bool operator==(arg_iterator LHS, arg_iterator RHS) {
+ return LHS.Current == RHS.Current;
+ }
+ friend bool operator!=(arg_iterator LHS, arg_iterator RHS) {
+ return !(LHS == RHS);
+ }
+};
+
+/// ArgList - Ordered collection of driver arguments.
+///
+/// The ArgList class manages a list of Arg instances as well as
+/// auxiliary data and convenience methods to allow Tools to quickly
+/// check for the presence of Arg instances for a particular Option
+/// and to iterate over groups of arguments.
+class ArgList {
+public:
+ using arglist_type = SmallVector<Arg *, 16>;
+ using iterator = arg_iterator<arglist_type::iterator>;
+ using const_iterator = arg_iterator<arglist_type::const_iterator>;
+ using reverse_iterator = arg_iterator<arglist_type::reverse_iterator>;
+ using const_reverse_iterator =
+ arg_iterator<arglist_type::const_reverse_iterator>;
+
+ template<unsigned N> using filtered_iterator =
+ arg_iterator<arglist_type::const_iterator, N>;
+ template<unsigned N> using filtered_reverse_iterator =
+ arg_iterator<arglist_type::const_reverse_iterator, N>;
+
+private:
+ /// The internal list of arguments.
+ arglist_type Args;
+
+ using OptRange = std::pair<unsigned, unsigned>;
+ static OptRange emptyRange() { return {-1u, 0u}; }
+
+ /// The first and last index of each different OptSpecifier ID.
+ DenseMap<unsigned, OptRange> OptRanges;
+
+ /// Get the range of indexes in which options with the specified IDs might
+ /// reside, or (0, 0) if there are no such options.
+ OptRange getRange(std::initializer_list<OptSpecifier> Ids) const;
+
+protected:
+ // Make the default special members protected so they won't be used to slice
+ // derived objects, but can still be used by derived objects to implement
+ // their own special members.
+ ArgList() = default;
+
+ // Explicit move operations to ensure the container is cleared post-move
+ // otherwise it could lead to a double-delete in the case of moving of an
+ // InputArgList which deletes the contents of the container. If we could fix
+ // up the ownership here (delegate storage/ownership to the derived class so
+ // it can be a container of unique_ptr) this would be simpler.
+ ArgList(ArgList &&RHS)
+ : Args(std::move(RHS.Args)), OptRanges(std::move(RHS.OptRanges)) {
+ RHS.Args.clear();
+ RHS.OptRanges.clear();
+ }
+
+ ArgList &operator=(ArgList &&RHS) {
+ Args = std::move(RHS.Args);
+ RHS.Args.clear();
+ OptRanges = std::move(RHS.OptRanges);
+ RHS.OptRanges.clear();
+ return *this;
+ }
+
+ // Protect the dtor to ensure this type is never destroyed polymorphically.
+ ~ArgList() = default;
+
+ // Implicitly convert a value to an OptSpecifier. Used to work around a bug
+ // in MSVC's implementation of narrowing conversion checking.
+ static OptSpecifier toOptSpecifier(OptSpecifier S) { return S; }
+
+public:
+ /// @name Arg Access
+ /// @{
+
+ /// append - Append \p A to the arg list.
+ void append(Arg *A);
+
+ const arglist_type &getArgs() const { return Args; }
+
+ unsigned size() const { return Args.size(); }
+
+ /// @}
+ /// @name Arg Iteration
+ /// @{
+
+ iterator begin() { return {Args.begin(), Args.end()}; }
+ iterator end() { return {Args.end(), Args.end()}; }
+
+ reverse_iterator rbegin() { return {Args.rbegin(), Args.rend()}; }
+ reverse_iterator rend() { return {Args.rend(), Args.rend()}; }
+
+ const_iterator begin() const { return {Args.begin(), Args.end()}; }
+ const_iterator end() const { return {Args.end(), Args.end()}; }
+
+ const_reverse_iterator rbegin() const { return {Args.rbegin(), Args.rend()}; }
+ const_reverse_iterator rend() const { return {Args.rend(), Args.rend()}; }
+
+ template<typename ...OptSpecifiers>
+ iterator_range<filtered_iterator<sizeof...(OptSpecifiers)>>
+ filtered(OptSpecifiers ...Ids) const {
+ OptRange Range = getRange({toOptSpecifier(Ids)...});
+ auto B = Args.begin() + Range.first;
+ auto E = Args.begin() + Range.second;
+ using Iterator = filtered_iterator<sizeof...(OptSpecifiers)>;
+ return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}),
+ Iterator(E, E, {toOptSpecifier(Ids)...}));
+ }
+
+ template<typename ...OptSpecifiers>
+ iterator_range<filtered_reverse_iterator<sizeof...(OptSpecifiers)>>
+ filtered_reverse(OptSpecifiers ...Ids) const {
+ OptRange Range = getRange({toOptSpecifier(Ids)...});
+ auto B = Args.rend() - Range.second;
+ auto E = Args.rend() - Range.first;
+ using Iterator = filtered_reverse_iterator<sizeof...(OptSpecifiers)>;
+ return make_range(Iterator(B, E, {toOptSpecifier(Ids)...}),
+ Iterator(E, E, {toOptSpecifier(Ids)...}));
+ }
+
+ /// @}
+ /// @name Arg Removal
+ /// @{
+
+ /// eraseArg - Remove any option matching \p Id.
+ void eraseArg(OptSpecifier Id);
+
+ /// @}
+ /// @name Arg Access
+ /// @{
+
+ /// hasArg - Does the arg list contain any option matching \p Id.
+ ///
+ /// \p Claim Whether the argument should be claimed, if it exists.
+ template<typename ...OptSpecifiers>
+ bool hasArgNoClaim(OptSpecifiers ...Ids) const {
+ return getLastArgNoClaim(Ids...) != nullptr;
+ }
+ template<typename ...OptSpecifiers>
+ bool hasArg(OptSpecifiers ...Ids) const {
+ return getLastArg(Ids...) != nullptr;
+ }
+
+ /// Return the last argument matching \p Id, or null.
+ template<typename ...OptSpecifiers>
+ Arg *getLastArg(OptSpecifiers ...Ids) const {
+ Arg *Res = nullptr;
+ for (Arg *A : filtered(Ids...)) {
+ Res = A;
+ Res->claim();
+ }
+ return Res;
+ }
+
+ /// Return the last argument matching \p Id, or null. Do not "claim" the
+ /// option (don't mark it as having been used).
+ template<typename ...OptSpecifiers>
+ Arg *getLastArgNoClaim(OptSpecifiers ...Ids) const {
+ for (Arg *A : filtered_reverse(Ids...))
+ return A;
+ return nullptr;
+ }
+
+ /// getArgString - Return the input argument string at \p Index.
+ virtual const char *getArgString(unsigned Index) const = 0;
+
+ /// getNumInputArgStrings - Return the number of original argument strings,
+ /// which are guaranteed to be the first strings in the argument string
+ /// list.
+ virtual unsigned getNumInputArgStrings() const = 0;
+
+ /// @}
+ /// @name Argument Lookup Utilities
+ /// @{
+
+ /// getLastArgValue - Return the value of the last argument, or a default.
+ StringRef getLastArgValue(OptSpecifier Id, StringRef Default = "") const;
+
+ /// getAllArgValues - Get the values of all instances of the given argument
+ /// as strings.
+ std::vector<std::string> getAllArgValues(OptSpecifier Id) const;
+
+ /// @}
+ /// @name Translation Utilities
+ /// @{
+
+ /// hasFlag - Given an option \p Pos and its negative form \p Neg, return
+ /// true if the option is present, false if the negation is present, and
+ /// \p Default if neither option is given. If both the option and its
+ /// negation are present, the last one wins.
+ bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default=true) const;
+
+ /// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
+ /// form \p Neg, return true if the option or its alias is present, false if
+ /// the negation is present, and \p Default if none of the options are
+ /// given. If multiple options are present, the last one wins.
+ bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
+ bool Default = true) const;
+
+ /// Render only the last argument match \p Id0, if present.
+ template<typename ...OptSpecifiers>
+ void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const {
+ if (Arg *A = getLastArg(Ids...)) // Calls claim() on all Ids's Args.
+ A->render(*this, Output);
+ }
+
+ /// AddAllArgsExcept - Render all arguments matching any of the given ids
+ /// and not matching any of the excluded ids.
+ void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
+ ArrayRef<OptSpecifier> ExcludeIds) const;
+ /// AddAllArgs - Render all arguments matching any of the given ids.
+ void AddAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
+
+ /// AddAllArgs - Render all arguments matching the given ids.
+ void AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
+ OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
+
+ /// AddAllArgValues - Render the argument values of all arguments
+ /// matching the given ids.
+ void AddAllArgValues(ArgStringList &Output, OptSpecifier Id0,
+ OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;
+
+ /// AddAllArgsTranslated - Render all the arguments matching the
+ /// given ids, but forced to separate args and using the provided
+ /// name instead of the first option value.
+ ///
+ /// \param Joined - If true, render the argument as joined with
+ /// the option specifier.
+ void AddAllArgsTranslated(ArgStringList &Output, OptSpecifier Id0,
+ const char *Translation,
+ bool Joined = false) const;
+
+ /// ClaimAllArgs - Claim all arguments which match the given
+ /// option id.
+ void ClaimAllArgs(OptSpecifier Id0) const;
+
+ /// ClaimAllArgs - Claim all arguments.
+ ///
+ void ClaimAllArgs() const;
+
+ /// @}
+ /// @name Arg Synthesis
+ /// @{
+
+ /// Construct a constant string pointer whose
+ /// lifetime will match that of the ArgList.
+ virtual const char *MakeArgStringRef(StringRef Str) const = 0;
+ const char *MakeArgString(const Twine &Str) const {
+ SmallString<256> Buf;
+ return MakeArgStringRef(Str.toStringRef(Buf));
+ }
+
+ /// Create an arg string for (\p LHS + \p RHS), reusing the
+ /// string at \p Index if possible.
+ const char *GetOrMakeJoinedArgString(unsigned Index, StringRef LHS,
+ StringRef RHS) const;
+
+ void print(raw_ostream &O) const;
+ void dump() const;
+
+ /// @}
+};
+
+class InputArgList final : public ArgList {
+private:
+ /// List of argument strings used by the contained Args.
+ ///
+ /// This is mutable since we treat the ArgList as being the list
+ /// of Args, and allow routines to add new strings (to have a
+ /// convenient place to store the memory) via MakeIndex.
+ mutable ArgStringList ArgStrings;
+
+ /// Strings for synthesized arguments.
+ ///
+ /// This is mutable since we treat the ArgList as being the list
+ /// of Args, and allow routines to add new strings (to have a
+ /// convenient place to store the memory) via MakeIndex.
+ mutable std::list<std::string> SynthesizedStrings;
+
+ /// The number of original input argument strings.
+ unsigned NumInputArgStrings;
+
+ /// Release allocated arguments.
+ void releaseMemory();
+
+public:
+ InputArgList() : NumInputArgStrings(0) {}
+
+ InputArgList(const char* const *ArgBegin, const char* const *ArgEnd);
+
+ InputArgList(InputArgList &&RHS)
+ : ArgList(std::move(RHS)), ArgStrings(std::move(RHS.ArgStrings)),
+ SynthesizedStrings(std::move(RHS.SynthesizedStrings)),
+ NumInputArgStrings(RHS.NumInputArgStrings) {}
+
+ InputArgList &operator=(InputArgList &&RHS) {
+ releaseMemory();
+ ArgList::operator=(std::move(RHS));
+ ArgStrings = std::move(RHS.ArgStrings);
+ SynthesizedStrings = std::move(RHS.SynthesizedStrings);
+ NumInputArgStrings = RHS.NumInputArgStrings;
+ return *this;
+ }
+
+ ~InputArgList() { releaseMemory(); }
+
+ const char *getArgString(unsigned Index) const override {
+ return ArgStrings[Index];
+ }
+
+ void replaceArgString(unsigned Index, const Twine &S) {
+ ArgStrings[Index] = MakeArgString(S);
+ }
+
+ unsigned getNumInputArgStrings() const override {
+ return NumInputArgStrings;
+ }
+
+ /// @name Arg Synthesis
+ /// @{
+
+public:
+ /// MakeIndex - Get an index for the given string(s).
+ unsigned MakeIndex(StringRef String0) const;
+ unsigned MakeIndex(StringRef String0, StringRef String1) const;
+
+ using ArgList::MakeArgString;
+ const char *MakeArgStringRef(StringRef Str) const override;
+
+ /// @}
+};
+
+/// DerivedArgList - An ordered collection of driver arguments,
+/// whose storage may be in another argument list.
+class DerivedArgList final : public ArgList {
+ const InputArgList &BaseArgs;
+
+ /// The list of arguments we synthesized.
+ mutable SmallVector<std::unique_ptr<Arg>, 16> SynthesizedArgs;
+
+public:
+ /// Construct a new derived arg list from \p BaseArgs.
+ DerivedArgList(const InputArgList &BaseArgs);
+
+ const char *getArgString(unsigned Index) const override {
+ return BaseArgs.getArgString(Index);
+ }
+
+ unsigned getNumInputArgStrings() const override {
+ return BaseArgs.getNumInputArgStrings();
+ }
+
+ const InputArgList &getBaseArgs() const {
+ return BaseArgs;
+ }
+
+ /// @name Arg Synthesis
+ /// @{
+
+ /// AddSynthesizedArg - Add a argument to the list of synthesized arguments
+ /// (to be freed).
+ void AddSynthesizedArg(Arg *A);
+
+ using ArgList::MakeArgString;
+ const char *MakeArgStringRef(StringRef Str) const override;
+
+ /// AddFlagArg - Construct a new FlagArg for the given option \p Id and
+ /// append it to the argument list.
+ void AddFlagArg(const Arg *BaseArg, const Option Opt) {
+ append(MakeFlagArg(BaseArg, Opt));
+ }
+
+ /// AddPositionalArg - Construct a new Positional arg for the given option
+ /// \p Id, with the provided \p Value and append it to the argument
+ /// list.
+ void AddPositionalArg(const Arg *BaseArg, const Option Opt,
+ StringRef Value) {
+ append(MakePositionalArg(BaseArg, Opt, Value));
+ }
+
+ /// AddSeparateArg - Construct a new Positional arg for the given option
+ /// \p Id, with the provided \p Value and append it to the argument
+ /// list.
+ void AddSeparateArg(const Arg *BaseArg, const Option Opt,
+ StringRef Value) {
+ append(MakeSeparateArg(BaseArg, Opt, Value));
+ }
+
+ /// AddJoinedArg - Construct a new Positional arg for the given option
+ /// \p Id, with the provided \p Value and append it to the argument list.
+ void AddJoinedArg(const Arg *BaseArg, const Option Opt,
+ StringRef Value) {
+ append(MakeJoinedArg(BaseArg, Opt, Value));
+ }
+
+ /// MakeFlagArg - Construct a new FlagArg for the given option \p Id.
+ Arg *MakeFlagArg(const Arg *BaseArg, const Option Opt) const;
+
+ /// MakePositionalArg - Construct a new Positional arg for the
+ /// given option \p Id, with the provided \p Value.
+ Arg *MakePositionalArg(const Arg *BaseArg, const Option Opt,
+ StringRef Value) const;
+
+ /// MakeSeparateArg - Construct a new Positional arg for the
+ /// given option \p Id, with the provided \p Value.
+ Arg *MakeSeparateArg(const Arg *BaseArg, const Option Opt,
+ StringRef Value) const;
+
+ /// MakeJoinedArg - Construct a new Positional arg for the
+ /// given option \p Id, with the provided \p Value.
+ Arg *MakeJoinedArg(const Arg *BaseArg, const Option Opt,
+ StringRef Value) const;
+
+ /// @}
+};
+
+} // end namespace opt
+
+} // end namespace llvm
+
+#endif // LLVM_OPTION_ARGLIST_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Option/OptParser.td b/contrib/libs/llvm12/include/llvm/Option/OptParser.td
new file mode 100644
index 0000000000..9a179c511b
--- /dev/null
+++ b/contrib/libs/llvm12/include/llvm/Option/OptParser.td
@@ -0,0 +1,234 @@
+//===--- OptParser.td - Common Option Parsing Interfaces ------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the common interfaces used by the option parsing TableGen
+// backend.
+//
+//===----------------------------------------------------------------------===//
+
+// Define the kinds of options.
+
+class OptionKind<string name, int precedence = 0, bit sentinel = false> {
+ string Name = name;
+ // The kind precedence, kinds with lower precedence are matched first.
+ int Precedence = precedence;
+ // Indicate a sentinel option.
+ bit Sentinel = sentinel;
+}
+
+// An option group.
+def KIND_GROUP : OptionKind<"Group">;
+// The input option kind.
+def KIND_INPUT : OptionKind<"Input", 1, true>;
+// The unknown option kind.
+def KIND_UNKNOWN : OptionKind<"Unknown", 2, true>;
+// A flag with no values.
+def KIND_FLAG : OptionKind<"Flag">;
+// An option which prefixes its (single) value.
+def KIND_JOINED : OptionKind<"Joined", 1>;
+// An option which is followed by its value.
+def KIND_SEPARATE : OptionKind<"Separate">;
+// An option followed by its values, which are separated by commas.
+def KIND_COMMAJOINED : OptionKind<"CommaJoined">;
+// An option which is which takes multiple (separate) arguments.
+def KIND_MULTIARG : OptionKind<"MultiArg">;
+// An option which is either joined to its (non-empty) value, or followed by its
+// value.
+def KIND_JOINED_OR_SEPARATE : OptionKind<"JoinedOrSeparate">;
+// An option which is both joined to its (first) value, and followed by its
+// (second) value.
+def KIND_JOINED_AND_SEPARATE : OptionKind<"JoinedAndSeparate">;
+// An option which consumes all remaining arguments if there are any.
+def KIND_REMAINING_ARGS : OptionKind<"RemainingArgs">;
+// An option which consumes an optional joined argument and any other remaining
+// arguments.
+def KIND_REMAINING_ARGS_JOINED : OptionKind<"RemainingArgsJoined">;
+
+// Define the option flags.
+
+class OptionFlag {}
+
+// HelpHidden - The option should not be displayed in --help, even if it has
+// help text. Clients *can* use this in conjunction with the OptTable::PrintHelp
+// arguments to implement hidden help groups.
+def HelpHidden : OptionFlag;
+
+// RenderAsInput - The option should not render the name when rendered as an
+// input (i.e., the option is rendered as values).
+def RenderAsInput : OptionFlag;
+
+// RenderJoined - The option should be rendered joined, even if separate (only
+// sensible on single value separate options).
+def RenderJoined : OptionFlag;
+
+// RenderSeparate - The option should be rendered separately, even if joined
+// (only sensible on joined options).
+def RenderSeparate : OptionFlag;
+
+// Define the option group class.
+
+class OptionGroup<string name> {
+ string EnumName = ?; // Uses the def name if undefined.
+ string Name = name;
+ string HelpText = ?;
+ OptionGroup Group = ?;
+ list<OptionFlag> Flags = [];
+}
+
+// Define the option class.
+
+class Option<list<string> prefixes, string name, OptionKind kind> {
+ string EnumName = ?; // Uses the def name if undefined.
+ list<string> Prefixes = prefixes;
+ string Name = name;
+ OptionKind Kind = kind;
+ // Used by MultiArg option kind.
+ int NumArgs = 0;
+ string HelpText = ?;
+ string MetaVarName = ?;
+ string Values = ?;
+ code ValuesCode = ?;
+ list<OptionFlag> Flags = [];
+ OptionGroup Group = ?;
+ Option Alias = ?;
+ list<string> AliasArgs = [];
+ code MacroPrefix = "";
+ code KeyPath = ?;
+ code DefaultValue = ?;
+ code ImpliedValue = ?;
+ code ImpliedCheck = "false";
+ code ShouldParse = "true";
+ bit ShouldAlwaysEmit = false;
+ code NormalizerRetTy = ?;
+ code NormalizedValuesScope = "";
+ code Normalizer = "";
+ code Denormalizer = "";
+ code ValueMerger = "mergeForwardValue";
+ code ValueExtractor = "extractForwardValue";
+ list<code> NormalizedValues = ?;
+}
+
+// Helpers for defining options.
+
+class Flag<list<string> prefixes, string name>
+ : Option<prefixes, name, KIND_FLAG>;
+class Joined<list<string> prefixes, string name>
+ : Option<prefixes, name, KIND_JOINED>;
+class Separate<list<string> prefixes, string name>
+ : Option<prefixes, name, KIND_SEPARATE>;
+class CommaJoined<list<string> prefixes, string name>
+ : Option<prefixes, name, KIND_COMMAJOINED>;
+class MultiArg<list<string> prefixes, string name, int numargs>
+ : Option<prefixes, name, KIND_MULTIARG> {
+ int NumArgs = numargs;
+}
+class JoinedOrSeparate<list<string> prefixes, string name>
+ : Option<prefixes, name, KIND_JOINED_OR_SEPARATE>;
+class JoinedAndSeparate<list<string> prefixes, string name>
+ : Option<prefixes, name, KIND_JOINED_AND_SEPARATE>;
+
+// Mix-ins for adding optional attributes.
+
+class Alias<Option alias> { Option Alias = alias; }
+class AliasArgs<list<string> aliasargs> { list<string> AliasArgs = aliasargs; }
+class EnumName<string name> { string EnumName = name; }
+class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
+class Group<OptionGroup group> { OptionGroup Group = group; }
+class HelpText<string text> { string HelpText = text; }
+class MetaVarName<string name> { string MetaVarName = name; }
+class Values<string value> { string Values = value; }
+class ValuesCode<code valuecode> { code ValuesCode = valuecode; }
+
+// Helpers for defining marshalling information.
+
+class KeyPathAndMacro<string key_path_prefix, string key_path_base,
+ string macro_prefix = ""> {
+ code KeyPath = !strconcat(key_path_prefix, key_path_base);
+ code MacroPrefix = macro_prefix;
+}
+
+def EmptyKPM : KeyPathAndMacro<"", "">;
+
+class ImpliedByAnyOf<list<string> key_paths, code value = "true"> {
+ code ImpliedCheck = !foldl("false", key_paths, accumulator, key_path,
+ !strconcat(accumulator, " || ", key_path));
+ code ImpliedValue = value;
+}
+
+class MarshallingInfo<KeyPathAndMacro kpm, code defaultvalue> {
+ code KeyPath = kpm.KeyPath;
+ code MacroPrefix = kpm.MacroPrefix;
+ code DefaultValue = defaultvalue;
+}
+
+class MarshallingInfoString<KeyPathAndMacro kpm, code defaultvalue="std::string()">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeString";
+ code Denormalizer = "denormalizeString";
+}
+
+class MarshallingInfoStringInt<KeyPathAndMacro kpm, code defaultvalue="0", code type="unsigned">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeStringIntegral<"#type#">";
+ code Denormalizer = "denormalizeString";
+}
+
+class MarshallingInfoStringVector<KeyPathAndMacro kpm>
+ : MarshallingInfo<kpm, "std::vector<std::string>({})"> {
+ code Normalizer = "normalizeStringVector";
+ code Denormalizer = "denormalizeStringVector";
+}
+
+class MarshallingInfoFlag<KeyPathAndMacro kpm, code defaultvalue = "false">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeSimpleFlag";
+ code Denormalizer = "denormalizeSimpleFlag";
+}
+
+class MarshallingInfoNegativeFlag<KeyPathAndMacro kpm, code defaultvalue = "true">
+ : MarshallingInfo<kpm, defaultvalue> {
+ code Normalizer = "normalizeSimpleNegativeFlag";
+ code Denormalizer = "denormalizeSimpleFlag";
+}
+
+class MarshallingInfoBitfieldFlag<KeyPathAndMacro kpm, code value>
+ : MarshallingInfoFlag<kpm, "0u"> {
+ code Normalizer = "makeFlagToValueNormalizer("#value#")";
+ code ValueMerger = "mergeMaskValue";
+ code ValueExtractor = "(extractMaskValue<unsigned, decltype("#value#"), "#value#">)";
+}
+
+// Marshalling info for booleans. Applied to the flag setting keypath to false.
+class MarshallingInfoBooleanFlag<KeyPathAndMacro kpm, code defaultvalue, code value, code name,
+ code other_value, code other_name>
+ : MarshallingInfoFlag<kpm, defaultvalue> {
+ code Normalizer = "makeBooleanOptionNormalizer("#value#", "#other_value#", OPT_"#other_name#")";
+ code Denormalizer = "makeBooleanOptionDenormalizer("#value#")";
+}
+
+// Mixins for additional marshalling attributes.
+
+class ShouldParseIf<code condition> { code ShouldParse = condition; }
+class AlwaysEmit { bit ShouldAlwaysEmit = true; }
+class Normalizer<code normalizer> { code Normalizer = normalizer; }
+class Denormalizer<code denormalizer> { code Denormalizer = denormalizer; }
+class NormalizedValuesScope<code scope> { code NormalizedValuesScope = scope; }
+class NormalizedValues<list<code> definitions> { list<code> NormalizedValues = definitions; }
+class AutoNormalizeEnum {
+ code Normalizer = "normalizeSimpleEnum";
+ code Denormalizer = "denormalizeSimpleEnum";
+}
+class ValueMerger<code merger> { code ValueMerger = merger; }
+class ValueExtractor<code extractor> { code ValueExtractor = extractor; }
+
+// Predefined options.
+
+// FIXME: Have generator validate that these appear in correct position (and
+// aren't duplicated).
+def INPUT : Option<[], "<input>", KIND_INPUT>;
+def UNKNOWN : Option<[], "<unknown>", KIND_UNKNOWN>;
diff --git a/contrib/libs/llvm12/include/llvm/Option/OptSpecifier.h b/contrib/libs/llvm12/include/llvm/Option/OptSpecifier.h
new file mode 100644
index 0000000000..2515cb1f29
--- /dev/null
+++ b/contrib/libs/llvm12/include/llvm/Option/OptSpecifier.h
@@ -0,0 +1,49 @@
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- OptSpecifier.h - Option Specifiers -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPTION_OPTSPECIFIER_H
+#define LLVM_OPTION_OPTSPECIFIER_H
+
+namespace llvm {
+namespace opt {
+
+class Option;
+
+/// OptSpecifier - Wrapper class for abstracting references to option IDs.
+class OptSpecifier {
+ unsigned ID = 0;
+
+public:
+ OptSpecifier() = default;
+ explicit OptSpecifier(bool) = delete;
+ /*implicit*/ OptSpecifier(unsigned ID) : ID(ID) {}
+ /*implicit*/ OptSpecifier(const Option *Opt);
+
+ bool isValid() const { return ID != 0; }
+
+ unsigned getID() const { return ID; }
+
+ bool operator==(OptSpecifier Opt) const { return ID == Opt.getID(); }
+ bool operator!=(OptSpecifier Opt) const { return !(*this == Opt); }
+};
+
+} // end namespace opt
+} // end namespace llvm
+
+#endif // LLVM_OPTION_OPTSPECIFIER_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Option/OptTable.h b/contrib/libs/llvm12/include/llvm/Option/OptTable.h
new file mode 100644
index 0000000000..f7553d2b4b
--- /dev/null
+++ b/contrib/libs/llvm12/include/llvm/Option/OptTable.h
@@ -0,0 +1,275 @@
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- OptTable.h - Option Table --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPTION_OPTTABLE_H
+#define LLVM_OPTION_OPTTABLE_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Option/OptSpecifier.h"
+#include "llvm/Support/StringSaver.h"
+#include <cassert>
+#include <string>
+#include <vector>
+
+namespace llvm {
+
+class raw_ostream;
+template <typename Fn> class function_ref;
+
+namespace opt {
+
+class Arg;
+class ArgList;
+class InputArgList;
+class Option;
+
+/// Provide access to the Option info table.
+///
+/// The OptTable class provides a layer of indirection which allows Option
+/// instance to be created lazily. In the common case, only a few options will
+/// be needed at runtime; the OptTable class maintains enough information to
+/// parse command lines without instantiating Options, while letting other
+/// parts of the driver still use Option instances where convenient.
+class OptTable {
+public:
+ /// Entry for a single option instance in the option data table.
+ struct Info {
+ /// A null terminated array of prefix strings to apply to name while
+ /// matching.
+ const char *const *Prefixes;
+ const char *Name;
+ const char *HelpText;
+ const char *MetaVar;
+ unsigned ID;
+ unsigned char Kind;
+ unsigned char Param;
+ unsigned int Flags;
+ unsigned short GroupID;
+ unsigned short AliasID;
+ const char *AliasArgs;
+ const char *Values;
+ };
+
+private:
+ /// The option information table.
+ std::vector<Info> OptionInfos;
+ bool IgnoreCase;
+ bool GroupedShortOptions = false;
+ const char *EnvVar = nullptr;
+
+ unsigned TheInputOptionID = 0;
+ unsigned TheUnknownOptionID = 0;
+
+ /// The index of the first option which can be parsed (i.e., is not a
+ /// special option like 'input' or 'unknown', and is not an option group).
+ unsigned FirstSearchableIndex = 0;
+
+ /// The union of all option prefixes. If an argument does not begin with
+ /// one of these, it is an input.
+ StringSet<> PrefixesUnion;
+ std::string PrefixChars;
+
+private:
+ const Info &getInfo(OptSpecifier Opt) const {
+ unsigned id = Opt.getID();
+ assert(id > 0 && id - 1 < getNumOptions() && "Invalid Option ID.");
+ return OptionInfos[id - 1];
+ }
+
+ Arg *parseOneArgGrouped(InputArgList &Args, unsigned &Index) const;
+
+protected:
+ OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
+
+public:
+ ~OptTable();
+
+ /// Return the total number of option classes.
+ unsigned getNumOptions() const { return OptionInfos.size(); }
+
+ /// Get the given Opt's Option instance, lazily creating it
+ /// if necessary.
+ ///
+ /// \return The option, or null for the INVALID option id.
+ const Option getOption(OptSpecifier Opt) const;
+
+ /// Lookup the name of the given option.
+ const char *getOptionName(OptSpecifier id) const {
+ return getInfo(id).Name;
+ }
+
+ /// Get the kind of the given option.
+ unsigned getOptionKind(OptSpecifier id) const {
+ return getInfo(id).Kind;
+ }
+
+ /// Get the group id for the given option.
+ unsigned getOptionGroupID(OptSpecifier id) const {
+ return getInfo(id).GroupID;
+ }
+
+ /// Get the help text to use to describe this option.
+ const char *getOptionHelpText(OptSpecifier id) const {
+ return getInfo(id).HelpText;
+ }
+
+ /// Get the meta-variable name to use when describing
+ /// this options values in the help text.
+ const char *getOptionMetaVar(OptSpecifier id) const {
+ return getInfo(id).MetaVar;
+ }
+
+ /// Specify the environment variable where initial options should be read.
+ void setInitialOptionsFromEnvironment(const char *E) { EnvVar = E; }
+
+ /// Support grouped short options. e.g. -ab represents -a -b.
+ void setGroupedShortOptions(bool Value) { GroupedShortOptions = Value; }
+
+ /// Find possible value for given flags. This is used for shell
+ /// autocompletion.
+ ///
+ /// \param [in] Option - Key flag like "-stdlib=" when "-stdlib=l"
+ /// was passed to clang.
+ ///
+ /// \param [in] Arg - Value which we want to autocomplete like "l"
+ /// when "-stdlib=l" was passed to clang.
+ ///
+ /// \return The vector of possible values.
+ std::vector<std::string> suggestValueCompletions(StringRef Option,
+ StringRef Arg) const;
+
+ /// Find flags from OptTable which starts with Cur.
+ ///
+ /// \param [in] Cur - String prefix that all returned flags need
+ // to start with.
+ ///
+ /// \return The vector of flags which start with Cur.
+ std::vector<std::string> findByPrefix(StringRef Cur,
+ unsigned int DisableFlags) const;
+
+ /// Find the OptTable option that most closely matches the given string.
+ ///
+ /// \param [in] Option - A string, such as "-stdlibs=l", that represents user
+ /// input of an option that may not exist in the OptTable. Note that the
+ /// string includes prefix dashes "-" as well as values "=l".
+ /// \param [out] NearestString - The nearest option string found in the
+ /// OptTable.
+ /// \param [in] FlagsToInclude - Only find options with any of these flags.
+ /// Zero is the default, which includes all flags.
+ /// \param [in] FlagsToExclude - Don't find options with this flag. Zero
+ /// is the default, and means exclude nothing.
+ /// \param [in] MinimumLength - Don't find options shorter than this length.
+ /// For example, a minimum length of 3 prevents "-x" from being considered
+ /// near to "-S".
+ ///
+ /// \return The edit distance of the nearest string found.
+ unsigned findNearest(StringRef Option, std::string &NearestString,
+ unsigned FlagsToInclude = 0, unsigned FlagsToExclude = 0,
+ unsigned MinimumLength = 4) const;
+
+ /// Add Values to Option's Values class
+ ///
+ /// \param [in] Option - Prefix + Name of the flag which Values will be
+ /// changed. For example, "-analyzer-checker".
+ /// \param [in] Values - String of Values seperated by ",", such as
+ /// "foo, bar..", where foo and bar is the argument which the Option flag
+ /// takes
+ ///
+ /// \return true in success, and false in fail.
+ bool addValues(const char *Option, const char *Values);
+
+ /// Parse a single argument; returning the new argument and
+ /// updating Index.
+ ///
+ /// \param [in,out] Index - The current parsing position in the argument
+ /// string list; on return this will be the index of the next argument
+ /// string to parse.
+ /// \param [in] FlagsToInclude - Only parse options with any of these flags.
+ /// Zero is the default which includes all flags.
+ /// \param [in] FlagsToExclude - Don't parse options with this flag. Zero
+ /// is the default and means exclude nothing.
+ ///
+ /// \return The parsed argument, or 0 if the argument is missing values
+ /// (in which case Index still points at the conceptual next argument string
+ /// to parse).
+ Arg *ParseOneArg(const ArgList &Args, unsigned &Index,
+ unsigned FlagsToInclude = 0,
+ unsigned FlagsToExclude = 0) const;
+
+ /// Parse an list of arguments into an InputArgList.
+ ///
+ /// The resulting InputArgList will reference the strings in [\p ArgBegin,
+ /// \p ArgEnd), and their lifetime should extend past that of the returned
+ /// InputArgList.
+ ///
+ /// The only error that can occur in this routine is if an argument is
+ /// missing values; in this case \p MissingArgCount will be non-zero.
+ ///
+ /// \param MissingArgIndex - On error, the index of the option which could
+ /// not be parsed.
+ /// \param MissingArgCount - On error, the number of missing options.
+ /// \param FlagsToInclude - Only parse options with any of these flags.
+ /// Zero is the default which includes all flags.
+ /// \param FlagsToExclude - Don't parse options with this flag. Zero
+ /// is the default and means exclude nothing.
+ /// \return An InputArgList; on error this will contain all the options
+ /// which could be parsed.
+ InputArgList ParseArgs(ArrayRef<const char *> Args, unsigned &MissingArgIndex,
+ unsigned &MissingArgCount, unsigned FlagsToInclude = 0,
+ unsigned FlagsToExclude = 0) const;
+
+ /// A convenience helper which handles optional initial options populated from
+ /// an environment variable, expands response files recursively and parses
+ /// options.
+ ///
+ /// \param ErrorFn - Called on a formatted error message for missing arguments
+ /// or unknown options.
+ /// \return An InputArgList; on error this will contain all the options which
+ /// could be parsed.
+ InputArgList parseArgs(int Argc, char *const *Argv, OptSpecifier Unknown,
+ StringSaver &Saver,
+ function_ref<void(StringRef)> ErrorFn) const;
+
+ /// Render the help text for an option table.
+ ///
+ /// \param OS - The stream to write the help text to.
+ /// \param Usage - USAGE: Usage
+ /// \param Title - OVERVIEW: Title
+ /// \param FlagsToInclude - If non-zero, only include options with any
+ /// of these flags set.
+ /// \param FlagsToExclude - Exclude options with any of these flags set.
+ /// \param ShowAllAliases - If true, display all options including aliases
+ /// that don't have help texts. By default, we display
+ /// only options that are not hidden and have help
+ /// texts.
+ void PrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
+ unsigned FlagsToInclude, unsigned FlagsToExclude,
+ bool ShowAllAliases) const;
+
+ void PrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
+ bool ShowHidden = false, bool ShowAllAliases = false) const;
+};
+
+} // end namespace opt
+
+} // end namespace llvm
+
+#endif // LLVM_OPTION_OPTTABLE_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
diff --git a/contrib/libs/llvm12/include/llvm/Option/Option.h b/contrib/libs/llvm12/include/llvm/Option/Option.h
new file mode 100644
index 0000000000..6bc4436754
--- /dev/null
+++ b/contrib/libs/llvm12/include/llvm/Option/Option.h
@@ -0,0 +1,247 @@
+#pragma once
+
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
+//===- Option.h - Abstract Driver Options -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_OPTION_OPTION_H
+#define LLVM_OPTION_OPTION_H
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Option/OptSpecifier.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <string>
+
+namespace llvm {
+
+class raw_ostream;
+
+namespace opt {
+
+class Arg;
+class ArgList;
+
+/// ArgStringList - Type used for constructing argv lists for subprocesses.
+using ArgStringList = SmallVector<const char *, 16>;
+
+/// Base flags for all options. Custom flags may be added after.
+enum DriverFlag {
+ HelpHidden = (1 << 0),
+ RenderAsInput = (1 << 1),
+ RenderJoined = (1 << 2),
+ RenderSeparate = (1 << 3)
+};
+
+/// Option - Abstract representation for a single form of driver
+/// argument.
+///
+/// An Option class represents a form of option that the driver
+/// takes, for example how many arguments the option has and how
+/// they can be provided. Individual option instances store
+/// additional information about what group the option is a member
+/// of (if any), if the option is an alias, and a number of
+/// flags. At runtime the driver parses the command line into
+/// concrete Arg instances, each of which corresponds to a
+/// particular Option instance.
+class Option {
+public:
+ enum OptionClass {
+ GroupClass = 0,
+ InputClass,
+ UnknownClass,
+ FlagClass,
+ JoinedClass,
+ ValuesClass,
+ SeparateClass,
+ RemainingArgsClass,
+ RemainingArgsJoinedClass,
+ CommaJoinedClass,
+ MultiArgClass,
+ JoinedOrSeparateClass,
+ JoinedAndSeparateClass
+ };
+
+ enum RenderStyleKind {
+ RenderCommaJoinedStyle,
+ RenderJoinedStyle,
+ RenderSeparateStyle,
+ RenderValuesStyle
+ };
+
+protected:
+ const OptTable::Info *Info;
+ const OptTable *Owner;
+
+public:
+ Option(const OptTable::Info *Info, const OptTable *Owner);
+
+ bool isValid() const {
+ return Info != nullptr;
+ }
+
+ unsigned getID() const {
+ assert(Info && "Must have a valid info!");
+ return Info->ID;
+ }
+
+ OptionClass getKind() const {
+ assert(Info && "Must have a valid info!");
+ return OptionClass(Info->Kind);
+ }
+
+ /// Get the name of this option without any prefix.
+ StringRef getName() const {
+ assert(Info && "Must have a valid info!");
+ return Info->Name;
+ }
+
+ const Option getGroup() const {
+ assert(Info && "Must have a valid info!");
+ assert(Owner && "Must have a valid owner!");
+ return Owner->getOption(Info->GroupID);
+ }
+
+ const Option getAlias() const {
+ assert(Info && "Must have a valid info!");
+ assert(Owner && "Must have a valid owner!");
+ return Owner->getOption(Info->AliasID);
+ }
+
+ /// Get the alias arguments as a \0 separated list.
+ /// E.g. ["foo", "bar"] would be returned as "foo\0bar\0".
+ const char *getAliasArgs() const {
+ assert(Info && "Must have a valid info!");
+ assert((!Info->AliasArgs || Info->AliasArgs[0] != 0) &&
+ "AliasArgs should be either 0 or non-empty.");
+
+ return Info->AliasArgs;
+ }
+
+ /// Get the default prefix for this option.
+ StringRef getPrefix() const {
+ const char *Prefix = *Info->Prefixes;
+ return Prefix ? Prefix : StringRef();
+ }
+
+ /// Get the name of this option with the default prefix.
+ std::string getPrefixedName() const {
+ std::string Ret(getPrefix());
+ Ret += getName();
+ return Ret;
+ }
+
+ /// Get the help text for this option.
+ StringRef getHelpText() const {
+ assert(Info && "Must have a valid info!");
+ return Info->HelpText;
+ }
+
+ /// Get the meta-variable list for this option.
+ StringRef getMetaVar() const {
+ assert(Info && "Must have a valid info!");
+ return Info->MetaVar;
+ }
+
+ unsigned getNumArgs() const { return Info->Param; }
+
+ bool hasNoOptAsInput() const { return Info->Flags & RenderAsInput;}
+
+ RenderStyleKind getRenderStyle() const {
+ if (Info->Flags & RenderJoined)
+ return RenderJoinedStyle;
+ if (Info->Flags & RenderSeparate)
+ return RenderSeparateStyle;
+ switch (getKind()) {
+ case GroupClass:
+ case InputClass:
+ case UnknownClass:
+ return RenderValuesStyle;
+ case JoinedClass:
+ case JoinedAndSeparateClass:
+ return RenderJoinedStyle;
+ case CommaJoinedClass:
+ return RenderCommaJoinedStyle;
+ case FlagClass:
+ case ValuesClass:
+ case SeparateClass:
+ case MultiArgClass:
+ case JoinedOrSeparateClass:
+ case RemainingArgsClass:
+ case RemainingArgsJoinedClass:
+ return RenderSeparateStyle;
+ }
+ llvm_unreachable("Unexpected kind!");
+ }
+
+ /// Test if this option has the flag \a Val.
+ bool hasFlag(unsigned Val) const {
+ return Info->Flags & Val;
+ }
+
+ /// getUnaliasedOption - Return the final option this option
+ /// aliases (itself, if the option has no alias).
+ const Option getUnaliasedOption() const {
+ const Option Alias = getAlias();
+ if (Alias.isValid()) return Alias.getUnaliasedOption();
+ return *this;
+ }
+
+ /// getRenderName - Return the name to use when rendering this
+ /// option.
+ StringRef getRenderName() const {
+ return getUnaliasedOption().getName();
+ }
+
+ /// matches - Predicate for whether this option is part of the
+ /// given option (which may be a group).
+ ///
+ /// Note that matches against options which are an alias should never be
+ /// done -- aliases do not participate in matching and so such a query will
+ /// always be false.
+ bool matches(OptSpecifier ID) const;
+
+ /// accept - Potentially accept the current argument, returning a
+ /// new Arg instance, or 0 if the option does not accept this
+ /// argument (or the argument is missing values).
+ ///
+ /// If the option accepts the current argument, accept() sets
+ /// Index to the position where argument parsing should resume
+ /// (even if the argument is missing values).
+ ///
+ /// \p CurArg The argument to be matched. It may be shorter than the
+ /// underlying storage to represent a Joined argument.
+ /// \p GroupedShortOption If true, we are handling the fallback case of
+ /// parsing a prefix of the current argument as a short option.
+ Arg *accept(const ArgList &Args, StringRef CurArg, bool GroupedShortOption,
+ unsigned &Index) const;
+
+private:
+ Arg *acceptInternal(const ArgList &Args, StringRef CurArg,
+ unsigned &Index) const;
+
+public:
+ void print(raw_ostream &O) const;
+ void dump() const;
+};
+
+} // end namespace opt
+
+} // end namespace llvm
+
+#endif // LLVM_OPTION_OPTION_H
+
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif