This adds a new attribute requested by BPF developers. Specifically, they want the ability to
(a) #include the machine-generated vmlinux.h header, that describes the structures, enums and typedefs of the running kernel, and
(b) #include regular kernel headers to get at accessor macros and/or [inline] functions
Those kernel headers will also define the structures of the vmlinux.h header, and thus this would normally be expected to die horribly with a compilation error about multiple definitions or conflicting declarations.
Why conflicting declarations? It turns out that the following are also true:
a) the vmlinux definition of structures & enums defines those of the running kernel, which may not have been configured the same way as the compilation under process. So the structure definitions differ.
b) typedefs may be being given conflicting types (due to lack of fidelity in debug info?)
I understand that neither of these mismatches is a problem to BPF developers.
This patch adds a bpf_dominating_decl Decl attribute, applicable to Record, Enum and Typedef Decls. It is only available for bpf targets compiling C.
This attribute does affect language semantics, so breaks the convention (sorry, couldn't fund actual words in a std mandating this) that ignoring attributes does not change the well-formedness of a program.
The new checks in SemaDecl are on the error path, where we're about to give an error, so we do not degrade well-formed program compilation speed.
This change is unrelated, feel free to land as an NFC with its own commit and revert from here.