Bug Summary

File:tools/polly/lib/External/ppcg/gpu_array_tile.c
Warning:line 14, column 16
Dereference of null pointer

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name gpu_array_tile.c -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=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~svn324650/build-llvm/tools/polly/lib/External -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/pet/include -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/ppcg/include -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/ppcg/imath -I /build/llvm-toolchain-snapshot-7~svn324650/build-llvm/tools/polly/lib/External/ppcg -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/isl -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/isl/include -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/isl/imath -I /build/llvm-toolchain-snapshot-7~svn324650/build-llvm/tools/polly/lib/External/isl -I /build/llvm-toolchain-snapshot-7~svn324650/build-llvm/tools/polly/include -I /usr/include/jsoncpp -I /build/llvm-toolchain-snapshot-7~svn324650/build-llvm/tools/polly/lib/External/isl/include -I /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/include -I /build/llvm-toolchain-snapshot-7~svn324650/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn324650/include -U NDEBUG -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-comment -fconst-strings -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn324650/build-llvm/tools/polly/lib/External -fdebug-prefix-map=/build/llvm-toolchain-snapshot-7~svn324650=. -ferror-limit 19 -fmessage-length 0 -stack-protector 2 -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-02-09-212803-22585-1 -x c /build/llvm-toolchain-snapshot-7~svn324650/tools/polly/lib/External/ppcg/gpu_array_tile.c
1#include <isl/aff.h>
2#include <isl/map.h>
3
4#include "gpu_array_tile.h"
5
6struct gpu_array_tile *gpu_array_tile_free(struct gpu_array_tile *tile)
7{
8 int j;
9
10 if (!tile)
7
Taking false branch
11 return NULL((void*)0);
12
13 for (j = 0; j < tile->n; ++j) {
8
Assuming the condition is true
9
Loop condition is true. Entering loop body
14 isl_val_free(tile->bound[j].size);
10
Dereference of null pointer
15 isl_val_free(tile->bound[j].stride);
16 isl_aff_free(tile->bound[j].lb);
17 isl_aff_free(tile->bound[j].shift);
18 }
19 free(tile->bound);
20 isl_multi_aff_free(tile->tiling);
21 free(tile);
22
23 return NULL((void*)0);
24}
25
26/* Create a gpu_array_tile for an array of dimension "n_index".
27 */
28struct gpu_array_tile *gpu_array_tile_create(isl_ctx *ctx, int n_index)
29{
30 int i;
31 struct gpu_array_tile *tile;
32
33 tile = isl_calloc_type(ctx, struct gpu_array_tile)((struct gpu_array_tile *)isl_calloc_or_die(ctx, 1, sizeof(struct
gpu_array_tile)))
;
34 if (!tile)
1
Assuming 'tile' is non-null
2
Taking false branch
35 return NULL((void*)0);
36
37 tile->ctx = ctx;
38 tile->bound = isl_alloc_array(ctx, struct gpu_array_bound, n_index)((struct gpu_array_bound *)isl_malloc_or_die(ctx, (n_index)*sizeof
(struct gpu_array_bound)))
;
3
Value assigned to field 'bound'
39 if (!tile->bound)
4
Assuming pointer value is null
5
Taking true branch
40 return gpu_array_tile_free(tile);
6
Calling 'gpu_array_tile_free'
41
42 tile->n = n_index;
43
44 for (i = 0; i < n_index; ++i) {
45 tile->bound[i].size = NULL((void*)0);
46 tile->bound[i].lb = NULL((void*)0);
47 tile->bound[i].stride = NULL((void*)0);
48 tile->bound[i].shift = NULL((void*)0);
49 }
50
51 return tile;
52}
53
54/* Compute the size of the tile specified by "tile"
55 * in number of elements and return the result.
56 */
57__isl_give isl_val *gpu_array_tile_size(struct gpu_array_tile *tile)
58{
59 int i;
60 isl_val *size;
61
62 if (!tile)
63 return NULL((void*)0);
64
65 size = isl_val_one(tile->ctx);
66
67 for (i = 0; i < tile->n; ++i)
68 size = isl_val_mul(size, isl_val_copy(tile->bound[i].size));
69
70 return size;
71}