1//===- SerializationFormatRegistry.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/Serialization/SerializationFormatRegistry.h"
10#include <memory>
11
12using namespace clang;
13using namespace ssaf;
14
15LLVM_INSTANTIATE_REGISTRY(SerializationFormatRegistry)
16
17bool ssaf::isFormatRegistered(llvm::StringRef FormatName) {
18 for (const auto &Entry : SerializationFormatRegistry::entries())
19 if (Entry.getName() == FormatName)
20 return true;
21 return false;
22}
23
24std::unique_ptr<SerializationFormat>
25ssaf::makeFormat(llvm::StringRef FormatName) {
26 for (const auto &Entry : SerializationFormatRegistry::entries())
27 if (Entry.getName() == FormatName)
28 return Entry.instantiate();
29 assert(false && "Unknown SerializationFormat name");
30 return nullptr;
31}
32
33void ssaf::printAvailableFormats(llvm::raw_ostream &OS) {
34 OS << "OVERVIEW: Available SSAF serialization formats:\n\n";
35 for (const auto &Entry : SerializationFormatRegistry::entries())
36 OS << " " << Entry.getName() << " - " << Entry.getDesc() << "\n";
37}
38