YCM seems to ignore some clang-tidy checks

55 views
Skip to first unread message

Peter Wolf

unread,
Jul 30, 2020, 7:12:24 PM7/30/20
to ycm-users
Hi,

I've observed the following behaviour and I'm trying to understand where this is coming from.

I have a .clang-tidy configuration file in my C project's root folder (with an array of checks enabled).
In the main function I have something like the following code snippets:

MyStruct s = (MyStruct*) malloc(sizeof(MyStruct));
MyStruct2 s2 = (MyStruct2*) malloc(sizeof(MyStruct2));

if (s == NULL || s2 == NULL)
{
  printf("Error when allocating memory for structs.\n");
 
return 0;
}

//...

pthread_t first_thread
;
pthread_create
(&first_thread, NULL, my_func, NULL);


pthread_t second_thread;
pthread_create
(&second_thread, NULL, my_other_func, NULL);

//...


Running clang-tidy with my config outside of vim on that file results in a few warnings:

1. s or s2 might leak. (from clang-analyzer-unix.Malloc)
2. first_thread (and second_thread) should be initialized (from cppcoreguidelines-init-variables)

But when inside vim, only the cppcoreguidelines-init-variables issues are shown to me by YCM.

Investigating a little further, it seems that YCM is not reporting all these "default" checks that clang-tidy reports even when the "Checks" in .clang-tidy are set to an empty string.
So most/all of the "clang-*" checks.

What do I have to do to enable those in YCM?

Thanks for your help!

Reply all
Reply to author
Forward
0 new messages