Options.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. //===- llvm/Support/Options.cpp - Debug options support ---------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file implements the helper objects for defining debug options using the
  11. // new API built on cl::opt, but not requiring the use of static globals.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #include "llvm/Support/Options.h"
  15. #include "llvm/Support/ManagedStatic.h"
  16. using namespace llvm;
  17. OptionRegistry::~OptionRegistry() {
  18. for (auto IT = Options.begin(); IT != Options.end(); ++IT)
  19. delete IT->second;
  20. }
  21. void OptionRegistry::addOption(void *Key, cl::Option *O) {
  22. assert(Options.find(Key) == Options.end() &&
  23. "Argument with this key already registerd");
  24. Options.insert(std::make_pair(Key, O));
  25. }
  26. static ManagedStatic<OptionRegistry> OR;
  27. OptionRegistry &OptionRegistry::instance() { return *OR; }