Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/checks/abseil/duration-addition.rst

raw
1 .. title:: clang-tidy - abseil-duration-addition
2
3 abseil-duration-addition
4 ========================
5
6 Check for cases where addition should be performed in the ``absl::Time`` domain.
7 When adding two values, and one is known to be an ``absl::Time``, we can infer
8 that the other should be interpreted as an ``absl::Duration`` of a similar
9 scale, and make that inference explicit.
10
11 Examples:
12
13 .. code-block:: c++
14
15 // Original - Addition in the integer domain
16 int x;
17 absl::Time t;
18 int result = absl::ToUnixSeconds(t) + x;
19
20 // Suggestion - Addition in the absl::Time domain
21 int result = absl::ToUnixSeconds(t + absl::Seconds(x));