1//===- SummaryDataBuilderRegistry.cpp -------------------------------------===//
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#include "clang/ScalableStaticAnalysisFramework/Core/SummaryData/SummaryDataBuilderRegistry.h"
10
11using namespace clang;
12using namespace ssaf;
13
14using RegistryT = llvm::Registry<SummaryDataBuilderBase>;
15LLVM_INSTANTIATE_REGISTRY(RegistryT)
16
17namespace {
18const RegistryT::entry *findEntry(llvm::StringRef Name) {
19 for (const auto &Entry : RegistryT::entries()) {
20 if (Entry.getName() == Name) {
21 return &Entry;
22 }
23 }
24 return nullptr;
25}
26} // namespace
27
28bool SummaryDataBuilderRegistry::contains(llvm::StringRef Name) {
29 return findEntry(Name) != nullptr;
30}
31
32std::unique_ptr<SummaryDataBuilderBase>
33SummaryDataBuilderRegistry::instantiate(llvm::StringRef Name) {
34 const auto *Entry = findEntry(Name);
35 return Entry ? Entry->instantiate() : nullptr;
36}
37