[cfe-dev] [RFC] Adding lifetime analysis to clang

Dmitri Gribenko via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 15 07:01:40 PDT 2019


On Mon, Apr 15, 2019 at 2:26 PM Gábor Horváth <xazax.hun at gmail.com> wrote:
>
> Thank you for summarizing the discussion and raising all these points.
> Based on your response I propose the following plan moving forward:
>
> * Start submitting patches regarding the non-controversial parts of the analysis, including:
>   - Adding the annotations to Clang
>   - Generalize existing statement-local warnings
>     - Technical question here: should we expect the STL vendors to annotate the types, should we hard-code the annotations into the compiler, or should we actually implement type inference but restrict it to STL types?
>   - Adding some extra statement-local warnings
>   - Adding the flow sensitive analysis
>
> Can we add you as a reviewer to those patches?

Happy to help :)

> To start the discussions regarding the type category inference, as far as I understand you are more worried about the false negatives that can give a bad impression about the analysis rather than the false positives.

I would say my concerns are around the understandability of the
system, more so than the false negatives of inference.

> One idea we had is to have a refactoring that will automatically annotate the user defined types based on the inference we have. This could give the users a way to understand the root causes of such false negatives.
> In case the community will not want automatic type category inference in the compiler we are still likely to implement it as a Tidy check with a refactoring to make it easier for users to adopt this analysis.

That'd be helpful, however, relying purely on such analysis is not
much better than inference.  Users should annotate types that conform
to type categories.  We should also figure out a way to learn if it is
common for users to have types that are in spirit conforming to type
categories, but don't conform syntactically (e.g., have named methods
instead of overloaded operators).  If those are important, we would
need to build corresponding annotations.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the cfe-dev mailing list