Bug Summary

File:build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/lldb/source/Plugins/Process/Utility/AuxVector.cpp
Warning:line 53, column 15
Value stored to 'name' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name AuxVector.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-16/lib/clang/16.0.0 -isystem /usr/include/libxml2 -D HAVE_ROUND -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/lldb/source/Plugins/Process/Utility -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/lldb/source/Plugins/Process/Utility -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/lldb/include -I tools/lldb/include -I include -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/llvm/include -I /usr/include/python3.9 -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/clang/include -I tools/lldb/../clang/include -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/lldb/source -I tools/lldb/source -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/= -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/= -O2 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-10-03-140002-15933-1 -x c++ /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/lldb/source/Plugins/Process/Utility/AuxVector.cpp
1//===-- AuxVector.cpp -----------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "AuxVector.h"
10
11AuxVector::AuxVector(const lldb_private::DataExtractor &data) {
12 ParseAuxv(data);
13}
14
15void AuxVector::ParseAuxv(const lldb_private::DataExtractor &data) {
16 lldb::offset_t offset = 0;
17 const size_t value_type_size = data.GetAddressByteSize() * 2;
18 while (data.ValidOffsetForDataOfSize(offset, value_type_size)) {
19 // We're not reading an address but an int that could be 32 or 64 bit
20 // depending on the address size, which is what GetAddress does.
21 const uint64_t type = data.GetAddress(&offset);
22 const uint64_t value = data.GetAddress(&offset);
23 if (type == AUXV_AT_NULL)
24 break;
25 if (type == AUXV_AT_IGNORE)
26 continue;
27
28 m_auxv_entries[type] = value;
29 }
30}
31
32llvm::Optional<uint64_t>
33AuxVector::GetAuxValue(enum EntryType entry_type) const {
34 auto it = m_auxv_entries.find(static_cast<uint64_t>(entry_type));
35 if (it != m_auxv_entries.end())
36 return it->second;
37 return llvm::None;
38}
39
40void AuxVector::DumpToLog(lldb_private::Log *log) const {
41 if (!log)
42 return;
43
44 log->PutCString("AuxVector: ");
45 for (auto entry : m_auxv_entries) {
46 LLDB_LOGF(log, " %s [%" PRIu64 "]: %" PRIx64,do { ::lldb_private::Log *log_private = (log); if (log_private
) log_private->Printf(" %s [%" "l" "u" "]: %" "l" "x", GetEntryName
(static_cast<EntryType>(entry.first)), entry.first, entry
.second); } while (0)
47 GetEntryName(static_cast<EntryType>(entry.first)), entry.first,do { ::lldb_private::Log *log_private = (log); if (log_private
) log_private->Printf(" %s [%" "l" "u" "]: %" "l" "x", GetEntryName
(static_cast<EntryType>(entry.first)), entry.first, entry
.second); } while (0)
48 entry.second)do { ::lldb_private::Log *log_private = (log); if (log_private
) log_private->Printf(" %s [%" "l" "u" "]: %" "l" "x", GetEntryName
(static_cast<EntryType>(entry.first)), entry.first, entry
.second); } while (0)
;
49 }
50}
51
52const char *AuxVector::GetEntryName(EntryType type) const {
53 const char *name = "AT_???";
Value stored to 'name' during its initialization is never read
54
55#define ENTRY_NAME(_type) \
56 _type: \
57 name = &#_type[5]
58 switch (type) {
59 case ENTRY_NAME(AUXV_AT_NULL); break;
60 case ENTRY_NAME(AUXV_AT_IGNORE); break;
61 case ENTRY_NAME(AUXV_AT_EXECFD); break;
62 case ENTRY_NAME(AUXV_AT_PHDR); break;
63 case ENTRY_NAME(AUXV_AT_PHENT); break;
64 case ENTRY_NAME(AUXV_AT_PHNUM); break;
65 case ENTRY_NAME(AUXV_AT_PAGESZ); break;
66 case ENTRY_NAME(AUXV_AT_BASE); break;
67 case ENTRY_NAME(AUXV_AT_FLAGS); break;
68 case ENTRY_NAME(AUXV_AT_ENTRY); break;
69 case ENTRY_NAME(AUXV_AT_NOTELF); break;
70 case ENTRY_NAME(AUXV_AT_UID); break;
71 case ENTRY_NAME(AUXV_AT_EUID); break;
72 case ENTRY_NAME(AUXV_AT_GID); break;
73 case ENTRY_NAME(AUXV_AT_EGID); break;
74 case ENTRY_NAME(AUXV_AT_CLKTCK); break;
75 case ENTRY_NAME(AUXV_AT_PLATFORM); break;
76 case ENTRY_NAME(AUXV_AT_HWCAP); break;
77 case ENTRY_NAME(AUXV_AT_FPUCW); break;
78 case ENTRY_NAME(AUXV_AT_DCACHEBSIZE); break;
79 case ENTRY_NAME(AUXV_AT_ICACHEBSIZE); break;
80 case ENTRY_NAME(AUXV_AT_UCACHEBSIZE); break;
81 case ENTRY_NAME(AUXV_AT_IGNOREPPC); break;
82 case ENTRY_NAME(AUXV_AT_SECURE); break;
83 case ENTRY_NAME(AUXV_AT_BASE_PLATFORM); break;
84 case ENTRY_NAME(AUXV_AT_RANDOM); break;
85 case ENTRY_NAME(AUXV_AT_HWCAP2); break;
86 case ENTRY_NAME(AUXV_AT_EXECFN); break;
87 case ENTRY_NAME(AUXV_AT_SYSINFO); break;
88 case ENTRY_NAME(AUXV_AT_SYSINFO_EHDR); break;
89 case ENTRY_NAME(AUXV_AT_L1I_CACHESHAPE); break;
90 case ENTRY_NAME(AUXV_AT_L1D_CACHESHAPE); break;
91 case ENTRY_NAME(AUXV_AT_L2_CACHESHAPE); break;
92 case ENTRY_NAME(AUXV_AT_L3_CACHESHAPE); break;
93 }
94#undef ENTRY_NAME
95
96 return name;
97}