a patch for clang static checker: optimization.StrLengthCalculation

Hello ,
I implemented another checker for clang static checker.
It checks that some code uses strlen(or wcslen) to calculate the length of an std::string( or std::wstring).

example:

#include <string>
#include <string.h>

void test() {
  std::string s;
  if (strlen(s.c_str()) != 0) {}; // warn 

}

Currently, I want to study clang static analyzer through developing some checkers.But I do not know whether my patches will be accepted by the clang community.

StrLengthCalculationChecker.cpp (5.47 KB)

str_length_calculation_test.cpp (599 Bytes)

In article <7bd94015.2f8.14b4bb8bc12.Coremail.wuming_81@163.com>,
    <wuming_81@163.com> writes:

    I implemented another checker for clang static checker.
    It checks that some code uses strlen(or wcslen) to calculate the
length of an std::string( or std::wstring).
    
   example:

#include <string>
#include <string.h>

void test() {
  std::string s;
  if (strlen(s.c_str()) != 0) {}; // warn
}

Great! Are you implementing these only as warnings for the static
analyzer or are you also implementing a check for clang-tidy since the
fix is easy to apply?