~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to clang/test/Analysis/retain-release.mm

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
enum {
84
84
kCFStringEncodingMacRoman = 0,     kCFStringEncodingWindowsLatin1 = 0x0500,     kCFStringEncodingISOLatin1 = 0x0201,     kCFStringEncodingNextStepLatin = 0x0B01,     kCFStringEncodingASCII = 0x0600,     kCFStringEncodingUnicode = 0x0100,     kCFStringEncodingUTF8 = 0x08000100,     kCFStringEncodingNonLossyASCII = 0x0BFF      ,     kCFStringEncodingUTF16 = 0x0100,     kCFStringEncodingUTF16BE = 0x10000100,     kCFStringEncodingUTF16LE = 0x14000100,      kCFStringEncodingUTF32 = 0x0c000100,     kCFStringEncodingUTF32BE = 0x18000100,     kCFStringEncodingUTF32LE = 0x1c000100  };
85
85
extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
 
86
extern CFStringRef CFStringCreateCopy(CFAllocatorRef alloc, CFStringRef theString);
86
87
typedef double CFTimeInterval;
87
88
typedef CFTimeInterval CFAbsoluteTime;
88
89
extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
269
270
    CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
270
271
    CGGradientDrawingOptions options);
271
272
extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
272
 
 
273
273
//===----------------------------------------------------------------------===//
274
274
// Test cases.
275
275
//===----------------------------------------------------------------------===//
408
408
}
409
409
@end
410
410
 
 
411
//===----------------------------------------------------------------------===//
 
412
// Don't crash on getting a null expression from CallEnter corresponding to a
 
413
// destructor.
 
414
//===----------------------------------------------------------------------===//
 
415
 
 
416
template <typename X>
 
417
class Holder {
 
418
public:
 
419
        Holder() throw();
 
420
        ~Holder() throw() {}
 
421
        X* get() const throw();
 
422
        void reset(X* p) throw();
 
423
private:
 
424
        X* ptr_;
 
425
};
 
426
 
 
427
template<typename X>
 
428
inline
 
429
Holder<X>::Holder() throw()
 
430
: ptr_(0){}
 
431
 
 
432
template <typename X>
 
433
inline
 
434
X* Holder<X>::get() const throw() {
 
435
        return ptr_;
 
436
}
 
437
 
 
438
template <typename X>
 
439
inline
 
440
void Holder<X>::reset(X* p) throw() {
 
441
        if (ptr_ != p) {
 
442
                if (ptr_ != 0) {
 
443
                        ::CFRelease( ptr_ );
 
444
                }
 
445
                ptr_ = p;
 
446
        }
 
447
}
 
448
 
 
449
class radar13722286 {
 
450
public:
 
451
  radar13722286() {}
 
452
private:
 
453
        void                    PrepareBitmap();
 
454
        Holder<const struct __CFString> mStr;
 
455
};
 
456
 
 
457
void    radar13722286::PrepareBitmap() {
 
458
        if (mStr.get() != 0) {
 
459
                Holder<const struct __CFString> str1;
 
460
                mStr.reset( CFStringCreateCopy( 0, str1.get() ) ); //expected-warning {{Potential leak of an object}}
 
461
        }
 
462
}
 
463