diff options
author | Craig Topper <craig.topper@gmail.com> | 2014-04-09 04:20:00 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2014-04-09 04:20:00 +0000 |
commit | 725011e72f7b6fa358d953cffbb63f218e20af8b (patch) | |
tree | b61db4fb01e1e0b56165db0b2702774f483d3d6a /lib/Support/CommandLine.cpp | |
parent | e4d89ec8de33c9ed3554dcc2b2391b7698dba1e3 (diff) | |
download | llvm-725011e72f7b6fa358d953cffbb63f218e20af8b.tar.gz llvm-725011e72f7b6fa358d953cffbb63f218e20af8b.tar.bz2 llvm-725011e72f7b6fa358d953cffbb63f218e20af8b.tar.xz |
[C++11] Replace some comparisons with 'nullptr' with simple boolean checks to reduce verbosity.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r-- | lib/Support/CommandLine.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 04a40b46f1..4777616b95 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -300,7 +300,7 @@ static inline bool ProvideOption(Option *Handler, StringRef ArgName, // Enforce value requirements switch (Handler->getValueExpectedFlag()) { case ValueRequired: - if (Value.data() == nullptr) { // No value specified? + if (!Value.data()) { // No value specified? if (i+1 >= argc) return Handler->error("requires a value!"); // Steal the next argument, like for '-o filename' @@ -400,7 +400,7 @@ static Option *HandlePrefixedOrGroupedOption(StringRef &Arg, StringRef &Value, // Do the lookup! size_t Length = 0; Option *PGOpt = getOptionPred(Arg, Length, isPrefixedOrGrouping, OptionsMap); - if (PGOpt == nullptr) return nullptr; + if (!PGOpt) return nullptr; // If the option is a prefixed option, then the value is simply the // rest of the name... so fall through to later processing, by @@ -770,7 +770,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv, // Calculate how many positional values are _required_. bool UnboundedFound = false; - for (size_t i = ConsumeAfterOpt != nullptr, e = PositionalOpts.size(); + for (size_t i = ConsumeAfterOpt ? 1 : 0, e = PositionalOpts.size(); i != e; ++i) { Option *Opt = PositionalOpts[i]; if (RequiresValue(Opt)) @@ -845,8 +845,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv, // All of the positional arguments have been fulfulled, give the rest to // the consume after option... if it's specified... // - if (PositionalVals.size() >= NumPositionalRequired && - ConsumeAfterOpt != nullptr) { + if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt) { for (++i; i < argc; ++i) PositionalVals.push_back(std::make_pair(argv[i],i)); break; // Handle outside of the argument processing loop... @@ -884,18 +883,18 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv, Handler = LookupOption(ArgName, Value, Opts); // Check to see if this "option" is really a prefixed or grouped argument. - if (Handler == nullptr) + if (!Handler) Handler = HandlePrefixedOrGroupedOption(ArgName, Value, ErrorParsing, Opts); // Otherwise, look for the closest available option to report to the user // in the upcoming error. - if (Handler == nullptr && SinkOpts.empty()) + if (!Handler && SinkOpts.empty()) NearestHandler = LookupNearestOption(ArgName, Opts, NearestHandlerString); } - if (Handler == nullptr) { + if (!Handler) { if (SinkOpts.empty()) { errs() << ProgramName << ": Unknown command line argument '" << argv[i] << "'. Try: '" << argv[0] << " -help'\n"; @@ -939,7 +938,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv, << " positional arguments: See: " << argv[0] << " -help\n"; ErrorParsing = true; - } else if (ConsumeAfterOpt == nullptr) { + } else if (!ConsumeAfterOpt) { // Positional args have already been handled if ConsumeAfter is specified. unsigned ValNo = 0, NumVals = static_cast<unsigned>(PositionalVals.size()); for (size_t i = 0, e = PositionalOpts.size(); i != e; ++i) { @@ -1044,7 +1043,7 @@ void cl::ParseCommandLineOptions(int argc, const char * const *argv, // bool Option::error(const Twine &Message, StringRef ArgName) { - if (ArgName.data() == nullptr) ArgName = ArgStr; + if (!ArgName.data()) ArgName = ArgStr; if (ArgName.empty()) errs() << HelpStr; // Be nice for positional arguments else @@ -1779,7 +1778,7 @@ void cl::SetVersionPrinter(void (*func)()) { } void cl::AddExtraVersionPrinter(void (*func)()) { - if (ExtraVersionPrinters == nullptr) + if (!ExtraVersionPrinters) ExtraVersionPrinters = new std::vector<void (*)()>; ExtraVersionPrinters->push_back(func); |