summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/Support/CommandLine.h
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2017-06-09 21:41:54 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2017-06-09 21:41:54 +0000
commit416e0592d5fc2828bffcb996cc2ac2512e71e82c (patch)
tree6afc2bd9e2b774788cfe826bddaf0d1923598ea8 /llvm/include/llvm/Support/CommandLine.h
parent41cafcd49c4ff778740f90ea87687caccdd351ca (diff)
downloadbcm5719-llvm-416e0592d5fc2828bffcb996cc2ac2512e71e82c.tar.gz
bcm5719-llvm-416e0592d5fc2828bffcb996cc2ac2512e71e82c.zip
[Support] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 305119
Diffstat (limited to 'llvm/include/llvm/Support/CommandLine.h')
-rw-r--r--llvm/include/llvm/Support/CommandLine.h68
1 files changed, 40 insertions, 28 deletions
diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h
index fe18416e239..771b0a8c26a 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -33,6 +33,7 @@
#include <cassert>
#include <climits>
#include <cstddef>
+#include <functional>
#include <initializer_list>
#include <string>
#include <type_traits>
@@ -41,6 +42,7 @@
namespace llvm {
class StringSaver;
+class raw_ostream;
/// cl Namespace - This namespace contains all of the command line option
/// processing machinery. It is intentionally a short name to make qualified
@@ -65,7 +67,7 @@ void ParseEnvironmentOptions(const char *progName, const char *envvar,
const char *Overview = "");
// Function pointer type for printing version information.
-typedef std::function<void(raw_ostream &)> VersionPrinterTy;
+using VersionPrinterTy = std::function<void(raw_ostream &)>;
///===---------------------------------------------------------------------===//
/// SetVersionPrinter - Override the default (LLVM specific) version printer
@@ -245,7 +247,7 @@ class Option {
// Out of line virtual function to provide home for the class.
virtual void anchor();
- int NumOccurrences; // The number of times specified
+ int NumOccurrences = 0; // The number of times specified
// Occurrences, HiddenFlag, and Formatting are all enum types but to avoid
// problems with signed enums in bitfields.
unsigned Occurrences : 3; // enum NumOccurrencesFlag
@@ -255,8 +257,8 @@ class Option {
unsigned HiddenFlag : 2; // enum OptionHidden
unsigned Formatting : 2; // enum FormattingFlags
unsigned Misc : 3;
- unsigned Position; // Position of last occurrence of the option
- unsigned AdditionalVals; // Greater than 0 for multi-valued option.
+ unsigned Position = 0; // Position of last occurrence of the option
+ unsigned AdditionalVals = 0; // Greater than 0 for multi-valued option.
public:
StringRef ArgStr; // The argument string itself (ex: "help", "o")
@@ -264,7 +266,7 @@ public:
StringRef ValueStr; // String describing what the value of this option is
OptionCategory *Category; // The Category this option belongs to
SmallPtrSet<SubCommand *, 4> Subs; // The subcommands this option belongs to.
- bool FullyInitialized; // Has addArguemnt been called?
+ bool FullyInitialized = false; // Has addArguemnt been called?
inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
return (enum NumOccurrencesFlag)Occurrences;
@@ -319,10 +321,8 @@ public:
protected:
explicit Option(enum NumOccurrencesFlag OccurrencesFlag,
enum OptionHidden Hidden)
- : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
- HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), Position(0),
- AdditionalVals(0), Category(&GeneralCategory), FullyInitialized(false) {
- }
+ : Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden),
+ Formatting(NormalFormatting), Misc(0), Category(&GeneralCategory) {}
inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; }
@@ -450,8 +450,8 @@ struct GenericOptionValue {
protected:
GenericOptionValue() = default;
GenericOptionValue(const GenericOptionValue&) = default;
- ~GenericOptionValue() = default;
GenericOptionValue &operator=(const GenericOptionValue &) = default;
+ ~GenericOptionValue() = default;
private:
virtual void anchor();
@@ -464,7 +464,7 @@ template <class DataType> struct OptionValue;
template <class DataType, bool isClass>
struct OptionValueBase : public GenericOptionValue {
// Temporary storage for argument passing.
- typedef OptionValue<DataType> WrapperType;
+ using WrapperType = OptionValue<DataType>;
bool hasValue() const { return false; }
@@ -490,8 +490,8 @@ template <class DataType> class OptionValueCopy : public GenericOptionValue {
protected:
OptionValueCopy(const OptionValueCopy&) = default;
+ OptionValueCopy &operator=(const OptionValueCopy &) = default;
~OptionValueCopy() = default;
- OptionValueCopy &operator=(const OptionValueCopy&) = default;
public:
OptionValueCopy() = default;
@@ -522,13 +522,13 @@ public:
// Non-class option values.
template <class DataType>
struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> {
- typedef DataType WrapperType;
+ using WrapperType = DataType;
protected:
OptionValueBase() = default;
OptionValueBase(const OptionValueBase&) = default;
+ OptionValueBase &operator=(const OptionValueBase &) = default;
~OptionValueBase() = default;
- OptionValueBase &operator=(const OptionValueBase&) = default;
};
// Top-level option class.
@@ -551,7 +551,7 @@ enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE };
template <>
struct OptionValue<cl::boolOrDefault> final
: OptionValueCopy<cl::boolOrDefault> {
- typedef cl::boolOrDefault WrapperType;
+ using WrapperType = cl::boolOrDefault;
OptionValue() = default;
@@ -568,7 +568,7 @@ private:
template <>
struct OptionValue<std::string> final : OptionValueCopy<std::string> {
- typedef StringRef WrapperType;
+ using WrapperType = StringRef;
OptionValue() = default;
@@ -739,13 +739,15 @@ protected:
public:
OptionInfo(StringRef name, DataType v, StringRef helpStr)
: GenericOptionInfo(name, helpStr), V(v) {}
+
OptionValue<DataType> V;
};
SmallVector<OptionInfo, 8> Values;
public:
parser(Option &O) : generic_parser_base(O) {}
- typedef DataType parser_data_type;
+
+ using parser_data_type = DataType;
// Implement virtual functions needed by generic_parser_base
unsigned getNumOptions() const override { return unsigned(Values.size()); }
@@ -840,10 +842,10 @@ protected:
//
template <class DataType> class basic_parser : public basic_parser_impl {
public:
- basic_parser(Option &O) : basic_parser_impl(O) {}
+ using parser_data_type = DataType;
+ using OptVal = OptionValue<DataType>;
- typedef DataType parser_data_type;
- typedef OptionValue<DataType> OptVal;
+ basic_parser(Option &O) : basic_parser_impl(O) {}
protected:
~basic_parser() = default;
@@ -1295,6 +1297,7 @@ class opt : public Option,
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
+
void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}
@@ -1303,6 +1306,7 @@ class opt : public Option,
size_t getOptionWidth() const override {
return Parser.getOptionWidth(*this);
}
+
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}
@@ -1387,16 +1391,18 @@ template <class DataType> class list_storage<DataType, bool> {
std::vector<DataType> Storage;
public:
- typedef typename std::vector<DataType>::iterator iterator;
+ using iterator = typename std::vector<DataType>::iterator;
iterator begin() { return Storage.begin(); }
iterator end() { return Storage.end(); }
- typedef typename std::vector<DataType>::const_iterator const_iterator;
+ using const_iterator = typename std::vector<DataType>::const_iterator;
+
const_iterator begin() const { return Storage.begin(); }
const_iterator end() const { return Storage.end(); }
- typedef typename std::vector<DataType>::size_type size_type;
+ using size_type = typename std::vector<DataType>::size_type;
+
size_type size() const { return Storage.size(); }
bool empty() const { return Storage.empty(); }
@@ -1404,8 +1410,9 @@ public:
void push_back(const DataType &value) { Storage.push_back(value); }
void push_back(DataType &&value) { Storage.push_back(value); }
- typedef typename std::vector<DataType>::reference reference;
- typedef typename std::vector<DataType>::const_reference const_reference;
+ using reference = typename std::vector<DataType>::reference;
+ using const_reference = typename std::vector<DataType>::const_reference;
+
reference operator[](size_type pos) { return Storage[pos]; }
const_reference operator[](size_type pos) const { return Storage[pos]; }
@@ -1456,6 +1463,7 @@ class list : public Option, public list_storage<DataType, StorageClass> {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
+
void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}
@@ -1476,6 +1484,7 @@ class list : public Option, public list_storage<DataType, StorageClass> {
size_t getOptionWidth() const override {
return Parser.getOptionWidth(*this);
}
+
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}
@@ -1595,6 +1604,7 @@ class bits : public Option, public bits_storage<DataType, Storage> {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
+
void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}
@@ -1615,6 +1625,7 @@ class bits : public Option, public bits_storage<DataType, Storage> {
size_t getOptionWidth() const override {
return Parser.getOptionWidth(*this);
}
+
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}
@@ -1827,9 +1838,9 @@ void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver,
/// \brief String tokenization function type. Should be compatible with either
/// Windows or Unix command line tokenizers.
-typedef void (*TokenizerCallback)(StringRef Source, StringSaver &Saver,
- SmallVectorImpl<const char *> &NewArgv,
- bool MarkEOLs);
+using TokenizerCallback = void (*)(StringRef Source, StringSaver &Saver,
+ SmallVectorImpl<const char *> &NewArgv,
+ bool MarkEOLs);
/// \brief Expand response files on a command line recursively using the given
/// StringSaver and tokenization strategy. Argv should contain the command line
@@ -1883,6 +1894,7 @@ void ResetAllOptionOccurrences();
void ResetCommandLineParser();
} // end namespace cl
+
} // end namespace llvm
#endif // LLVM_SUPPORT_COMMANDLINE_H
OpenPOWER on IntegriCloud