1 //===- llvm/Support/Options.cpp - Debug options support ---------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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"
19 OptionRegistry::~OptionRegistry() {
20 for (auto IT
= Options
.begin(); IT
!= Options
.end(); ++IT
)
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
; }