clang 23.0.0git
AnalysisRegistry.cpp
Go to the documentation of this file.
1//===- AnalysisRegistry.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
11#include "llvm/ADT/STLExtras.h"
12
13using namespace clang;
14using namespace ssaf;
15
16using RegistryT = llvm::Registry<AnalysisBase>;
17
18// NOLINTNEXTLINE(misc-use-internal-linkage)
20LLVM_INSTANTIATE_REGISTRY(RegistryT)
21
22std::vector<AnalysisName> &AnalysisRegistry::getAnalysisNames() {
23 static std::vector<AnalysisName> Names;
24 return Names;
25}
26
28 return llvm::is_contained(getAnalysisNames(), Name);
29}
30
31const std::vector<AnalysisName> &AnalysisRegistry::names() {
32 return getAnalysisNames();
33}
34
37 for (const auto &Entry : RegistryT::entries()) {
38 if (Entry.getName() == Name.str()) {
39 return std::unique_ptr<AnalysisBase>(Entry.instantiate());
40 }
41 }
42 return ErrorBuilder::create(std::errc::invalid_argument,
43 "no analysis registered for '{0}'", Name)
44 .build();
45}
volatile int SSAFAnalysisRegistryAnchorSource
llvm::Registry< SummaryDataBuilderBase > RegistryT
Uniquely identifies a whole-program analysis and the AnalysisResult it produces.
llvm::StringRef str() const
Explicit conversion to the underlying string representation.
static bool contains(const AnalysisName &Name)
Returns true if an analysis is registered under Name.
static const std::vector< AnalysisName > & names()
Returns the names of all registered analyses.
static llvm::Expected< std::unique_ptr< AnalysisBase > > instantiate(const AnalysisName &Name)
Instantiates the analysis registered under Name, or returns an error if no such analysis is registere...
static ErrorBuilder create(std::error_code EC, const char *Fmt, Args &&...ArgVals)
Create an ErrorBuilder with an error code and formatted message.
llvm::Error build() const
Build and return the final error.
The JSON file list parser is used to communicate input to InstallAPI.