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

some missing nodiscard expressions #1056

Merged
merged 1 commit into from
Apr 9, 2024
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
2 changes: 1 addition & 1 deletion examples/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool with_program_serialized ( F callback, ProgramPtr program ) {
program.reset();
// deserialize
AstSerializer deser ( ForReading{} );
deser.buffer = move(ser.buffer);
deser.buffer = das::move(ser.buffer);
auto new_program = make_smart<Program>();
new_program->serialize(deser);
program = new_program;
Expand Down
39 changes: 39 additions & 0 deletions src/ast/ast_infer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,12 @@ namespace das {
return Visitor::visit(expr);
}
// ExprStaticAssert
virtual void preVisit ( ExprStaticAssert * expr ) override {
Visitor::preVisit(expr);
for ( auto & arg : expr->arguments ) {
markNoDiscard(arg.get());
}
}
virtual ExpressionPtr visit ( ExprStaticAssert * expr ) override {
if ( expr->argumentsFailedToInfer ) return Visitor::visit(expr);
if ( expr->arguments.size()<1 || expr->arguments.size()>2 ) {
Expand All @@ -2413,6 +2419,12 @@ namespace das {
return Visitor::visit(expr);
}
// ExprAssert
virtual void preVisit ( ExprAssert * expr ) override {
Visitor::preVisit(expr);
for ( auto & arg : expr->arguments ) {
markNoDiscard(arg.get());
}
}
virtual ExpressionPtr visit ( ExprAssert * expr ) override {
if ( expr->argumentsFailedToInfer ) return Visitor::visit(expr);
if ( expr->arguments.size()<1 || expr->arguments.size()>2 ) {
Expand Down Expand Up @@ -6000,6 +6012,10 @@ namespace das {
}
return !expr->isStatic;
}
virtual void preVisit ( ExprIfThenElse * expr ) override {
Visitor::preVisit(expr);
if ( expr->cond ) markNoDiscard(expr->cond.get());
}
virtual ExpressionPtr visit ( ExprIfThenElse * expr ) override {
if ( !expr->cond->type ) {
return Visitor::visit(expr);
Expand Down Expand Up @@ -6163,6 +6179,7 @@ namespace das {
virtual void preVisit ( ExprWhile * expr ) override {
Visitor::preVisit(expr);
loop.push_back(expr);
markNoDiscard(expr->cond.get());
}
virtual ExpressionPtr visit ( ExprWhile * expr ) override {
loop.pop_back();
Expand Down Expand Up @@ -6918,6 +6935,28 @@ namespace das {
} else if ( expr->rtti_isAsVariant() ) {
auto av = (ExprAsVariant *) expr;
markNoDiscard(av->value.get());
} else if ( expr->rtti_isMakeArray() ) {
auto ma = (ExprMakeArray *) expr;
for ( auto & arg : ma->values ) {
markNoDiscard(arg.get());
}
} else if ( expr->rtti_isMakeStruct() ) {
auto ms = (ExprMakeStruct *) expr;
for ( auto & arg : ms->structs ) {
for ( auto & fld : *arg ) {
markNoDiscard(fld->value.get());
}
}
} else if ( expr->rtti_isMakeTuple() ) {
auto mt = (ExprMakeTuple *) expr;
for ( auto & arg : mt->values ) {
markNoDiscard(arg.get());
}
} else if ( expr->rtti_isMakeVariant() ) {
auto mv = (ExprMakeVariant *) expr;
for ( auto & v : mv->variants ) {
markNoDiscard(v->value.get());
}
}
}
virtual void preVisit ( ExprCall * call ) override {
Expand Down
Loading