[all-commits] [llvm/llvm-project] 7068aa: Strengthen -Wint-conversion to default to an error
Aaron Ballman via All-commits
all-commits at lists.llvm.org
Fri Jul 22 12:26:16 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7068aa98412ade19a34b7ed126f4669f581b2311
https://github.com/llvm/llvm-project/commit/7068aa98412ade19a34b7ed126f4669f581b2311
Author: Aaron Ballman <aaron at aaronballman.com>
Date: 2022-07-22 (Fri, 22 Jul 2022)
Changed paths:
M clang-tools-extra/test/clang-tidy/checkers/bugprone/no-escape.m
M clang-tools-extra/test/clang-tidy/checkers/performance/no-int-to-ptr.c
M clang/bindings/python/tests/cindex/test_diagnostics.py
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/test/Analysis/ObjCProperties.m
M clang/test/Analysis/bsd-string.c
M clang/test/Analysis/novoidtypecrash.c
M clang/test/Analysis/null-deref-ps.c
M clang/test/Analysis/number-object-conversion.c
M clang/test/Analysis/number-object-conversion.m
M clang/test/Analysis/pr22954.c
M clang/test/C/drs/dr0xx.c
M clang/test/C/drs/dr2xx.c
M clang/test/CodeGen/2008-03-05-syncPtr.c
M clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
M clang/test/CodeGen/aarch64-mops.c
M clang/test/CodeGen/address-space-cast.c
M clang/test/CodeGen/const-init.c
M clang/test/CodeGen/pointer-arithmetic.c
M clang/test/CodeGen/pointer-to-int.c
M clang/test/CodeGen/statements.c
M clang/test/CodeGen/struct-init.c
M clang/test/CodeGen/vla.c
M clang/test/CodeGenObjC/block-ptr-type-crash.m
M clang/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
M clang/test/FixIt/dereference-addressof.c
M clang/test/FixIt/selector-fixit.m
M clang/test/Misc/serialized-diags.c
M clang/test/Misc/tabstop.c
M clang/test/Modules/config_macros.m
M clang/test/PCH/objc_exprs.m
M clang/test/Parser/implicit-casts.c
M clang/test/Sema/array-init.c
M clang/test/Sema/atomic-ops.c
M clang/test/Sema/block-return.c
M clang/test/Sema/builtin-alloca-with-align.c
M clang/test/Sema/builtin-assume-aligned.c
M clang/test/Sema/builtin-dump-struct.c
M clang/test/Sema/builtins-bpf.c
M clang/test/Sema/builtins.c
M clang/test/Sema/compound-literal.c
M clang/test/Sema/conditional-expr.c
M clang/test/Sema/enum.c
M clang/test/Sema/extern-redecl.c
M clang/test/Sema/format-strings.c
M clang/test/Sema/function-redecl.c
M clang/test/Sema/function.c
M clang/test/Sema/i-c-e.c
M clang/test/Sema/indirect-goto.c
M clang/test/Sema/matrix-type-builtins.c
M clang/test/Sema/nullability.c
M clang/test/SemaObjC/argument-checking.m
M clang/test/SemaObjC/comptypes-7.m
M clang/test/SemaObjC/ivar-lookup-resolution-builtin.m
M clang/test/SemaObjC/message.m
M clang/test/SemaObjC/method-lookup-5.m
M clang/test/SemaObjC/nullability.m
M clang/test/SemaObjC/objc-container-subscripting-3.m
M clang/test/SemaObjC/objc-literal-fixit.m
M clang/test/SemaObjC/signed-char-bool-conversion.m
M clang/test/SemaOpenCL/atomic-ops.cl
M clang/test/SemaOpenCL/builtins-amdgcn-error.cl
M clang/test/VFS/Inputs/external-names.h
M clang/test/VFS/external-names.c
M compiler-rt/test/dfsan/gep.c
M compiler-rt/test/dfsan/sigaction.c
Log Message:
-----------
Strengthen -Wint-conversion to default to an error
Clang has traditionally allowed C programs to implicitly convert
integers to pointers and pointers to integers, despite it not being
valid to do so except under special circumstances (like converting the
integer 0, which is the null pointer constant, to a pointer). In C89,
this would result in undefined behavior per 3.3.4, and in C99 this rule
was strengthened to be a constraint violation instead. Constraint
violations are most often handled as an error.
This patch changes the warning to default to an error in all C modes
(it is already an error in C++). This gives us better security posture
by calling out potential programmer mistakes in code but still allows
users who need this behavior to use -Wno-error=int-conversion to retain
the warning behavior, or -Wno-int-conversion to silence the diagnostic
entirely.
Differential Revision: https://reviews.llvm.org/D129881
More information about the All-commits
mailing list