1// RUN: %check_clang_tidy %s misc-const-correctness %t \
2// RUN: -config='{CheckOptions: {\
3// RUN: misc-const-correctness.AnalyzeValues: false,\
4// RUN: misc-const-correctness.AnalyzeReferences: false,\
5// RUN: misc-const-correctness.AnalyzePointers: true,\
6// RUN: misc-const-correctness.WarnPointersAsValues: true,\
7// RUN: misc-const-correctness.WarnPointersAsPointers: true,\
8// RUN: misc-const-correctness.TransformPointersAsValues: true,\
9// RUN: misc-const-correctness.TransformPointersAsPointers: true\
10// RUN: }}' \
11// RUN: -- -fno-delayed-template-parsing
12
13void pointee_to_const() {
14 int a[] = {1, 2};
15 int *p_local0 = &a[0];
16 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: pointee of variable 'p_local0' of type 'int *' can be declared 'const'
17 // CHECK-MESSAGES: [[@LINE-2]]:3: warning: variable 'p_local0' of type 'int *' can be declared 'const'
18 // CHECK-FIXES: int const*const p_local0 = &a[0];
19}
20

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers-values.cpp