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
In C++ attribute: likely, unlikely (since C++20), we can add [[likely]] / [[unlikely]] on if-else clauses. But cpplint does not recognize the [[likely]] / [[unlikely]] attributes after if / else / else if:
$ pip3 install -I git+https://github.com/cpplint/cpplint.gitLooking in indexes: https://pypi.tuna.tsinghua.edu.cn/simpleCollecting git+https://github.com/cpplint/cpplint.git Cloning https://github.com/cpplint/cpplint.git to /tmp/pip-req-build-6nkph3fd Running command git clone --filter=blob:none --quiet https://github.com/cpplint/cpplint.git /tmp/pip-req-build-6nkph3fd Resolved https://github.com/cpplint/cpplint.git to commit fa12a0bbdafa15291276ddd2a2dcd2ac7a2ce4cb Preparing metadata (setup.py) ... doneBuilding wheels for collected packages: cpplint Building wheel for cpplint (setup.py) ... done Created wheel for cpplint: filename=cpplint-1.6.1-py3-none-any.whl size=77266 sha256=3e95bbfd3de2b8d61d561339213e6a4ae741e8bb110b34c9b6f626c55cd325c9 Stored in directory: /tmp/pip-ephem-wheel-cache-d42ge4uo/wheels/af/90/88/663d23197700a259f2a9199aef67ee9977e21f6d1980257857Successfully built cpplintInstalling collected packages: cpplintSuccessfully installed cpplint-1.6.1
$ cpplint foo.cppfoo.cpp:7: If/else bodies with multiple statements require braces [readability/braces] [4]foo.cpp:10: If/else bodies with multiple statements require braces [readability/braces] [4]foo.cpp:13: Else clause should never be on same line as else (use 2 lines) [whitespace/newline] [4]foo.cpp:13: If/else bodies with multiple statements require braces [readability/braces] [4]foo.cpp:16: Else clause should never be on same line as else (use 2 lines) [whitespace/newline] [4]Done processing foo.cppTotal errors found: 5
The text was updated successfully, but these errors were encountered:
XuehaiPan
changed the title
C++20 [[likely]] / [[unlikely]] attribute support for else clause
C++20 [[likely]] / [[unlikely]] attribute support
Oct 19, 2022
Than ks for the report, cpplint currently does not support any braking c++20 syntax elements, and I don't know if it ever will (due to lack of maintainers, and googles lack of public cpplint updates).
1. Fixescpplint#212
2. else statements that have braces on both sides but have the second-to-last } on a separate line will no longer claim we need braces on both sides
3. Fix single-line if statements being yelled at to split their lines, something contradictory to the style guide
4. Fixes relevant tests, including adding the new "TestLintContains" and "TestLintNotContains" methods. (ik the latter may have a grammar error but who cares, this is consistent with the former's name)
5. Add a todo for "This exception does not apply to multi-keyword statements like if ... else or do ... while."
In C++ attribute:
likely
,unlikely
(since C++20), we can add[[likely]]
/[[unlikely]]
onif-else
clauses. Butcpplint
does not recognize the[[likely]]
/[[unlikely]]
attributes afterif
/else
/else if
:Source file:
Command-line:
The text was updated successfully, but these errors were encountered: