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 // Indexing libraries registered since the last parse is not thread-safe.
33
34 // Parses the option of L that Args[0] spells, keeping the other values.
36 unsigned &Consumed);
37
38 // The arguments assigned so far.
39 ArrayRef<const char *> args() const { return SavedArgs; }
40
41 // T's values, or T::Default if none of its options is parsed.
42 template <typename T> const T &get() const {
43 auto It = Values.find(&T::Default);
44 return It == Values.end() ? T::Default
45 : *static_cast<const T *>(It->second);
46 }
47
48 // C's values of T, or T::Global if C is null.
49 template <typename T> static const T &get(const LibraryOptionsContext *C) {
50 return C ? C->get<T>() : T::Global;
51 }
52
53private:
57};
58
59} // namespace cl
60} // namespace llvm
61
62#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:211
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.
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