LLVM 24.0.0git
LibraryOptionsContext.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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#ifndef LLVM_SUPPORT_LIBRARYOPTIONSCONTEXT_H
10#define LLVM_SUPPORT_LIBRARYOPTIONSCONTEXT_H
11
12#include "llvm/ADT/ArrayRef.h"
13#include "llvm/ADT/DenseMap.h"
17
18namespace llvm {
19
20class Error;
21
22namespace cl {
23
24class LibraryOptions;
25
26// The library options of one compilation context, such as an LLVMContext.
27// Libraries declared with perContext read their options here.
29public:
30 // Replaces the library options with Other's by replaying its arguments.
31 //
32 // A library's values start as a copy of its global(), which may refer to
33 // strings that ResetAllOptionOccurrences frees.
34 // Indexing libraries registered since the last parse is not thread-safe.
36
37 // Parses the option of L that Args[0] spells, keeping the other values.
39 unsigned &Consumed);
40
41 // The arguments assigned so far.
42 ArrayRef<const char *> args() const { return SavedArgs; }
43
44 // T's values, or T::Global if there are none.
45 template <typename T> const T &get() const {
46 if (const void *Opts = Values.lookup(&T::Global))
47 return *static_cast<const T *>(Opts);
48 // TODO: Return the defaults once cl::ParseCommandLineOptions callers have
49 // migrated to parseCommandLineOptions and no longer set T::Global.
50 return T::Global;
51 }
52
53 // C's values of T, or T::Global if C is null.
54 template <typename T> static const T &get(const LibraryOptionsContext *C) {
55 return C ? C->get<T>() : T::Global;
56 }
57
58private:
62};
63
64} // namespace cl
65} // namespace llvm
66
67#endif // LLVM_SUPPORT_LIBRARYOPTIONSCONTEXT_H
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition Compiler.h:215
This file defines the DenseMap class.
static llvm::Error parse(GsymDataExtractor &Data, uint64_t BaseAddr, LineEntryCallback const &Callback)
Definition LineTable.cpp:54
#define T
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
ArrayRef< const char * > args() const
void assign(const LibraryOptionsContext &Other)
static const T & get(const LibraryOptionsContext *C)
The options of a library that declares them in TableGen rather than as cl::opt (see llvm/Option/Libra...
This namespace contains all of the command line option processing machinery.
Definition LLVMContext.h:35
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
@ Other
Any other memory.
Definition ModRef.h:68
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391