Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style and include fixes #2

Merged
merged 3 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/AnalysisType.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

#include "AstType.h"
#include "Util.h"
#include <algorithm>
#include <cassert>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>

namespace souffle {

Expand Down Expand Up @@ -151,7 +158,7 @@ class InnerAnalysisType : public AnalysisType {
// each inner type belongs to a separate sublattice, depending on the kind
virtual Kind getKind() const = 0;

virtual InnerAnalysisType* clone() const = 0;
InnerAnalysisType* clone() const override = 0;
};

/** A top primitive in a lattice, just below the top element */
Expand Down Expand Up @@ -289,7 +296,7 @@ class BottomPrimitiveAnalysisType : public InnerAnalysisType {
/** A base type in the lattice, just above the bottom primitives */
class BaseAnalysisType : public InnerAnalysisType {
public:
BaseAnalysisType(Kind kind, AstTypeIdentifier name) : kind(kind), name(name) {}
BaseAnalysisType(Kind kind, AstTypeIdentifier name) : kind(kind), name(std::move(name)) {}
BaseAnalysisType(const BaseAnalysisType&) = default;
BaseAnalysisType(BaseAnalysisType&&) = default;

Expand Down
2 changes: 1 addition & 1 deletion src/AstArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ class AstRecordInit : public AstArgument {
public:
AstRecordInit() = default;

AstRecordInit(const AstTypeIdentifier& type) : type(type) {}
AstRecordInit(AstTypeIdentifier type) : type(std::move(type)) {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this preferred? Just better style or?


~AstRecordInit() override = default;

Expand Down
1 change: 1 addition & 0 deletions src/AstGroundAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "AstClause.h"
#include "AstConstraintAnalysis.h"
#include "AstLiteral.h"
#include "AstNode.h"
#include "BinaryConstraintOps.h"
#include "Constraints.h"
#include "Util.h"
Expand Down
3 changes: 3 additions & 0 deletions src/AstIOTypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

#include "AstIOTypeAnalysis.h"
#include "AstIO.h"
#include "AstProgram.h"
#include "AstRelation.h"
#include "AstTranslationUnit.h"
#include "AstVisitor.h"
#include "Util.h"
#include <ostream>

namespace souffle {

Expand Down
4 changes: 2 additions & 2 deletions src/AstNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#include "SrcLocation.h"
#include "Util.h"

#include <cstddef>
#include <cstring>
#include <limits>
#include <memory>
#include <typeinfo>

#include <cstddef>
#include <cstring>
#include <libgen.h>
#include <unistd.h>

Expand Down
2 changes: 2 additions & 0 deletions src/AstProfileUse.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

namespace souffle {

class AstTranslationUnit;

/**
* AstAnalysis that loads profile data and has a profile query interface.
*/
Expand Down
7 changes: 1 addition & 6 deletions src/AstProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#pragma once

#include "AstClause.h"
#include "AstComponent.h"
#include "AstFunctorDeclaration.h"
#include "AstIO.h"
Expand All @@ -37,12 +38,6 @@

namespace souffle {

class AstClause;
class AstLoad;
class AstPrintSize;
class AstStore;
class AstRelation;

/**
* Intermediate representation of a datalog program
* that consists of relations, clauses and types
Expand Down
3 changes: 3 additions & 0 deletions src/AstSemanticChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
***********************************************************************/

#include "AstSemanticChecker.h"
#include "AnalysisType.h"
#include "AstArgument.h"
#include "AstAttribute.h"
#include "AstClause.h"
#include "AstFunctorDeclaration.h"
#include "AstGroundAnalysis.h"
#include "AstIO.h"
#include "AstIOTypeAnalysis.h"
#include "AstLiteral.h"
#include "AstNode.h"
#include "AstProgram.h"
Expand All @@ -46,6 +48,7 @@
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
Expand Down
3 changes: 1 addition & 2 deletions src/AstSemanticChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

#pragma once

#include "AstArgument.h"
#include "AstTransformer.h"
#include <string>

namespace souffle {

class AstAggregator;
class AstArgument;
class AstAtom;
class AstClause;
class AstLiteral;
Expand Down
9 changes: 6 additions & 3 deletions src/AstTransforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
***********************************************************************/

#include "AstTransforms.h"
#include "AnalysisType.h"
#include "AstAttribute.h"
#include "AstClause.h"
#include "AstIOTypeAnalysis.h"
#include "AstLiteral.h"
#include "AstNode.h"
#include "AstProgram.h"
#include "AstRelation.h"
#include "AstRelationIdentifier.h"
#include "AstTranslationUnit.h"
#include "AstTypeAnalysis.h"
#include "AstTypeEnvironmentAnalysis.h"
#include "AstTypes.h"
#include "AstUtils.h"
#include "AstVisitor.h"
#include "BinaryConstraintOps.h"
#include "GraphUtils.h"
#include "PrecedenceGraph.h"
#include "TypeLattice.h"
#include "TypeSystem.h"
#include <cassert>
#include <cstddef>
#include <functional>
#include <map>
Expand All @@ -41,6 +42,8 @@

namespace souffle {

class TypeLattice;

bool NullTransformer::transform(AstTranslationUnit& translationUnit) {
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/AstTransforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "AstArgument.h"
#include "AstTransformer.h"
#include "AstTranslationUnit.h"
#include "DebugReport.h"
#include "Util.h"
#include <functional>
Expand All @@ -31,8 +30,8 @@
namespace souffle {

class AstClause;
class AstProgram;
class AstRelation;
class AstTranslationUnit;

/**
* Transformation pass to eliminate grounded aliases.
Expand Down
7 changes: 2 additions & 5 deletions src/AstTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@
#include <cassert>
#include <chrono>
#include <cstddef>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <set>
#include <typeinfo>
#include <sstream>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -753,7 +750,7 @@ std::unique_ptr<RamStatement> AstTranslator::ClauseTranslator::translateClause(

// translate arguments's of atom (if exists) to conditions
if (atom != nullptr) {
for (size_t pos = 0; pos < atom->argSize(); ++pos) {
for (size_t pos = 0; pos < atom->getArguments().size(); ++pos) {
// variable bindings are issued differently since we don't want self
// referential variable bindings
if (const auto* var = dynamic_cast<const AstVariable*>(atom->getArgument(pos))) {
Expand Down
1 change: 1 addition & 0 deletions src/AstTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <set>
#include <string>
#include <utility>
#include <vector>

namespace souffle {

Expand Down
40 changes: 26 additions & 14 deletions src/AstTypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@
***********************************************************************/

#include "AstTypeAnalysis.h"
#include "AstArgument.h"
#include "AstAttribute.h"
#include "AstClause.h"
#include "AstFunctorDeclaration.h"
#include "AstLiteral.h"
#include "AstProgram.h"
#include "AstRelation.h"
#include "AstTranslationUnit.h"
#include "AstType.h"
#include "AstTypeEnvironmentAnalysis.h"
#include "AstVisitor.h"
#include "BinaryConstraintOps.h"
#include "FunctorOps.h"
#include "Global.h"
#include "TypeConstraint.h"
#include "TypeSystem.h"
#include <ostream>

namespace souffle {
Expand All @@ -30,38 +42,38 @@ void TypeSolver::generateConstraints() {
ConstraintFinder(const AstProgram* program, const TypeLattice* lattice, TypeSolver* solver)
: program(program), lattice(lattice), solver(solver) {}

void visitNode(const AstNode& node) {
void visitNode(const AstNode& node) override {
// by default, extract the constraints generated by all children
for (const AstNode* child : node.getChildNodes()) {
visit(*child);
}
}

void visitCounter(const AstCounter& counter) {
void visitCounter(const AstCounter& counter) override {
// counters must be numbers
solver->addConstraint(std::make_unique<FixedConstraint>(
&counter, std::make_unique<ConstantAnalysisType>(Kind::NUMBER)));
}

void visitNumberConstant(const AstNumberConstant& constant) {
void visitNumberConstant(const AstNumberConstant& constant) override {
// number constants must actually be numbers
solver->addConstraint(std::make_unique<FixedConstraint>(
&constant, std::make_unique<ConstantAnalysisType>(Kind::NUMBER)));
}

void visitStringConstant(const AstStringConstant& constant) {
void visitStringConstant(const AstStringConstant& constant) override {
// string constants must actually be strings
solver->addConstraint(std::make_unique<FixedConstraint>(
&constant, std::make_unique<ConstantAnalysisType>(Kind::SYMBOL)));
}

void visitNullConstant(const AstNullConstant& constant) {
void visitNullConstant(const AstNullConstant& constant) override {
// nils must be record types
solver->addConstraint(std::make_unique<FixedConstraint>(
&constant, std::make_unique<ConstantAnalysisType>(Kind::RECORD)));
}

void visitTypeCast(const AstTypeCast& cast) {
void visitTypeCast(const AstTypeCast& cast) override {
// extract child constraints
visitNode(cast);

Expand All @@ -71,7 +83,7 @@ void TypeSolver::generateConstraints() {
std::make_unique<FixedConstraint>(&cast, std::unique_ptr<AnalysisType>(type->clone())));
}

void visitIntrinsicFunctor(const AstIntrinsicFunctor& functor) {
void visitIntrinsicFunctor(const AstIntrinsicFunctor& functor) override {
// extract child constraints
visitNode(functor);

Expand Down Expand Up @@ -116,7 +128,7 @@ void TypeSolver::generateConstraints() {
}
}

void visitUserDefinedFunctor(const AstUserDefinedFunctor& functor) {
void visitUserDefinedFunctor(const AstUserDefinedFunctor& functor) override {
// extract child constraints
visitNode(functor);

Expand Down Expand Up @@ -156,7 +168,7 @@ void TypeSolver::generateConstraints() {
solver->addConstraint(std::move(constantConstraint));
}

void visitRecordInit(const AstRecordInit& record) {
void visitRecordInit(const AstRecordInit& record) override {
// extract child constraints
visitNode(record);

Expand Down Expand Up @@ -215,7 +227,7 @@ void TypeSolver::generateConstraints() {
solver->addConstraint(std::move(finalConstraint));
}

void visitAggregator(const AstAggregator& aggregate) {
void visitAggregator(const AstAggregator& aggregate) override {
// extract child constraints
visitNode(aggregate);

Expand All @@ -236,7 +248,7 @@ void TypeSolver::generateConstraints() {
}
}

void visitAtom(const AstAtom& atom) {
void visitAtom(const AstAtom& atom) override {
// extract child constraints
visitNode(atom);

Expand All @@ -252,12 +264,12 @@ void TypeSolver::generateConstraints() {
}
}

void visitNegation(const AstNegation& negation) {
void visitNegation(const AstNegation& negation) override {
// only extract child constraints of the internal atom
return visitNode(*negation.getAtom());
}

void visitBinaryConstraint(const AstBinaryConstraint& binary) {
void visitBinaryConstraint(const AstBinaryConstraint& binary) override {
// extract child constraints
visitNode(binary);

Expand All @@ -270,7 +282,7 @@ void TypeSolver::generateConstraints() {
}
}

void visitClause(const AstClause& clause) {
void visitClause(const AstClause& clause) override {
// get constraints from body literals only
for (const AstLiteral* literal : clause.getBodyLiterals()) {
visit(*literal);
Expand Down
Loading