[cfe-users] Analyzer diagnostics for uninstantiated classes

Benjamin Bannier bbannier at gmail.com
Wed Oct 16 00:03:12 PDT 2013


clang's analyzer doesn't seem to emit diagnostics for uninstantiated
classes. Can I as a frontend user turn these on with some flag?

The current situation is a little unfortunate when developing library
code: the library might not instantiate all its types while in user code
the definitions of all functions might not be available.

I see this behavior e.g. in r192680.


    struct A {
      void setup() { n = N; }
      A() {
        N = 1;

      int N, n;

    int main() {
      //A a; //  **HERE**

With the line marked **HERE** commented out `clang --analyze` finds nothing,
while with it active I get what I wanted:

    test.cpp:2:20: warning: Assigned value is garbage or undefined
      void setup() { n = N; }
                       ^ ~
    1 warning generated

What awesome times were I am surprised by this kind of problem, thanks
for the great work,


"Good judgment comes from experience. Experience comes from bad judgment."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20131016/55475f0a/attachment.sig>

More information about the cfe-users mailing list