forked from OSchip/llvm-project
846e562dcc
Add support for the GNU C style __attribute__((error(""))) and __attribute__((warning(""))). These attributes are meant to be put on declarations of functions whom should not be called. They are frequently used to provide compile time diagnostics similar to _Static_assert, but which may rely on non-ICE conditions (ie. relying on compiler optimizations). This is also similar to diagnose_if function attribute, but can diagnose after optimizations have been run. While users may instead simply call undefined functions in such cases to get a linkage failure from the linker, these provide a much more ergonomic and actionable diagnostic to users and do so at compile time rather than at link time. Users instead may be able use inline asm .err directives. These are used throughout the Linux kernel in its implementation of BUILD_BUG and BUILD_BUG_ON macros. These macros generally cannot be converted to use _Static_assert because many of the parameters are not ICEs. The Linux kernel still needs to be modified to make use of these when building with Clang; I have a patch that does so I will send once this feature is landed. To do so, we create a new IR level Function attribute, "dontcall" (both error and warning boil down to one IR Fn Attr). Then, similar to calls to inline asm, we attach a !srcloc Metadata node to call sites of such attributed callees. The backend diagnoses these during instruction selection, while we still know that a call is a call (vs say a JMP that's a tail call) in an arch agnostic manner. The frontend then reconstructs the SourceLocation from that Metadata, and determines whether to emit an error or warning based on the callee's attribute. Link: https://bugs.llvm.org/show_bug.cgi?id=16428 Link: https://github.com/ClangBuiltLinux/linux/issues/1173 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D106030 |
||
---|---|---|
.. | ||
Inputs | ||
DSOLocalEquivalent.ll | ||
alias_import.ll | ||
alias_internal.ll | ||
alias_resolution.ll | ||
asm.ll | ||
autoupgrade.ll | ||
builtin-nostrip.ll | ||
cache-config.ll | ||
cache-icall.ll | ||
cache-import-lists.ll | ||
cache-typeid-resolutions.ll | ||
cache.ll | ||
callees-metadata.ll | ||
cfi-devirt.ll | ||
cfi-distributed.ll | ||
cfi-icall-only-defuse.ll | ||
cfi-icall.ll | ||
cfi-unsat.ll | ||
cfi.ll | ||
crash_debuginfo.ll | ||
deadstrip.ll | ||
debuginfo-compositetype-import.ll | ||
debuginfo-cu-import.ll | ||
devirt-after-icp.ll | ||
devirt.ll | ||
devirt2.ll | ||
devirt_alias.ll | ||
devirt_available_externally.ll | ||
devirt_check.ll | ||
devirt_external_comdat_same_guid.ll | ||
devirt_local_same_guid.ll | ||
devirt_multiple_type_test.ll | ||
devirt_promote.ll | ||
devirt_promote_legacy.ll | ||
devirt_pure_virtual_base.ll | ||
devirt_single_hybrid.ll | ||
devirt_vcall_vis_hidden.ll | ||
devirt_vcall_vis_public.ll | ||
diagnostic-handler-remarks-with-hotness.ll | ||
diagnostic-handler-remarks.ll | ||
dicompositetype-unique-alias.ll | ||
dicompositetype-unique.ll | ||
dicompositetype-unique2.ll | ||
distributed_import.ll | ||
distributed_indexes.ll | ||
dontcall.ll | ||
dot-dumper-full-lto.ll | ||
dot-dumper.ll | ||
dot-dumper2.ll | ||
drop-debug-info.ll | ||
dsolocal_dllimport.ll | ||
emit_imports.ll | ||
empty-module.ll | ||
empty_module_with_cache.ll | ||
export.ll | ||
funcimport-debug.ll | ||
funcimport-stats.ll | ||
funcimport-tbaa.ll | ||
funcimport.ll | ||
funcimport2.ll | ||
funcimport_alwaysinline.ll | ||
function_entry_count.ll | ||
globals-import-blockaddr.ll | ||
globals-import-const-fold.ll | ||
globals-import.ll | ||
guid_collision.ll | ||
import-constant.ll | ||
import-dsolocal.ll | ||
import-metadata.ll | ||
import-ro-constant.ll | ||
import-symver.ll | ||
import_opaque_type.ll | ||
index-const-prop-O0.ll | ||
index-const-prop-alias.ll | ||
index-const-prop-cache.ll | ||
index-const-prop-comdat.ll | ||
index-const-prop-dead.ll | ||
index-const-prop-full-lto.ll | ||
index-const-prop-gvref-pie.ll | ||
index-const-prop-gvref.ll | ||
index-const-prop-ldst.ll | ||
index-const-prop-linkage.ll | ||
index-const-prop.ll | ||
index-const-prop2.ll | ||
internalize.ll | ||
lazyload_metadata.ll | ||
linkonce_aliasee_ref_import.ll | ||
linkonce_odr_unnamed_addr.ll | ||
linkonce_resolution_comdat.ll | ||
lit.local.cfg | ||
llvm.used.ll | ||
load-store-caching.ll | ||
local_name_conflict.ll | ||
local_name_conflict_var.ll | ||
mangled_symbol.ll | ||
merge-triple.ll | ||
module_asm2.ll | ||
module_asm_glob.ll | ||
module_summary_graph_traits.ll | ||
newpm-basic.ll | ||
nodevirt-nonpromoted-typeid.ll | ||
noinline.ll | ||
nossp.ll | ||
not-internalized.ll | ||
personality-local.ll | ||
personality.ll | ||
pr35472.ll | ||
prefix_replace.ll | ||
printer.ll | ||
pseudo-probe-desc-import.ll | ||
reference_non_importable.ll | ||
referenced_by_constant.ll | ||
save_objects.ll | ||
section.ll | ||
strong_non_prevailing.ll | ||
thinlto-internalize-doublepromoted.ll | ||
thinlto-internalize-used.ll | ||
tli-nobuiltin.ll | ||
type_test_noindircall.ll | ||
visibility-elf.ll | ||
visibility-macho.ll | ||
weak_externals.ll | ||
weak_globals_import.ll | ||
weak_resolution.ll | ||
weak_resolution_single.ll | ||
writeonly-with-refs.ll | ||
writeonly.ll | ||
writeonly2.ll |