Bug 385851

Summary: Allow visiting of implicit code
Product: [Developer tools] clazy Reporter: Richard <richard.oehlinger>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: normal CC: smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: All   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Minimal patch

Description Richard 2017-10-17 11:09:54 UTC
Created attachment 108400 [details]
Minimal patch

Right now its not possible to check for actions performed in an implicit constructor. 
Therfore ClazyASTConsumer should override the method shouldVisitImplicitCode. See patch attached.

Perhaps this should be configurable, but I don't know how to incorporate this best.
Comment 1 Sergio Martins 2017-10-17 12:34:51 UTC
By implicit CTORs you mean the compiler-synthesized ones ? Which clazy check would find anything interesting in there ?
Comment 2 Richard 2017-10-17 13:05:34 UTC
We've an in-house check for a 3rdparty library which we cannot control to flag default construction of several types:

//in thirdpartylib.h
class DoNotDefaultConstruct {
//....
}

//in our code
DoNotDefaultConstruct c; // will be flagged as intended
struct SomeStruct {
    DoNotDefaultConstruct c;
} inst; //should be flagged, but won't
Comment 3 Sergio Martins 2017-10-18 08:00:42 UTC
It makes things considerably slower (11m vs 15m to build qtbase), so I'll add an opt-in option to enable it
Comment 4 Sergio Martins 2017-10-19 17:44:15 UTC
commit ec9ec84e7fd73f5a4753973660ad4f301eaa8c0e (HEAD -> master, origin/master)
Author: Sergio Martins <smartins@kde.org>
Date:   Thu Oct 19 18:35:27 2017 +0100

    Minor cleanup to previous commit regarding visit-implicit-code
    
    CCBUG: 385851

commit 4847a25f3fa65744bd7dd23533da6bb8783ca6b6
Author: Richard Oehlinger <r.oehlinger@avibit.com>
Date:   Thu Oct 19 16:00:29 2017 +0200

    Add option to visit implicit code, such as compiler generated CTORs
    
    Although clazy's built-in checks don't need this, some custom user
    checks might
    
    Not enabled by default as it causes a slight slowdown
    
    BUG: 385851