File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ vtr_error
1414 :project: vtr
1515 :sections: briefdescription detaileddescription innernamespace innerclass user-defined public-func
1616
17+ .. _vtr_assertion :
18+
1719vtr_assertion
1820-------------
1921.. doxygenfile :: vtr_assert.h
Original file line number Diff line number Diff line change @@ -319,3 +319,31 @@ Group Related Data
319319
320320
321321
322+ Assertion and Safety Check
323+ ~~~~~~~~~~~~~~~~
324+
325+ Assertions help catch bugs early by checking that assumptions hold at runtime.
326+ Consistent use of assertions improves code reliability and helps developers identify problems close to their source.
327+
328+ General Guidelines
329+ ------------------
330+
331+ - Use assertions and data structure validators wherever possible.
332+ - Prefer using `VTR_ASSERT ` for checks that are inexpensive and should be enforced even in release builds.
333+ - In CPU-critical or performance-sensitive code, use `VTR_ASSERT_SAFE ` for potentially expensive checks.
334+ These checks are disabled in release builds but are useful during development and debugging.
335+
336+ .. code-block :: cpp
337+
338+ // Cheap check: always on
339+ VTR_ASSERT(ptr != nullptr);
340+
341+ // Expensive check: enabled only in debug/development builds
342+ VTR_ASSERT_SAFE(is_valid_graph(rr_graph));
343+
344+ - Use assertions to document the assumptions and constraints in your code.
345+ - Prefer placing assertions as close as possible to where they might have been violated.
346+
347+ .. note ::
348+
349+ For more on assertion macros and their behavior, see :ref: `vtr_assertion ` for more details.
You can’t perform that action at this time.
0 commit comments