[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 26 06:56:29 PDT 2017
aaron.ballman added inline comments.
================
Comment at: clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp:64-67
+ const auto StrLenText = Lexer::getSourceText(
+ CharSourceRange::getTokenRange(StrLen->getSourceRange()),
+ *Result.SourceManager, getLangOpts());
+ const auto StrLenBegin = StrLenText.substr(0, StrLenText.find('(') + 1);
----------------
Please don't use `auto` as the type is not spelled out in the initialization. Same elsewhere as well.
================
Comment at: docs/ReleaseNotes.rst:63
+
+ Finds cases a value is added to or subtracted from the string in the parameter
+ of ``strlen()`` method instead of to the result and use its return value as an
----------------
aaron.ballman wrote:
> This comment is no longer accurate and should be reworded.
Still not quite right because it's talking about subtraction.
================
Comment at: docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst:6
+
+Finds cases a value is added to or subtracted from the string in the parameter
+of ``strlen()`` method instead of to the result and use its return value as an
----------------
aaron.ballman wrote:
> This comment is no longer accurate and should be reworded.
Same comment about subtraction.
================
Comment at: docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst:12
+the parameter and the result of the ``strlen()``-like function are ignored,
+similarily to cases where the whole addition is surrounded by extra parentheses.
+
----------------
similarly to -> as are
================
Comment at: docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst:23
+
+The suggested fix is to add ``1`` to the return value of ``strlen()`` and not
+to its argument. In the example above the fix would be
----------------
You should also add an example showing how to silence the warning with parens.
https://reviews.llvm.org/D39121
More information about the cfe-commits
mailing list