souffle  2.0.2-371-g6315b36
RemoveRedundantRelations.cpp
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 RemoveRedundantRelations.cpp
12  *
13  ***********************************************************************/
14 
16 #include "ast/Relation.h"
17 #include "ast/TranslationUnit.h"
19 #include "ast/utility/Utils.h"
20 #include <set>
21 
22 namespace souffle::ast::transform {
23 
24 bool RemoveRedundantRelationsTransformer::transform(TranslationUnit& translationUnit) {
25  bool changed = false;
26  auto* redundantRelationsAnalysis = translationUnit.getAnalysis<analysis::RedundantRelationsAnalysis>();
27  const std::set<const Relation*>& redundantRelations = redundantRelationsAnalysis->getRedundantRelations();
28  if (!redundantRelations.empty()) {
29  for (auto rel : redundantRelations) {
30  removeRelation(translationUnit, rel->getQualifiedName());
31  changed = true;
32  }
33  }
34  return changed;
35 }
36 
37 } // namespace souffle::ast::transform
TranslationUnit.h
souffle::ast::removeRelation
void removeRelation(TranslationUnit &tu, const QualifiedName &name)
Remove relation and all its clauses from the program.
Definition: Utils.cpp:105
RemoveRedundantRelations.h
Relation.h
Utils.h
souffle::ast::transform::RemoveRedundantRelationsTransformer::transform
bool transform(TranslationUnit &translationUnit) override
Definition: RemoveRedundantRelations.cpp:28
RedundantRelations.h
souffle::ast::transform
Definition: Program.h:45
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086