| 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 | |
| 11 | using namespace clang; |
| 12 | using namespace ssaf; |
| 13 | |
| 14 | using RegistryT = llvm::Registry<SummaryDataBuilderBase>; |
| 15 | LLVM_INSTANTIATE_REGISTRY(RegistryT) |
| 16 | |
| 17 | namespace { |
| 18 | const 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 | |
| 28 | bool SummaryDataBuilderRegistry::contains(llvm::StringRef Name) { |
| 29 | return findEntry(Name) != nullptr; |
| 30 | } |
| 31 | |
| 32 | std::unique_ptr<SummaryDataBuilderBase> |
| 33 | SummaryDataBuilderRegistry::instantiate(llvm::StringRef Name) { |
| 34 | const auto *Entry = findEntry(Name); |
| 35 | return Entry ? Entry->instantiate() : nullptr; |
| 36 | } |
| 37 |