| 1 | //===- TransformationRegistry.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/ScalableStaticAnalysis/SourceTransformation/TransformationRegistry.h" |
| 10 | #include <memory> |
| 11 | |
| 12 | using namespace clang; |
| 13 | using namespace ssaf; |
| 14 | |
| 15 | namespace clang::ssaf { |
| 16 | // NOLINTNEXTLINE(misc-use-internal-linkage) |
| 17 | volatile int SSAFSourceTransformationAnchorSource = 0; |
| 18 | } // namespace clang::ssaf |
| 19 | |
| 20 | LLVM_DEFINE_REGISTRY(clang::ssaf::TransformationRegistry) |
| 21 | |
| 22 | bool ssaf::isTransformationRegistered(llvm::StringRef Name) { |
| 23 | for (const auto &Entry : TransformationRegistry::entries()) |
| 24 | if (Entry.getName() == Name) |
| 25 | return true; |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | std::unique_ptr<Transformation> |
| 30 | ssaf::makeTransformation(llvm::StringRef Name, const WPASuite &Suite, |
| 31 | SourceEditEmitter &Edits, |
| 32 | TransformationReportEmitter &Report) { |
| 33 | for (const auto &Entry : TransformationRegistry::entries()) |
| 34 | if (Entry.getName() == Name) |
| 35 | return Entry.instantiate(Params: Suite, Params&: Edits, Params&: Report); |
| 36 | assert(false && "Unknown Transformation name"); |
| 37 | return nullptr; |
| 38 | } |
| 39 | |
| 40 | void ssaf::printAvailableTransformations(llvm::raw_ostream &OS) { |
| 41 | OS << "OVERVIEW: Available SSAF source transformations:\n\n"; |
| 42 | for (const auto &Entry : TransformationRegistry::entries()) |
| 43 | OS << " "<< Entry.getName() << " - "<< Entry.getDesc() << "\n"; |
| 44 | } |
| 45 |