clang
23.0.0git
include
clang
ScalableStaticAnalysisFramework
Core
SummaryData
SummaryDataBuilderRegistry.h
Go to the documentation of this file.
1
//===- SummaryDataBuilderRegistry.h -----------------------------*- C++ -*-===//
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
// Registry for SummaryDataBuilders.
10
//
11
// To register a builder, add a static Add<BuilderT> in the builder's
12
// translation unit:
13
//
14
// static SummaryDataBuilderRegistry::Add<MyDataBuilder>
15
// Registered("Data builder for MyAnalysis");
16
//
17
// The registry entry name is derived automatically from
18
// MyDataBuilder::summaryName(), which returns MyData::summaryName().
19
//
20
//===----------------------------------------------------------------------===//
21
22
#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_SUMMARYDATA_SUMMARYDATABUILDERREGISTRY_H
23
#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_SUMMARYDATA_SUMMARYDATABUILDERREGISTRY_H
24
25
#include "
clang/ScalableStaticAnalysisFramework/Core/SummaryData/SummaryDataBuilder.h
"
26
#include "llvm/Support/Registry.h"
27
#include <memory>
28
#include <string>
29
30
namespace
clang::ssaf
{
31
32
/// Registry for SummaryDataBuilder implementations.
33
///
34
/// Provides an Add helper that derives the registry entry name from
35
/// BuilderT::summaryName(), eliminating the possibility of registering a
36
/// builder under the wrong name.
37
class
SummaryDataBuilderRegistry {
38
using
RegistryT = llvm::Registry<SummaryDataBuilderBase>;
39
40
SummaryDataBuilderRegistry() =
delete
;
41
42
public
:
43
/// Registers \p BuilderT under the name returned by
44
/// \c BuilderT::summaryName(). Only a description is required.
45
///
46
/// \c Add objects must be declared \c static at namespace scope — they
47
/// register an entry in a global linked list on construction and are
48
/// not copyable or movable.
49
template
<
typename
BuilderT>
struct
Add
{
50
explicit
Add
(llvm::StringRef Desc)
51
: Name(BuilderT::summaryName().str().str()), Node(Name, Desc) {}
52
53
Add
(
const
Add
&) =
delete
;
54
Add
&
operator=
(
const
Add
&) =
delete
;
55
56
private
:
57
std::string Name;
58
RegistryT::Add<BuilderT> Node;
59
};
60
61
/// Returns true if a builder is registered under \p Name.
62
static
bool
contains
(llvm::StringRef Name);
63
64
/// Instantiates the builder registered under \p Name, or returns nullptr
65
/// if no such builder is registered.
66
static
std::unique_ptr<SummaryDataBuilderBase>
67
instantiate
(llvm::StringRef Name);
68
};
69
70
}
// namespace clang::ssaf
71
72
#endif
// LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_CORE_SUMMARYDATA_SUMMARYDATABUILDERREGISTRY_H
SummaryDataBuilder.h
clang::ssaf::SummaryDataBuilderRegistry::contains
static bool contains(llvm::StringRef Name)
Returns true if a builder is registered under Name.
Definition
SummaryDataBuilderRegistry.cpp:28
clang::ssaf::SummaryDataBuilderRegistry::instantiate
static std::unique_ptr< SummaryDataBuilderBase > instantiate(llvm::StringRef Name)
Instantiates the builder registered under Name, or returns nullptr if no such builder is registered.
Definition
SummaryDataBuilderRegistry.cpp:33
clang::ssaf
Definition
UnsafeBufferUsage.h:18
clang::ssaf::SummaryDataBuilderRegistry::Add::operator=
Add & operator=(const Add &)=delete
clang::ssaf::SummaryDataBuilderRegistry::Add::Add
Add(llvm::StringRef Desc)
Definition
SummaryDataBuilderRegistry.h:50
clang::ssaf::SummaryDataBuilderRegistry::Add::Add
Add(const Add &)=delete
Generated on
for clang by
1.14.0