julia
bc49439f - require all src functions are declared in a header (or are not expected necessary due to static/extern/dllexport) (#62214)

Commit
14 days ago
require all src functions are declared in a header (or are not expected necessary due to static/extern/dllexport) (#62214) Add a StaticOrDeclared clang-tidy check that enforces that every function with external linkage defined in a source file is either: (a) declared in some header (i.e. it has a non-defining redeclaration that comes from an #included file, so the function is part of an API that other translation units can call), or (b) declared `static` (internal linkage), so it is private to its translation unit, or (c) explicitly exported with `JL_DLLEXPORT` -- i.e. it carries an explicit `__declspec(dllexport)` (on Windows) and/or `__attribute__((visibility("default")))` (elsewhere). Such a function is deliberately part of the public ABI even without a prototype, so it is permitted. Which attribute is present depends on the platform the analysis runs on, so both are accepted, or (d) explicitly annotated with the `extern` keyword in this file. Functions are external by default, so spelling out `extern` is a deliberate statement that the external linkage is intended, which overrides the warning. (This is the storage class `extern`, not the `extern "C"` language-linkage specifier.) This is intended to help ensure we discourage local prototypes, which can drift out of sync with their global prototype. It also lets the compiler generate slightly better code optimizations (inlining decisions) and minimizes the list of exported symbols for the linker.
Author
Loading