Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/Support/CommandLine.h
Show All 24 Lines | |||||
#include "llvm/ADT/STLExtras.h" | #include "llvm/ADT/STLExtras.h" | ||||
#include "llvm/ADT/SmallPtrSet.h" | #include "llvm/ADT/SmallPtrSet.h" | ||||
#include "llvm/ADT/SmallVector.h" | #include "llvm/ADT/SmallVector.h" | ||||
#include "llvm/ADT/StringMap.h" | #include "llvm/ADT/StringMap.h" | ||||
#include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||
#include "llvm/ADT/Twine.h" | #include "llvm/ADT/Twine.h" | ||||
#include "llvm/ADT/iterator_range.h" | #include "llvm/ADT/iterator_range.h" | ||||
#include "llvm/Support/ErrorHandling.h" | #include "llvm/Support/ErrorHandling.h" | ||||
#include "llvm/Support/ManagedStatic.h" | |||||
#include "llvm/Support/raw_ostream.h" | #include "llvm/Support/raw_ostream.h" | ||||
#include <cassert> | #include <cassert> | ||||
#include <climits> | #include <climits> | ||||
#include <cstddef> | #include <cstddef> | ||||
#include <functional> | #include <functional> | ||||
#include <initializer_list> | #include <initializer_list> | ||||
#include <string> | #include <string> | ||||
#include <type_traits> | #include <type_traits> | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | public: | ||||
SmallVector<Option *, 4> PositionalOpts; | SmallVector<Option *, 4> PositionalOpts; | ||||
SmallVector<Option *, 4> SinkOpts; | SmallVector<Option *, 4> SinkOpts; | ||||
StringMap<Option *> OptionsMap; | StringMap<Option *> OptionsMap; | ||||
Option *ConsumeAfterOpt = nullptr; // The ConsumeAfter option if it exists. | Option *ConsumeAfterOpt = nullptr; // The ConsumeAfter option if it exists. | ||||
}; | }; | ||||
// A special subcommand representing no subcommand | |||||
extern ManagedStatic<SubCommand> TopLevelSubCommand; | |||||
// A special subcommand that can be used to put an option into all subcommands. | |||||
extern ManagedStatic<SubCommand> AllSubCommands; | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
class Option { | class Option { | ||||
friend class alias; | friend class alias; | ||||
// Overriden by subclasses to handle the value passed into an argument. Should | // Overriden by subclasses to handle the value passed into an argument. Should | ||||
// return true if there was an error processing the argument and the program | // return true if there was an error processing the argument and the program | ||||
// should exit. | // should exit. | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | explicit Option(enum NumOccurrencesFlag OccurrencesFlag, | ||||
HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), | HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), | ||||
FullyInitialized(false), Position(0), AdditionalVals(0) { | FullyInitialized(false), Position(0), AdditionalVals(0) { | ||||
Categories.push_back(&getGeneralCategory()); | Categories.push_back(&getGeneralCategory()); | ||||
} | } | ||||
inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } | inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } | ||||
public: | public: | ||||
virtual ~Option() = default; | virtual ~Option() { | ||||
if (FullyInitialized) | |||||
removeArgument(); | |||||
} | |||||
// Register this argument with the commandline system. | // Register this argument with the commandline system. | ||||
// | // | ||||
void addArgument(); | void addArgument(); | ||||
/// Unregisters this option from the CommandLine system. | /// Unregisters this option from the CommandLine system. | ||||
/// | |||||
/// This option must have been the last option registered. | |||||
/// For testing purposes only. | |||||
void removeArgument(); | void removeArgument(); | ||||
efriedma: "This option must have been the last option registered. For testing purposes only."
Is this… | |||||
Thanks for spotting that. I did look into that when I wrote the code and the comment looks outdated to me. I've also been using these patches for a while now and this doesn't appear to be an issue in practice. I'm going to remove the comment. nhaehnle: Thanks for spotting that. I did look into that when I wrote the code and the comment looks… | |||||
// Return the width of the option tag for printing... | // Return the width of the option tag for printing... | ||||
virtual size_t getOptionWidth() const = 0; | virtual size_t getOptionWidth() const = 0; | ||||
// Print out information about this option. The to-be-maintained width is | // Print out information about this option. The to-be-maintained width is | ||||
// specified. | // specified. | ||||
// | // | ||||
virtual void printOptionInfo(size_t GlobalWidth) const = 0; | virtual void printOptionInfo(size_t GlobalWidth) const = 0; | ||||
▲ Show 20 Lines • Show All 1,797 Lines • Show Last 20 Lines |
"This option must have been the last option registered. For testing purposes only."
Is this still accurate? Is it an issue here?