Retires ui::TranslatedKeyEvent and replaces it with KeyEvent.
[chromium-blink-merge.git] / base / debug / leak_annotations.h
blob27fe663bddb202657d5b8bdff152223891ee7b71
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_DEBUG_LEAK_ANNOTATIONS_H_
6 #define BASE_DEBUG_LEAK_ANNOTATIONS_H_
8 #include "base/basictypes.h"
9 #include "build/build_config.h"
11 // This file defines macros which can be used to annotate intentional memory
12 // leaks. Support for annotations is implemented in LeakSanitizer. Annotated
13 // objects will be treated as a source of live pointers, i.e. any heap objects
14 // reachable by following pointers from an annotated object will not be
15 // reported as leaks.
17 // ANNOTATE_SCOPED_MEMORY_LEAK: all allocations made in the current scope
18 // will be annotated as leaks.
19 // ANNOTATE_LEAKING_OBJECT_PTR(X): the heap object referenced by pointer X will
20 // be annotated as a leak.
22 #if defined(LEAK_SANITIZER) && !defined(OS_NACL)
24 // Public LSan API from <sanitizer/lsan_interface.h>.
25 extern "C" {
26 void __lsan_disable();
27 void __lsan_enable();
28 void __lsan_ignore_object(const void *p);
30 // Invoke leak detection immediately. If leaks are found, the process will exit.
31 void __lsan_do_leak_check();
32 } // extern "C"
34 class ScopedLeakSanitizerDisabler {
35 public:
36 ScopedLeakSanitizerDisabler() { __lsan_disable(); }
37 ~ScopedLeakSanitizerDisabler() { __lsan_enable(); }
38 private:
39 DISALLOW_COPY_AND_ASSIGN(ScopedLeakSanitizerDisabler);
42 #define ANNOTATE_SCOPED_MEMORY_LEAK \
43 ScopedLeakSanitizerDisabler leak_sanitizer_disabler; static_cast<void>(0)
45 #define ANNOTATE_LEAKING_OBJECT_PTR(X) __lsan_ignore_object(X);
47 #else
49 // If neither HeapChecker nor LSan are used, the annotations should be no-ops.
50 #define ANNOTATE_SCOPED_MEMORY_LEAK ((void)0)
51 #define ANNOTATE_LEAKING_OBJECT_PTR(X) ((void)0)
53 #endif
55 #endif // BASE_DEBUG_LEAK_ANNOTATIONS_H_