blob: 770b7381c20ee5d5c84f375ec771800b6920981a [file] [log] [blame]
Chris Bieneman732e0aa2014-10-15 21:54:35 +00001//===- llvm/Support/Options.cpp - Debug options support ---------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Chris Bieneman732e0aa2014-10-15 21:54:35 +00006//
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.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Support/Options.h"
15#include "llvm/Support/ManagedStatic.h"
16
17using namespace llvm;
18
19OptionRegistry::~OptionRegistry() {
20 for (auto IT = Options.begin(); IT != Options.end(); ++IT)
21 delete IT->second;
22}
23
24void 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));
28}
29
30static ManagedStatic<OptionRegistry> OR;
31
32OptionRegistry &OptionRegistry::instance() { return *OR; }