Skip to content

Commit 066a4cc

Browse files
committed
Fix some clang tidy warnings
Mostly adding noexcept to some move assignments/ctors so they are utilized by STL. Also adding some std::move calls to avoid certain potentially expensive copies. Some misc fixes/improvements including fixing typos in comments.
1 parent 9ac6b24 commit 066a4cc

50 files changed

Lines changed: 130 additions & 134 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/ast/Constraint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Constraint : public Literal {
2828
public:
2929
using Literal::Literal;
3030

31-
Constraint(NodeKind kind, SrcLocation loc = {}) : Literal(kind, loc) {
31+
Constraint(NodeKind kind, SrcLocation loc = {}) : Literal(kind, std::move(loc)) {
3232
assert(kind >= NK_Constraint && kind < NK_LastConstraint);
3333
}
3434

src/ast/Functor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Functor : public Term {
2929
protected:
3030
using Term::Term;
3131

32-
Functor(NodeKind kind, SrcLocation loc = {}) : Term(kind, loc) {
32+
Functor(NodeKind kind, SrcLocation loc = {}) : Term(kind, std::move(loc)) {
3333
assert(kind > NK_FirstFunctor && kind < NK_LastFunctor);
3434
}
3535

src/ast/Lattice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void Lattice::setQualifiedName(QualifiedName name) {
4242
this->name = std::move(name);
4343
}
4444

45-
const std::map<LatticeOperator, const ast::Argument*> Lattice::getOperators() const {
45+
std::map<LatticeOperator, const ast::Argument*> Lattice::getOperators() const {
4646
std::map<LatticeOperator, const ast::Argument*> ops;
4747
for (const auto& [op, arg] : operators) {
4848
ops.emplace(std::make_pair(op, arg.get()));

src/ast/Lattice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Lattice : public Node {
4747
/** Set type name */
4848
void setQualifiedName(QualifiedName name);
4949

50-
const std::map<LatticeOperator, const ast::Argument*> getOperators() const;
50+
std::map<LatticeOperator, const ast::Argument*> getOperators() const;
5151

5252
bool hasGlb() const;
5353
bool hasLub() const;

src/ast/Literal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Literal : public Node {
3131
public:
3232
using Node::Node;
3333

34-
explicit Literal(NodeKind kind, SrcLocation loc = {}) : Node(kind, loc) {
34+
explicit Literal(NodeKind kind, SrcLocation loc = {}) : Node(kind, std::move(loc)) {
3535
assert(kind >= NK_Literal && kind < NK_LastLiteral);
3636
}
3737

src/ast/UnnamedVariable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace souffle::ast {
1313

14-
UnnamedVariable::UnnamedVariable(SrcLocation loc) : Argument(NK_UnnamedVariable, loc) {}
14+
UnnamedVariable::UnnamedVariable(SrcLocation loc) : Argument(NK_UnnamedVariable, std::move(loc)) {}
1515

1616
void UnnamedVariable::print(std::ostream& os) const {
1717
os << "_";

src/ast/UserDefinedAggregator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace souffle::ast {
2020
UserDefinedAggregator::UserDefinedAggregator(
2121
std::string name, Own<Argument> init, Own<Argument> expr, VecOwn<Literal> body, SrcLocation loc)
22-
: Aggregator(NK_UserDefinedAggregator, std::move(expr), std::move(body), std::move(loc)), name(name),
22+
: Aggregator(NK_UserDefinedAggregator, std::move(expr), std::move(body), std::move(loc)), name(std::move(name)),
2323
initValue(std::move(init)) {}
2424

2525
void UserDefinedAggregator::apply(const NodeMapper& map) {

src/ast/analysis/Aggregate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ std::set<std::string> getWitnessVariables(
105105
M update;
106106
aggregatorlessClause->apply(update);
107107
auto groundingAtom = mk<Atom>(QualifiedName::fromString("+grounding_atom"));
108-
for (std::string variableName : update.getAggregatorVariables()) {
108+
for (const std::string& variableName : update.getAggregatorVariables()) {
109109
groundingAtom->addArgument(mk<Variable>(variableName));
110110
}
111111
aggregatorlessClause->addToBody(std::move(groundingAtom));
@@ -163,7 +163,7 @@ std::set<std::string> getVariablesOutsideAggregate(const Clause& clause, const A
163163
return variablesOutsideAggregate;
164164
}
165165

166-
std::string findUniqueVariableName(const Clause& clause, std::string base) {
166+
std::string findUniqueVariableName(const Clause& clause, const std::string& base) {
167167
std::set<std::string> variablesInClause;
168168
visit(clause, [&](const Variable& v) { variablesInClause.insert(v.getName()); });
169169
int varNum = 0;
@@ -174,7 +174,7 @@ std::string findUniqueVariableName(const Clause& clause, std::string base) {
174174
return candidate;
175175
}
176176

177-
std::string findUniqueRelationName(const Program& program, std::string base) {
177+
std::string findUniqueRelationName(const Program& program, const std::string& base) {
178178
int counter = 0;
179179
auto candidate = base;
180180
while (program.getRelation(QualifiedName::fromString(candidate)) != nullptr) {
@@ -331,7 +331,7 @@ std::set<std::string> getInjectedVariables(
331331
tweakedClause->apply(update);
332332
// the update will now tell us which variables we need to ground!
333333
auto groundingAtom = mk<Atom>(QualifiedName::fromString("+grounding_atom"));
334-
for (std::string variableName : update.getAggregatorVariables()) {
334+
for (const std::string& variableName : update.getAggregatorVariables()) {
335335
groundingAtom->addArgument(mk<Variable>(variableName));
336336
}
337337
// add the newly created grounding atom to the body

src/ast/analysis/IOType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class IOTypeAnalysis : public Analysis {
6060
auto iter = limitSize.find(relation);
6161
if (iter != limitSize.end()) {
6262
return (*iter).second;
63-
} else
64-
return 0;
63+
}
64+
return 0;
6565
}
6666

6767
bool isIO(const Relation* relation) const {

src/ast/analysis/typesystem/TypeSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ struct RecordType : public Type {
311311

312312
protected:
313313
RecordType(const TypeEnvironment& environment, const QualifiedName& name,
314-
const std::vector<const Type*> fields = {})
315-
: Type(TK_RecordType, environment, name), fields(fields) {}
314+
std::vector<const Type*> fields = {})
315+
: Type(TK_RecordType, environment, name), fields(std::move(fields)) {}
316316

317317
private:
318318
friend class TypeEnvironment;

0 commit comments

Comments
 (0)