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