[cfe-users] [clang-include-fixer]

Achilles Theodorakopoulos via cfe-users cfe-users at lists.llvm.org
Wed Jul 31 06:12:43 PDT 2019


Hi all,

I'd like to share something I believe is incorrect behavior (bug?) of
find-all-symbols from the clang-include-fixer

Consider the following header (filename is Type.h)

/* ----------------------------- */
#ifndef _TYPE_H
#define _TYPE_H

typedef struct SomeType {
   int a;
   int b;
} SomeType;

#endif
/* ----------------------------- */


Consider, also, main.c as follows:

/* ----------------------------- */
#include "Type.h"

static void func( void )
{
    SomeType obj2;

    struct SomeType obj1;
}
/* ----------------------------- */

And finally for ease of reproduction the compile_commands.json:

[
{
   "directory": "/home/me",
   "command": "/usr/bin/gcc -std=gnu90 -c /home/me/main.c",
   "file": "/home/me/main.c"
}
]

The result of running `find-all-symbols main.c` is the following

---
Name:        SomeType
Contexts:    []
FilePath:    '/home/me/Type.h'
Type:        TypedefName
Seen:        1
Used:        1
...

which appears to be missing the definition of struct SomeType

Notably, if the file is parsed as c++ (eg change "gcc" to "g++" and "gnu90"
to "gnu++98" above) then the result is

---
Name:        SomeType
Contexts:    []
FilePath:    '/home/me/Type.h'
Type:        Class
Seen:        1
Used:        2
...
---
Name:        SomeType
Contexts:    []
FilePath:    '/home/me/Type.h'
Type:        TypedefName
Seen:        1
Used:        1
...

which looks ok.

Is this a bug or is there something I'm missing?

Kind Regards,
Achilles T.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20190731/ca7983d9/attachment.html>


More information about the cfe-users mailing list