}
}
+ // If we are storing the value into an auto function scope variable annotated
+ // with (__attribute__((cleanup))), stop tracking the value to avoid leak
+ // false positives.
+ if (const VarRegion *LVR = dyn_cast_or_null<VarRegion>(loc.getAsRegion())) {
+ const VarDecl *VD = LVR->getDecl();
+ if (VD->getAttr<CleanupAttr>()) {
+ escapes = true;
+ }
+ }
+
// If our store can represent the binding and we aren't storing to something
// that doesn't have local storage then just return and have the simulation
// state continue as is.
xpc_connection_set_finalizer_f(connection, releaseAfterXPC);
} // no-warning
+// Do not report leaks when object is cleaned up with __attribute__((cleanup ..)).
+inline static void cleanupFunction(void *tp) {
+ CFTypeRef x = *(CFTypeRef *)tp;
+ if (x) {
+ CFRelease(x);
+ }
+}
+#define ADDCLEANUP __attribute__((cleanup(cleanupFunction)))
+void foo() {
+ ADDCLEANUP CFStringRef myString;
+ myString = CFStringCreateWithCString(0, "hello world", kCFStringEncodingUTF8);
+ ADDCLEANUP CFStringRef myString2 =
+ CFStringCreateWithCString(0, "hello world", kCFStringEncodingUTF8);
+}
// CHECK: <key>diagnostics</key>
// CHECK-NEXT: <array>