Skip to content

Commit 3529c65

Browse files
committed
updated documentation, renamed option
1 parent 00ae0c6 commit 3529c65

File tree

6 files changed

+30
-29
lines changed

6 files changed

+30
-29
lines changed

clang/docs/analyzer/checkers.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,13 @@ as error. Specifically on x86/x86-64 target if the pointer address space is
162162
256 (x86 GS Segment), 257 (x86 FS Segment), or 258 (x86 SS Segment), a null
163163
dereference is not defined as error. See `X86/X86-64 Language Extensions
164164
<https://clang.llvm.org/docs/LanguageExtensions.html#memory-references-to-specified-segments>`__
165-
for reference. The ``suppress-all-address-spaces`` configuration option can be
166-
used to control if null dereferences with any address space or only with the
167-
specific x86 address spaces 256, 257, 258 are excluded from reporting as error.
168-
The default is all address spaces.
165+
for reference.
166+
167+
If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
168+
to true (the default value), then this checker never reports dereference of
169+
pointers with a specified address space. If the option is set to false, then
170+
reports from the specific x86 address spaces 256, 257 and 258 are still
171+
suppressed, but null dereferences from other address spaces are reported.
169172
170173
.. _core-StackAddressEscape:
171174
@@ -2944,10 +2947,12 @@ value.
29442947
int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
29452948
}
29462949
2947-
The analyzer option ``suppress-all-address-spaces`` affects this checker. If it
2948-
is set to true pointer dereferences with any address space are not reported as
2949-
error. Otherwise only address spaces 256, 257, 258 on target x86/x86-64 are
2950-
excluded from reporting as error. The default is all address spaces.
2950+
If the analyzer option ``suppress-dereferences-from-any-address-space`` is set
2951+
to true (the default value), then this checker never reports dereference of
2952+
pointers with a specified address space. If the option is set to false, then
2953+
reports from the specific x86 address spaces 256, 257 and 258 are still
2954+
suppressed, but fixed address dereferences from other address spaces are
2955+
reported.
29512956
29522957
.. _alpha-core-PointerArithm:
29532958

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ ANALYZER_OPTION(
396396
true)
397397

398398
ANALYZER_OPTION(
399-
bool, ShouldSuppressAddressSpaces, "suppress-all-address-spaces",
399+
bool, ShouldSuppressAddressSpaceDereferences, "suppress-dereferences-from-any-address-space",
400400
"The analyzer does not report dereferences on memory that use "
401401
"address space #256, #257, and #258. Those address spaces are used when "
402402
"dereferencing address spaces relative to the GS, FS, and SS segments on "

clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ bool DereferenceChecker::suppressReport(CheckerContext &C,
135135
QualType Ty = E->getType();
136136
if (!Ty.hasAddressSpace())
137137
return false;
138-
if (C.getAnalysisManager().getAnalyzerOptions().ShouldSuppressAddressSpaces)
138+
if (C.getAnalysisManager()
139+
.getAnalyzerOptions()
140+
.ShouldSuppressAddressSpaceDereferences)
139141
return true;
140142

141143
const llvm::Triple::ArchType Arch =

clang/test/Analysis/analyzer-config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@
123123
// CHECK-NEXT: silence-checkers = ""
124124
// CHECK-NEXT: stable-report-filename = false
125125
// CHECK-NEXT: support-symbolic-integer-casts = false
126-
// CHECK-NEXT: suppress-all-address-spaces = true
127126
// CHECK-NEXT: suppress-c++-stdlib = true
127+
// CHECK-NEXT: suppress-dereferences-from-any-address-space = true
128128
// CHECK-NEXT: suppress-inlined-defensive-checks = true
129129
// CHECK-NEXT: suppress-null-return-paths = true
130130
// CHECK-NEXT: track-conditions = true

clang/test/Analysis/cast-value-notes.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
//
55
// RUN: %clang_analyze_cc1 -std=c++14 -triple amdgcn-unknown-unknown \
66
// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
7-
// RUN: -analyzer-config suppress-all-address-spaces=false\
7+
// RUN: -analyzer-config suppress-dereferences-from-any-address-space=false\
88
// RUN: -analyzer-output=text -verify -DX86 -DNOT_SUPPRESSED %s 2>&1 | FileCheck %s -check-prefix=X86-CHECK
99
//
1010
// RUN: %clang_analyze_cc1 -std=c++14 -triple amdgcn-unknown-unknown \
1111
// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
12-
// RUN: -analyzer-config suppress-all-address-spaces=true\
12+
// RUN: -analyzer-config suppress-dereferences-from-any-address-space=true\
1313
// RUN: -analyzer-output=text -verify -DX86 -DSUPPRESSED %s 2>&1 | FileCheck %s -check-prefix=X86-CHECK
1414
//
1515
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-unknown \
@@ -18,12 +18,12 @@
1818
//
1919
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-unknown \
2020
// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
21-
// RUN: -analyzer-config suppress-all-address-spaces=true\
21+
// RUN: -analyzer-config suppress-dereferences-from-any-address-space=true\
2222
// RUN: -analyzer-output=text -verify -DX86 -DSUPPRESSED %s 2>&1 | FileCheck %s --check-prefix=X86-CHECK-SUPPRESSED
2323
//
2424
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-unknown \
2525
// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
26-
// RUN: -analyzer-config suppress-all-address-spaces=false\
26+
// RUN: -analyzer-config suppress-dereferences-from-any-address-space=false\
2727
// RUN: -analyzer-output=text -verify -DX86 -DNOT_SUPPRESSED %s 2>&1 | FileCheck %s --check-prefix=X86-CHECK
2828
//
2929
// RUN: %clang_analyze_cc1 -std=c++14 -triple mips-unknown-unknown \
@@ -32,12 +32,12 @@
3232
//
3333
// RUN: %clang_analyze_cc1 -std=c++14 -triple mips-unknown-unknown \
3434
// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
35-
// RUN: -analyzer-config suppress-all-address-spaces=false\
35+
// RUN: -analyzer-config suppress-dereferences-from-any-address-space=false\
3636
// RUN: -analyzer-output=text -verify -DMIPS %s 2>&1
3737
//
3838
// RUN: %clang_analyze_cc1 -std=c++14 -triple mips-unknown-unknown \
3939
// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
40-
// RUN: -analyzer-config suppress-all-address-spaces=true\
40+
// RUN: -analyzer-config suppress-dereferences-from-any-address-space=true\
4141
// RUN: -analyzer-output=text -verify -DMIPS_SUPPRESSED %s
4242

4343
#include "Inputs/llvm.h"

clang/test/Analysis/suppress-all-address-spaces.c renamed to clang/test/Analysis/suppress-dereferences-from-any-address-space.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-config suppress-all-address-spaces=false -verify=x86-nosuppress %s
2-
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -verify=x86-suppress %s
3-
// RUN: %clang_analyze_cc1 -triple arm-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-config suppress-all-address-spaces=false -verify=other-nosuppress %s
4-
// RUN: %clang_analyze_cc1 -triple arm-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -verify=other-suppress %s
1+
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-config suppress-dereferences-from-any-address-space=false -verify=x86-nosuppress,common %s
2+
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -verify=x86-suppress,common %s
3+
// RUN: %clang_analyze_cc1 -triple arm-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-config suppress-dereferences-from-any-address-space=false -verify=other-nosuppress,common %s
4+
// RUN: %clang_analyze_cc1 -triple arm-pc-linux-gnu -analyzer-checker=core,alpha.core -std=gnu99 -verify=other-suppress,common %s
55

66
#define AS_ATTRIBUTE(_X) volatile __attribute__((address_space(_X)))
77

@@ -34,10 +34,7 @@ void test_other_address_space_condition(int AS_ATTRIBUTE(259) *cpu_data) {
3434

3535
void test_no_address_space_condition(int *cpu_data) {
3636
if (cpu_data == 0) {
37-
*cpu_data = 3; // other-nosuppress-warning{{Dereference}} \
38-
// x86-nosuppress-warning{{Dereference}} \
39-
// other-suppress-warning{{Dereference}} \
40-
// x86-suppress-warning{{Dereference}}
37+
*cpu_data = 3; // common-warning{{Dereference}}
4138
}
4239
}
4340

@@ -69,9 +66,6 @@ void fixed_test_other_address_space_condition(int AS_ATTRIBUTE(259) *cpu_data) {
6966

7067
void fixed_test_no_address_space_condition(int *cpu_data) {
7168
if (cpu_data == (int *)2) {
72-
*cpu_data = 3; // other-nosuppress-warning{{Dereference}} \
73-
// x86-nosuppress-warning{{Dereference}} \
74-
// other-suppress-warning{{Dereference}} \
75-
// x86-suppress-warning{{Dereference}}
69+
*cpu_data = 3; // common-warning{{Dereference}}
7670
}
7771
}

0 commit comments

Comments
 (0)