clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name SmallVector.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -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 -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/lib/Support -I /build/llvm-toolchain-snapshot-7~svn329677/lib/Support -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn329677/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/lib/Support -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-04-11-031539-24776-1 -x c++ /build/llvm-toolchain-snapshot-7~svn329677/lib/Support/SmallVector.cpp
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | #include "llvm/ADT/SmallVector.h" |
15 | using namespace llvm; |
16 | |
17 | |
18 | |
19 | void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSizeInBytes, |
20 | size_t TSize) { |
21 | size_t CurSizeBytes = size_in_bytes(); |
22 | size_t NewCapacityInBytes = 2 * capacity_in_bytes() + TSize; |
23 | if (NewCapacityInBytes < MinSizeInBytes) |
| |
24 | NewCapacityInBytes = MinSizeInBytes; |
25 | |
26 | void *NewElts; |
27 | if (BeginX == FirstEl) { |
| 2 | | Assuming the condition is true | |
|
| |
28 | NewElts = malloc(NewCapacityInBytes); |
| 4 | | Value assigned to 'NewElts' | |
|
29 | if (NewElts == nullptr) |
| 5 | | Assuming pointer value is null | |
|
| |
30 | report_bad_alloc_error("Allocation of SmallVector element failed."); |
31 | |
32 | |
33 | memcpy(NewElts, this->BeginX, CurSizeBytes); |
| 7 | | Null pointer passed as an argument to a 'nonnull' parameter |
|
34 | } else { |
35 | |
36 | NewElts = realloc(this->BeginX, NewCapacityInBytes); |
37 | if (NewElts == nullptr) |
38 | report_bad_alloc_error("Reallocation of SmallVector element failed."); |
39 | } |
40 | |
41 | this->EndX = (char*)NewElts+CurSizeBytes; |
42 | this->BeginX = NewElts; |
43 | this->CapacityX = (char*)this->BeginX + NewCapacityInBytes; |
44 | } |