clang 23.0.0git
TransformationRegistry.h
Go to the documentation of this file.
1//===- TransformationRegistry.h ---------------------------------*- C++ -*-===//
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// Registry for Transformations, and some helper functions.
10// To register a transformation, insert this code:
11//
12// namespace clang::ssaf {
13// // NOLINTNEXTLINE(misc-use-internal-linkage)
14// volatile int MyTransformationAnchorSource = 0;
15// } // namespace clang::ssaf
16// static TransformationRegistry::Add<MyTransformation>
17// X("MyTransformation", "My awesome transformation");
18//
19// For a statically-linked transformation also extend the `AnchorSources`
20// list in
21// clang/include/clang/ScalableStaticAnalysisFramework/SSAFBuiltinForceLinker.h
22// (plugin-loaded transformations do not need an anchor — the dynamic loader
23// runs every global ctor on load).
24//
25//===----------------------------------------------------------------------===//
26
27#ifndef LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SOURCETRANSFORMATION_TRANSFORMATIONREGISTRY_H
28#define LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SOURCETRANSFORMATION_TRANSFORMATIONREGISTRY_H
29
35#include "llvm/ADT/StringRef.h"
36#include "llvm/Support/Registry.h"
37#include "llvm/Support/raw_ostream.h"
38#include <memory>
39
40namespace clang::ssaf {
41
42/// Check if a Transformation was registered with a given name.
43bool isTransformationRegistered(llvm::StringRef Name);
44
45/// Try to instantiate a Transformation with a given name.
46/// This might return null if the construction of the desired Transformation
47/// failed.
48/// It's a fatal error if there is no transformation registered with the name.
49std::unique_ptr<Transformation>
50makeTransformation(llvm::StringRef Name, const WPASuite &Suite,
51 SourceEditEmitter &Edits,
53
54/// Print the list of available Transformations.
55void printAvailableTransformations(llvm::raw_ostream &OS);
56
57// Registry for adding new Transformation implementations.
59 llvm::Registry<Transformation, const WPASuite &, SourceEditEmitter &,
61
62} // namespace clang::ssaf
63
64LLVM_DECLARE_REGISTRY(clang::ssaf::TransformationRegistry)
65
66#endif // LLVM_CLANG_SCALABLESTATICANALYSISFRAMEWORK_SOURCETRANSFORMATION_TRANSFORMATIONREGISTRY_H
Bundles the EntityIdTable (moved from the LUSummary) and the analysis results produced by one Analysi...
Definition WPASuite.h:37
void printAvailableTransformations(llvm::raw_ostream &OS)
Print the list of available Transformations.
llvm::Registry< Transformation, const WPASuite &, SourceEditEmitter &, TransformationReportEmitter & > TransformationRegistry
std::unique_ptr< Transformation > makeTransformation(llvm::StringRef Name, const WPASuite &Suite, SourceEditEmitter &Edits, TransformationReportEmitter &Report)
Try to instantiate a Transformation with a given name.
bool isTransformationRegistered(llvm::StringRef Name)
Check if a Transformation was registered with a given name.