@@ -95,53 +95,6 @@ Specific Conventions
9595 Example: `router_lookahead_map.cpp `, `netlist_walker.h `
9696
9797
98- Use of `auto `
99- ~~~~~~~~~~~~~
100-
101- Use `auto ` only when the type is long, complex, or hard to write explicitly.
102-
103- Examples where `auto ` is appropriate:
104-
105- .. code-block :: cpp
106-
107- auto it = container.begin(); // Iterator type is long and not helpful to spell out
108-
109- // The return type is std::vector<std::vector<std::pair<int, float>>>
110- auto matrix = generate_adjacency_matrix();
111-
112- // Lambdas have unreadable and compiler-generated types — use auto for them
113- auto add = [](int x, int y) { return x + y; };
114-
115-
116- Avoid `auto ` when the type is simple and clear:
117-
118- .. code-block :: cpp
119-
120- // Use type names when they are short and readable.
121- for (RRNodeId node_id : device_ctx.rr_graph.nodes()) {
122- t_rr_node_route_inf& node_inf = route_ctx.rr_node_route_inf[rr_id];
123- }
124-
125- int count = 0;
126- std::string name = "example";
127- std::vector<int> numbers = {1, 2, 3};
128-
129- Avoid:
130-
131- .. code-block :: cpp
132-
133- auto count = 0; // Simple and obvious type
134- auto name = std::string("x"); // Hides a short, clear type
135-
136- for (auto node_id : device_ctx.rr_graph.nodes()) {
137- // node_id is RRNodeId. Write it out for clarity.
138- auto& node_inf = route_ctx.rr_node_route_inf[rr_id];
139- // node_inf is t_rr_node_route_inf. Use the explicit type since it's simple and meaningful.
140- }
141-
142- Rationale: clear, explicit types help with readability and understanding. Avoid hiding simple types behind `auto `.
143-
144-
14598
14699Commenting Style
147100~~~~~~~~~~~~~~~~
@@ -272,19 +225,19 @@ Avoid Unnecessary Complexity
272225.. code-block :: cpp
273226
274227 // Prefer this
275- std::vector<int> get_ids() const;
228+ const std::vector<int>& get_ids() const;
276229
277230 // Avoid this unless you truly need it
278231 template<typename T>
279232 auto&& get_ids() const && noexcept;
280233
281234
282235 - **Write short functions. ** Functions should do one thing. Short functions are easier to understand, test, and reuse,
283- and their purpose can be clearly described in a concise comment or documentation block.
236+ and their purpose can be clearly described in a concise comment or documentation block.
284237- **Limit function length. ** If a function is growing too long or is difficult to describe in a sentence or two,
285- consider splitting it into smaller helper functions.
238+ consider splitting it into smaller helper functions.
286239- **Favor simplicity. ** Avoid clever or unnecessarily complex constructs. Code should be easy to read and maintain by others,
287- not just the original author.
240+ not just the original author.
288241- Before adding new functions, classes, or utilities, check the codebase and documentation to see if a similar utility already exists.
289242- Reuse or extend existing routines instead of duplicating functionality. This reduces bugs and makes the codebase more maintainable.
290243
@@ -346,4 +299,52 @@ General Guidelines
346299
347300.. note ::
348301
349- For more on assertion macros and their behavior, see :ref: `vtr_assertion ` for more details.
302+ For more on assertion macros and their behavior, see :ref: `vtr_assertion ` for more details.
303+
304+
305+
306+ Use of `auto `
307+ ~~~~~~~~~~~~~
308+
309+ Use `auto ` only when the type is long, complex, or hard to write explicitly.
310+
311+ Examples where `auto ` is appropriate:
312+
313+ .. code-block :: cpp
314+
315+ auto it = container.begin(); // Iterator type is long and not helpful to spell out
316+
317+ // The return type is std::vector<std::vector<std::pair<int, float>>>
318+ auto matrix = generate_adjacency_matrix();
319+
320+ // Lambdas have unreadable and compiler-generated types — use auto for them
321+ auto add = [](int x, int y) { return x + y; };
322+
323+
324+ Avoid `auto ` when the type is simple and clear:
325+
326+ .. code-block :: cpp
327+
328+ // Use type names when they are short and readable.
329+ for (RRNodeId node_id : device_ctx.rr_graph.nodes()) {
330+ t_rr_node_route_inf& node_inf = route_ctx.rr_node_route_inf[rr_id];
331+ }
332+
333+ int count = 0;
334+ std::string name = "example";
335+ std::vector<int> numbers = {1, 2, 3};
336+
337+ Avoid:
338+
339+ .. code-block :: cpp
340+
341+ auto count = 0; // Simple and obvious type
342+ auto name = std::string("x"); // Hides a short, clear type
343+
344+ for (auto node_id : device_ctx.rr_graph.nodes()) {
345+ // node_id is RRNodeId. Write it out for clarity.
346+ auto& node_inf = route_ctx.rr_node_route_inf[rr_id];
347+ // node_inf is t_rr_node_route_inf. Use the explicit type since it's simple and meaningful.
348+ }
349+
350+ Rationale: clear, explicit types help with readability and understanding. Avoid hiding simple types behind `auto `.
0 commit comments