Flag functions that should be static if they are only called within a particular compilation unit
Categories
(Developer Infrastructure :: Source Code Analysis, defect, P3)
Tracking
(Not tracked)
People
(Reporter: taras.mozilla, Unassigned)
References
Details
Attachments
(2 files)
644.90 KB,
text/plain
|
Details | |
2.38 KB,
patch
|
dwitte
:
review+
|
Details | Diff | Splinter Review |
Updated•15 years ago
|
Comment 1•15 years ago
|
||
Reporter | ||
Comment 2•15 years ago
|
||
Comment 4•15 years ago
|
||
Comment 5•15 years ago
|
||
Updated•15 years ago
|
Comment 6•15 years ago
|
||
Comment 7•15 years ago
|
||
Comment 8•8 years ago
|
||
Comment 9•8 years ago
|
||
Updated•8 years ago
|
Comment 10•8 years ago
|
||
Comment 11•8 years ago
|
||
Comment 12•8 years ago
|
||
Updated•7 years ago
|
Comment 13•6 years ago
|
||
Maybe we could do that with the searchfox db...
Comment 14•6 years ago
|
||
Searchfox uses a clang plugin to get its knowledge about C++ code. Instead of trying to shoehorn it into searchfox it would be better to just write a new clang plugin.
Comment 15•6 years ago
|
||
(In reply to Kartikaya Gupta (email:kats@mozilla.com) from comment #14)
Searchfox uses a clang plugin to get its knowledge about C++ code. Instead of trying to shoehorn it into searchfox it would be better to just write a new clang plugin.
What Sylvestre meant is to use the data produced by the searchfox Clang Plugin, not putting it into searchfox. I think a new Clang plugin wouldn't save a lot, you would still have to generate all the data, then postprocess it (because you have to scan for other invocations of the function, which you can't do directly from the Clang plugin).
I don't know if the searchfox data has all the information available for this, but I can take a look at it next week maybe.
Comment 16•6 years ago
•
|
||
clang's -Wmissing-prototypes option can identify some global functions that can be made static (or removed if they are unused).
-Wmissing-prototypes warns about global functions definitions that have no previous function prototype (e.g. from a header file) in scope. These functions could be made static (e.g. bug 1443402) because they are probably not called by other compilation units. Without a function prototype in a header file, another compilation unit would need to declare its own prototype for the function or use some dynamic mechanism like dlsym().
https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes
Unfortunately, there are currently 1331 -Wmissing-prototypes warnings, so fixing them all is probably impractical. Also, these warnings would not catch global functions that do have a function prototype but are still only called from one compilation unit (or not called at all).
Confusingly, gcc's -Wmissing-prototypes option is not equivalent to clang's -Wmissing-prototypes. -Wmissing-declarations is gcc's name for clang's -Wmissing-prototypes.
https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Warning-Options.html
Comment 17•6 years ago
|
||
(In reply to Christian Holler (:decoder) from comment #15)
What Sylvestre meant is to use the data produced by the searchfox Clang Plugin, not putting it into searchfox. I think a new Clang plugin wouldn't save a lot, you would still have to generate all the data, then postprocess it (because you have to scan for other invocations of the function, which you can't do directly from the Clang plugin).
I don't know if the searchfox data has all the information available for this, but I can take a look at it next week maybe.
Ah I see. The goals of searchfox and this bug still seem fundamentally different to me, so I'm not sure code sharing is such a good idea. Feel free to fork the searchfox clang-plugin though. If you do reuse the code as-is keep in mind the output format is subject to change at any time, no guarantees provided etc. Also the searchfox jobs currently only run on {mac,linux,windows}-debug builds so they might miss stuff.
Updated•6 years ago
|
Comment 18•4 years ago
|
||
Is this patch good to go? If not, can it be updated?
Updated•2 years ago
|
Updated•2 years ago
|
Description
•