souffle  2.0.2-371-g6315b36
RemoveEmptyRelations.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2015, 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 RemoveEmptyRelations.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ast/QualifiedName.h"
18 #include "ast/TranslationUnit.h"
20 #include <string>
21 
22 namespace souffle::ast::transform {
23 
24 /**
25  * Transformation pass to remove all empty relations and rules that use empty relations.
26  */
27 class RemoveEmptyRelationsTransformer : public Transformer {
28 public:
29  std::string getName() const override {
30  return "RemoveEmptyRelationsTransformer";
31  }
32 
33  /**
34  * Eliminate all empty relations (and their uses) in the given program.
35  *
36  * @param translationUnit the program to be processed
37  * @return whether the program was modified
38  */
39  static bool removeEmptyRelations(TranslationUnit& translationUnit);
40 
41  RemoveEmptyRelationsTransformer* clone() const override {
43  }
44 
45 private:
46  bool transform(TranslationUnit& translationUnit) override {
47  return removeEmptyRelations(translationUnit);
48  }
49 
50  /**
51  * Eliminate rules that contain empty relations and/or rewrite them.
52  *
53  * @param translationUnit the program to be processed
54  * @param emptyRelation relation that is empty
55  * @return whether the program was modified
56  */
57  static bool removeEmptyRelationUses(TranslationUnit& translationUnit, const QualifiedName& emptyRelation);
58 };
59 
60 } // namespace souffle::ast::transform
TranslationUnit.h
Transformer.h
souffle::ast::transform::RemoveEmptyRelationsTransformer
Transformation pass to remove all empty relations and rules that use empty relations.
Definition: RemoveEmptyRelations.h:31
souffle::ast::transform::RemoveEmptyRelationsTransformer::removeEmptyRelationUses
static bool removeEmptyRelationUses(TranslationUnit &translationUnit, const QualifiedName &emptyRelation)
Eliminate rules that contain empty relations and/or rewrite them.
Definition: RemoveEmptyRelations.cpp:75
souffle::ast::transform::RemoveEmptyRelationsTransformer::removeEmptyRelations
static bool removeEmptyRelations(TranslationUnit &translationUnit)
Eliminate all empty relations (and their uses) in the given program.
Definition: RemoveEmptyRelations.cpp:40
souffle::ast::transform::RemoveEmptyRelationsTransformer::clone
RemoveEmptyRelationsTransformer * clone() const override
Definition: RemoveEmptyRelations.h:49
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
souffle::ast::transform
Definition: Program.h:45
QualifiedName.h
souffle::ast::transform::RemoveEmptyRelationsTransformer::getName
std::string getName() const override
Definition: RemoveEmptyRelations.h:37
souffle::ast::QualifiedName
Qualified Name class defines fully/partially qualified names to identify objects in components.
Definition: QualifiedName.h:39
souffle::ast::transform::RemoveEmptyRelationsTransformer::transform
bool transform(TranslationUnit &translationUnit) override
Definition: RemoveEmptyRelations.h:54