[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / retain-release-cpp-classes.cpp
blob9ed1c0b3b5672f2cc72fad02f5424f33e7b66f1a
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-output=text -verify %s
3 // expected-no-diagnostics
5 typedef void *CFTypeRef;
6 typedef struct _CFURLCacheRef *CFURLCacheRef;
8 CFTypeRef CustomCFRetain(CFTypeRef);
9 void invalidate(void *);
10 struct S1 {
11 CFTypeRef s;
12 CFTypeRef returnFieldAtPlus0() {
13 return s;
16 struct S2 {
17 S1 *s1;
19 void foo(S1 *s1) {
20 invalidate(s1);
21 S2 s2;
22 s2.s1 = s1;
23 CustomCFRetain(s1->returnFieldAtPlus0());
25 // Definitely no leak end-of-path note here. The retained pointer
26 // is still accessible through s1 and s2.
27 ((void) 0); // no-warning
29 // FIXME: Ideally we need to warn after this invalidate(). The per-function
30 // retain-release contract is violated: the programmer should release
31 // the symbol after it was retained, within the same function.
32 invalidate(&s2);