Skip to content

Commit

Permalink
Make constructors, that can be called with a single argument, explicit.
Browse files Browse the repository at this point in the history
Also, fix two instances of unnecessary copy.

#xls-build-gardener

PiperOrigin-RevId: 721935924
  • Loading branch information
hzeller authored and copybara-github committed Feb 1, 2025
1 parent 0604797 commit 8a98d61
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion xls/data_structures/leaf_type_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,8 @@ class SharedLeafTypeTree {
private:
std::variant<LeafTypeTreeView<T>, LeafTypeTree<T>> inner_;

SharedLeafTypeTree(std::variant<LeafTypeTreeView<T>, LeafTypeTree<T>>&& inner)
explicit SharedLeafTypeTree(
std::variant<LeafTypeTreeView<T>, LeafTypeTree<T>>&& inner)
: inner_(std::move(inner)) {}

friend class LeafTypeTree<T>;
Expand Down
4 changes: 2 additions & 2 deletions xls/passes/dataflow_graph_analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace xls {
// terms of the nodes emitting them) that fully determine the value of the node.
class DataflowGraphAnalysis {
public:
DataflowGraphAnalysis(FunctionBase* f,
const QueryEngine* query_engine = nullptr);
explicit DataflowGraphAnalysis(FunctionBase* f,
const QueryEngine* query_engine = nullptr);

absl::StatusOr<std::vector<Node*>> GetMinCutFor(
Node* node, std::optional<int64_t> max_unknown_bits = std::nullopt,
Expand Down
4 changes: 2 additions & 2 deletions xls/passes/pipeline_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class PipelineGeneratorBase {
element.options());
}
if (element.has_fixedpoint()) {
auto fp_proto = element.fixedpoint();
const auto& fp_proto = element.fixedpoint();
auto fixedpoint =
std::make_unique<FixedPointCompoundPassBase<IrT, OptionsT, ResultsT>>(
fp_proto.has_short_name() ? fp_proto.short_name() : "fixedpoint",
Expand All @@ -138,7 +138,7 @@ class PipelineGeneratorBase {
return absl::OkStatus();
}
if (element.has_pipeline()) {
auto p_proto = element.pipeline();
const auto& p_proto = element.pipeline();
auto pipeline =
std::make_unique<CompoundPassBase<IrT, OptionsT, ResultsT>>(
p_proto.has_short_name() ? p_proto.short_name() : "pipeline",
Expand Down

0 comments on commit 8a98d61

Please sign in to comment.