[cfe-dev] Check virtual calls in ctor or dtor

章磊 ioripolo at gmail.com
Sun Sep 25 02:32:28 PDT 2011


Hi Ted,

I tried to implement this as a compiler warning. But i had some
problem in how to get the body of the ctor or dtor.

I implemented this in Sema::CheckConstructor and
Sema::CheckDestructor, but i can not get the body of them when there
is no body with the declaration yet. And i also need the function body
of the CallExpr in the ctor/dtor to do recursive analysis.

So where should i implement this to give a compiler warning?

2011/9/14, 章磊 <ioripolo at gmail.com>:
> Hi Ted,
>
> I think it's better to implement it as a compiler warning, where should i
> get involved in?
>
> There may some more syntax checks:
>
>    1. absence of virtual dtor( ), it seems that we need whole program
>    analysis to figure out whether a class is a base class.
>    2. define and initialize member variables in the same order
>    3. const-correctness
>
> Should this also be compiler warnings? How to define which they belong to?
>
> 2011/9/13 Ted Kremenek <kremenek at apple.com>
>
>> Hi Lei,
>>
>> Do you think this would be better implemented as a compiler warning,
>> instead of a static analysis check?
>>
>> Ted
>>
>> On Sep 12, 2011, at 6:45 AM, 章磊 wrote:
>>
>> > Hi Clang,
>> >
>> > The attached patch adds a C++ syntax Checker to clang, it checks
>> > whether
>> there is a virtual call in the constructor or destructor. I add a file to
>> svn to implement this checker, because i think there may be some other
>> syntax checkers we could write here.
>> >
>> > I will appreciate it if there are any advice about this patch.
>> >
>> > --
>> > Best regards!
>> >
>> > Lei Zhang
>> >
>> <VirtualCallinCtorOrDtor.patch>_______________________________________________
>> > cfe-dev mailing list
>> > cfe-dev at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>>
>
>
> --
> Best regards!
>
> Lei Zhang
>


-- 
Best regards!

Lei Zhang




More information about the cfe-dev mailing list