Recommit r373598 "[yaml2obj/obj2yaml] - Add support for SHT_LLVM_ADDRSIG sections."
[llvm-complete.git] / lib / Support / Options.cpp
blob770b7381c20ee5d5c84f375ec771800b6920981a
1 //===- llvm/Support/Options.cpp - Debug options support ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the helper objects for defining debug options using the
10 // new API built on cl::opt, but not requiring the use of static globals.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/Options.h"
15 #include "llvm/Support/ManagedStatic.h"
17 using namespace llvm;
19 OptionRegistry::~OptionRegistry() {
20 for (auto IT = Options.begin(); IT != Options.end(); ++IT)
21 delete IT->second;
24 void OptionRegistry::addOption(void *Key, cl::Option *O) {
25 assert(Options.find(Key) == Options.end() &&
26 "Argument with this key already registerd");
27 Options.insert(std::make_pair(Key, O));
30 static ManagedStatic<OptionRegistry> OR;
32 OptionRegistry &OptionRegistry::instance() { return *OR; }