souffle  2.0.2-371-g6315b36
RecursiveClauses.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file RecursiveClauses.h
12  *
13  * Defines the class to build the precedence graph,
14  * compute strongly connected components of the precedence graph, and
15  * build the strongly connected component graph.
16  *
17  ***********************************************************************/
18 
19 #pragma once
20 
21 #include "ast/analysis/Analysis.h"
22 #include <iostream>
23 #include <set>
24 #include <string>
25 
26 namespace souffle::ast {
27 
28 class Clause;
29 class TranslationUnit;
30 
31 namespace analysis {
32 
33 /**
34  * Analysis pass identifying clauses which are recursive.
35  */
36 class RecursiveClausesAnalysis : public Analysis {
37 public:
38  static constexpr const char* name = "recursive-clauses";
39 
41 
42  void run(const TranslationUnit& translationUnit) override;
43 
44  void print(std::ostream& os) const override;
45 
46  bool recursive(const Clause* clause) const {
47  return recursiveClauses.count(clause) != 0u;
48  }
49 
50 private:
51  std::set<const Clause*> recursiveClauses;
52 
53  /** Determines whether the given clause is recursive within the given program */
54  bool computeIsRecursive(const Clause& clause, const TranslationUnit& translationUnit) const;
55 };
56 
57 } // namespace analysis
58 } // namespace souffle::ast
souffle::ast::analysis::Analysis::Analysis
Analysis(std::string identifier)
Definition: Analysis.h:40
souffle::ast::analysis::RecursiveClausesAnalysis::run
void run(const TranslationUnit &translationUnit) override
run analysis for a Ast translation unit
Definition: RecursiveClauses.cpp:45
souffle::ast::Clause
Intermediate representation of a horn clause.
Definition: Clause.h:51
souffle::ast::analysis::RecursiveClausesAnalysis::computeIsRecursive
bool computeIsRecursive(const Clause &clause, const TranslationUnit &translationUnit) const
Determines whether the given clause is recursive within the given program.
Definition: RecursiveClauses.cpp:58
souffle::ast::analysis::RecursiveClausesAnalysis::RecursiveClausesAnalysis
RecursiveClausesAnalysis()
Definition: RecursiveClauses.h:48
souffle::ast::analysis::RecursiveClausesAnalysis::recursiveClauses
std::set< const Clause * > recursiveClauses
Definition: RecursiveClauses.h:59
souffle::ast::analysis::RecursiveClausesAnalysis::print
void print(std::ostream &os) const override
print the analysis result in HTML format
Definition: RecursiveClauses.cpp:54
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::analysis::RecursiveClausesAnalysis::recursive
bool recursive(const Clause *clause) const
Definition: RecursiveClauses.h:54
souffle::ast
Definition: Aggregator.h:35
Analysis.h
souffle::ast::analysis::RecursiveClausesAnalysis::name
static constexpr const char * name
Definition: RecursiveClauses.h:46