llvm-project/clang/test/Analysis/region-store.c
Aaron Ballman 0f1c1be196 [clang] Remove rdar links; NFC
We have a new policy in place making links to private resources
something we try to avoid in source and test files. Normally, we'd
organically switch to the new policy rather than make a sweeping change
across a project. However, Clang is in a somewhat special circumstance
currently: recently, I've had several new contributors run into rdar
links around test code which their patch was changing the behavior of.
This turns out to be a surprisingly bad experience, especially for
newer folks, for a handful of reasons: not understanding what the link
is and feeling intimidated by it, wondering whether their changes are
actually breaking something important to a downstream in some way,
having to hunt down strangers not involved with the patch to impose on
them for help, accidental pressure from asking for potentially private
IP to be made public, etc. Because folks run into these links entirely
by chance (through fixing bugs or working on new features), there's not
really a set of problematic links to focus on -- all of the links have
basically the same potential for causing these problems. As a result,
this is an omnibus patch to remove all such links.

This was not a mechanical change; it was done by manually searching for
rdar, radar, radr, and other variants to find all the various
problematic links. From there, I tried to retain or reword the
surrounding comments so that we would lose as little context as
possible. However, because most links were just a plain link with no
supporting context, the majority of the changes are simple removals.

Differential Review: https://reviews.llvm.org/D158071
2023-08-28 12:13:42 -04:00

81 lines
2.7 KiB
C

// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection \
// RUN: -verify -analyzer-config eagerly-assume=false -std=c99 %s \
// RUN: -Wno-implicit-function-declaration
int printf(const char *restrict,...);
void clang_analyzer_eval(int);
void clang_analyzer_dump(int*);
// Testing core functionality of the region store.
int compoundLiteralTest(void) {
int index = 0;
for (index = 0; index < 2; index++) {
int thing = (int []){0, 1}[index];
printf("thing: %i\n", thing);
}
return 0;
}
int compoundLiteralTest2(void) {
int index = 0;
for (index = 0; index < 3; index++) {
int thing = (int [][3]){{0,0,0}, {1,1,1}, {2,2,2}}[index][index];
printf("thing: %i\n", thing);
}
return 0;
}
int concreteOffsetBindingIsInvalidatedBySymbolicOffsetAssignment(int length,
int i) {
int values[length];
values[i] = 4;
return values[0]; // no-warning
}
struct X{
int mem;
};
int initStruct(struct X *st);
int structOffsetBindingIsInvalidated(int length, int i){
struct X l;
initStruct(&l);
return l.mem; // no-warning
}
void testConstraintOnRegionOffset(int *values, int length, int i){
if (values[1] == 4) {
values[i] = 5;
clang_analyzer_eval(values[1] == 4);// expected-warning {{UNKNOWN}}
}
}
int initArray(int *values);
void testConstraintOnRegionOffsetStack(int *values, int length, int i) {
if (values[0] == 4) {
initArray(values);
clang_analyzer_eval(values[0] == 4);// expected-warning {{UNKNOWN}}
}
}
int buffer[10];
void b(); // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent definition}}
void missingPrototypeCallsiteMatchingArgsAndParams() {
// expected-warning@+1 {{passing arguments to 'b' without a prototype is deprecated in all versions of C and is not supported in C23}}
b(&buffer);
}
void b(int *c) { // expected-note {{conflicting prototype is here}}
clang_analyzer_dump(c); // expected-warning {{&Element{buffer,0 S64b,int}}}
*c = 42; // no-crash
}
void c(); // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a subsequent definition}}
void missingPrototypeCallsiteMismatchingArgsAndParams() {
// expected-warning@+1 {{passing arguments to 'c' without a prototype is deprecated in all versions of C and is not supported in C23}}
c(&buffer, &buffer);
}
void c(int *c) { // expected-note {{conflicting prototype is here}}
clang_analyzer_dump(c); // expected-warning {{Unknown}}
*c = 42; // no-crash
}