You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- **Write short functions.** Functions should do one thing. Short functions are easier to understand, test, and reuse,
236
-
and their purpose can be clearly described in a concise comment or documentation block.
237
-
- **Limit function length.** If a function is growing too long or is difficult to describe in a sentence or two,
238
-
consider splitting it into smaller helper functions.
239
-
- **Favor simplicity.** Avoid clever or unnecessarily complex constructs. Code should be easy to read and maintain by others,
240
-
not just the original author.
235
+
- **Write short functions.** Functions should do one thing. Short functions are easier to understand, test, and reuse, and their purpose can be clearly described in a concise comment or documentation block.
236
+
- **Limit function length.** If a function is growing too long or is difficult to describe in a sentence or two, consider splitting it into smaller helper functions.
237
+
- **Favor simplicity.** Avoid clever or unnecessarily complex constructs. Code should be easy to read and maintain by others, not just the original author.
238
+
- **Avoid deep abstract class hierarchies.** Excessive layering of virtual base classes makes the code hard to navigate and understand. Many tools (e.g., IDEs, LSPs) struggle to follow virtual call chains, especially in large or templated codebases.
239
+
- **Avoid mixing templates with virtual functions.** This combination is particularly difficult to reason about and navigate. If you need to write generic code, prefer using either virtual dispatch or templates, but not both in the same interface.
241
240
- Before adding new functions, classes, or utilities, check the codebase and documentation to see if a similar utility already exists.
242
241
- Reuse or extend existing routines instead of duplicating functionality. This reduces bugs and makes the codebase more maintainable.
243
242
244
243
244
+
245
245
Group Related Data
246
246
~~~~~~~~~~~~~~~~~~
247
247
@@ -302,6 +302,30 @@ General Guidelines
302
302
For more on assertion macros and their behavior, see :ref:`vtr_assertion` for more details.
303
303
304
304
305
+
Logging and Error Reporting
306
+
~~~~~~~~~~~~~
307
+
Use the VTR logging and error handling utilities instead of raw `printf`, `std::cerr`, `exit()`, or `throw`.
308
+
309
+
- Use `VTR_LOG`, `VTR_LOG_WARN`, and `VTR_LOG_ERROR`
310
+
311
+
312
+
.. code-block:: cpp
313
+
314
+
VTR_LOG("Incr Slack updates %zu in %g sec\n", incr_slack_updates, incr_slack_update_time_sec);
315
+
316
+
if (check_route_option == e_check_route_option::OFF) {
317
+
VTR_LOG_WARN("The user disabled the check route step.");
318
+
return;
319
+
}
320
+
321
+
if (total_edges_to_node[inode] != 0) {
322
+
VTR_LOG_ERROR("in check_rr_graph: SOURCE node %d has a fanin of %d, expected 0.\n", inode, total_edges_to_node[inode]);
323
+
}
324
+
325
+
326
+
Refer to :doc:`Logging - Errors - Assertions</api/vtrutil/logging>` to learn more about logging and error reporting.
0 commit comments