[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening
Jan Kratochvil via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 19 07:32:49 PST 2019
jankratochvil added a comment.
Example output:
PATH="$PWD/bin:$PATH" ~/redhat/llvm-monorepo/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -checks='-*,bugprone-pointer-cast-widening' /home/jkratoch/redhat/llvm-monorepo/lldb/source/
Enabled checks:
bugprone-pointer-cast-widening
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Core/PluginManager.cpp:89:35: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend [bugprone-pointer-cast-widening]
return reinterpret_cast<FPtrTy>(reinterpret_cast<intptr_t>(VPtr));
^
- What is the use of intptr_t?
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRMemoryMap.cpp:333:29: warning: do not use cast of a pointer 'std::__shared_ptr<lldb_private::Process, __gnu_cxx::_S_atomic>::element_type *' (aka 'lldb_private::Process *') to non-uintptr_t 'lldb::addr_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
__FUNCTION__, (lldb::addr_t)process_sp.get(),
^
- A bug, submitted as: D71514
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRMemoryMap.cpp:582:42: warning: do not use cast of a pointer 'const uint8_t *' (aka 'const unsigned char *') to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
(uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
^
- A bug, not yet submitted.
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRMemoryMap.cpp:713:42: warning: do not use cast of a pointer 'uint8_t *' (aka 'unsigned char *') to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
(uint64_t)process_address, (uint64_t)bytes, (uint64_t)size,
^
- A bug, not yet submitted.
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Host/common/HostInfoBase.cpp:252:32: warning: do not use cast of a pointer 'bool (*)(lldb_private::FileSpec &)' to non-uintptr_t 'intptr_t' (aka 'long') which may sign-extend [bugprone-pointer-cast-widening]
reinterpret_cast<void *>(reinterpret_cast<intptr_t>(
^
- What is the use of intptr_t?
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Host/posix/DomainSocket.cpp:48:20: warning: do not use cast of a pointer 'char *' to non-uintptr_t 'size_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
saddr_un_len = SUN_LEN(saddr_un);
^
/usr/include/sys/un.h:40:24: note: expanded from macro 'SUN_LEN'
# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
^
- False positive?
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Expression/IRExecutionUnit.cpp:351:53: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
function.getName().str().c_str(), external, (lldb::addr_t)fun_ptr));
^
- A bug, submitted as: D71498
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp:358:24: warning: do not use cast of a pointer 'clang::NamedDecl *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
reinterpret_cast<uint64_t>(result_decl), false);
^
- A bug, not yet submitted.
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:139:23: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower),
^
- A bug, submitted as: D71514
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:140:18: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
reinterpret_cast<lldb::addr_t>(info.si_upper),
^
- A bug, submitted as: D71514
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:141:18: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
reinterpret_cast<lldb::addr_t>(info.si_addr));
^
- A bug, submitted as: D71514
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Plugins/Process/POSIX/CrashReason.cpp:147:31: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'lldb::addr_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
reinterpret_cast<lldb::addr_t>(info.si_addr));
^
- A bug, submitted as: D71514
/home/jkratoch/redhat/llvm-monorepo/lldb/source/Utility/Stream.cpp:159:65: warning: do not use cast of a pointer 'const void *' to non-uintptr_t 'ptrdiff_t' (aka 'long') which may sign-extend [bugprone-pointer-cast-widening]
Printf("0x%.*tx", static_cast<int>(sizeof(const void *)) * 2, (ptrdiff_t)p);
^
- False positive?
Output filtered by my script <https://git.jankratochvil.net/?p=nethome.git;a=blob_plain;f=bin/clang-tidy-filter>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71707/new/
https://reviews.llvm.org/D71707
More information about the cfe-commits
mailing list