1 //===- llvm/Support/Options.cpp - Debug options support ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Support/Options.h"
16 #include "llvm/Support/ManagedStatic.h"
20 OptionRegistry::~OptionRegistry() {
21 for (auto IT
= Options
.begin(); IT
!= Options
.end(); ++IT
)
25 void OptionRegistry::addOption(void *Key
, cl::Option
*O
) {
26 assert(Options
.find(Key
) == Options
.end() &&
27 "Argument with this key already registerd");
28 Options
.insert(std::make_pair(Key
, O
));
31 static ManagedStatic
<OptionRegistry
> OR
;
33 OptionRegistry
&OptionRegistry::instance() { return *OR
; }