mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 17:06:46 +00:00

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
46 lines
1.9 KiB
Objective-C
46 lines
1.9 KiB
Objective-C
// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -verify -fblocks %s
|
|
// expected-no-diagnostics
|
|
|
|
// A bunch of misc. failures involving evaluating these expressions and
|
|
// building CFGs. These tests are here to prevent regressions.
|
|
typedef long long int64_t;
|
|
@class NSString, NSDictionary;
|
|
typedef long NSInteger;
|
|
typedef unsigned long NSUInteger;
|
|
typedef unsigned char Boolean;
|
|
typedef const struct __CFDictionary * CFDictionaryRef;
|
|
|
|
extern Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value);
|
|
void shazam(NSUInteger i, unsigned char **out);
|
|
|
|
void rdar_6440393_1(NSDictionary *dict) {
|
|
NSInteger x = 0;
|
|
unsigned char buf[10], *bufptr = buf;
|
|
if (!CFDictionaryGetValueIfPresent(0, dict, (void *)&x))
|
|
return;
|
|
shazam(x, &bufptr);
|
|
}
|
|
|
|
// In this example we got a signedness mismatch between the literal '0' and the
|
|
// value of 'scrooge'. The trick is to have the evaluator convert the literal
|
|
// to an unsigned integer when doing a comparison with the pointer. This
|
|
// happens because of the transfer function logic of
|
|
// OSAtomicCompareAndSwap64Barrier, which doesn't have special casts in place
|
|
// to do this for us.
|
|
_Bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
|
|
extern id objc_lookUpClass(const char *name);
|
|
void rdar_6845148(id debug_yourself) {
|
|
if (!debug_yourself) {
|
|
const char *wacky = ((void *)0);
|
|
Class scrooge = wacky ? (Class)objc_lookUpClass(wacky) : ((void *)0);
|
|
OSAtomicCompareAndSwap64Barrier(0, (int64_t)scrooge, (int64_t*)&debug_yourself);
|
|
}
|
|
}
|
|
void rdar_6845148_b(id debug_yourself) {
|
|
if (!debug_yourself) {
|
|
const char *wacky = ((void *)0);
|
|
Class scrooge = wacky ? (Class)objc_lookUpClass(wacky) : ((void *)0);
|
|
OSAtomicCompareAndSwap64Barrier((int64_t)scrooge, 0, (int64_t*)&debug_yourself);
|
|
}
|
|
}
|