blob: fc1abae302cb4c42e222c05bde178d923ce8fd83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
//===--- Statistics.h - Helpers for Clang AST Statistics --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file provides helper classes, functions, and macros for tracking
// various statistics about the Clang AST and its usage.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_STATISTICS_H
#define LLVM_CLANG_AST_STATISTICS_H
#define CLANG_C_ONLY 1
#ifndef NDEBUG
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Casting.h"
/** \brief Tracks the number of time the \c isa() function template is
* used to try to cast to the given \c Type, by bumping the \c Counter.
*
* Note that this macro must be expanded in the global scope, and that
* both the type and the counter will be assumed to reside within the
* \c clang namespace.
*/
#define CLANG_ISA_STATISTIC(Type,Counter) \
namespace llvm { \
template <typename From> \
struct isa_impl<clang::Type, From> { \
static inline bool doit(const From &Val) { \
++clang::Counter; \
return clang::Type::classof(&Val); \
} \
}; \
}
#elif defined(CLANG_C_ONLY)
#define CLANG_ISA_STATISTIC(Type,Counter) \
namespace llvm { \
template <typename From> \
struct isa_impl<clang::Type, From> { \
static inline bool doit(const From &Val) __attribute__((always_inline)) { \
return false; \
} \
}; \
}
#else
#define CLANG_ISA_STATISTIC(Type,Counter)
#endif
#endif // LLVM_CLANG_AST_STATISTICS_H
|