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
16namespace clang::ssaf {
17// NOLINTNEXTLINE(misc-use-internal-linkage)
19} // namespace clang::ssaf
20
21LLVM_DEFINE_REGISTRY(llvm::Registry<AnalysisBase>)
22
23std::vector<AnalysisName> &AnalysisRegistry::getAnalysisNames() {
24 static std::vector<AnalysisName> Names;
25 return Names;
26}
27
29 return llvm::is_contained(getAnalysisNames(), Name);
30}
31
32const std::vector<AnalysisName> &AnalysisRegistry::names() {
33 return getAnalysisNames();
34}
35
38 for (const auto &Entry : llvm::Registry<AnalysisBase>::entries()) {
39 if (Entry.getName() == Name.str()) {
40 return std::unique_ptr<AnalysisBase>(Entry.instantiate());
41 }
42 }
43 return ErrorBuilder::create(std::errc::invalid_argument,
44 "no analysis registered for '{0}'", Name)
45 .build();
46}
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.
volatile int AnalysisRegistryAnchorSource
The JSON file list parser is used to communicate input to InstallAPI.