aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-30 18:56:13 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-30 18:56:13 +0000
commitf540305c5d834ad9412b41805b81a74249b7c5af (patch)
tree1de198a9d3c8ac599ac506de37b77b1c938e077d /lib
parent8891c4277a2e5b729214165414dcfe929b06e9b0 (diff)
Introduce new AST statistics that keep track of the number of isa (or
dyn_cast) invocations for C++ and Objective-C types, declarations, expressions, and statements. The statistics will be printed when -print-stats is provided to Clang -cc1, with results such as: 277073 clang - Number of checks for C++ declaration nodes 13311 clang - Number of checks for C++ expression nodes 18 clang - Number of checks for C++ statement nodes 174182 clang - Number of checks for C++ type nodes 92300 clang - Number of checks for Objective-C declaration nodes 9800 clang - Number of checks for Objective-C expression nodes 7 clang - Number of checks for Objective-C statement nodes 65733 clang - Number of checks for Objective-C type nodes The statistics are only gathered when NDEBUG is not defined, since they introduce potentially-expensive operations into very low-level routines (isa). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/DeclBase.cpp7
-rw-r--r--lib/AST/Expr.cpp7
-rw-r--r--lib/AST/Stmt.cpp7
-rw-r--r--lib/AST/Type.cpp7
4 files changed, 28 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index c693e153dd..522875f64f 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -35,6 +35,13 @@ using namespace clang;
// Statistics
//===----------------------------------------------------------------------===//
+#ifndef NDEBUG
+llvm::Statistic clang::objc_decl_checks =
+ { "clang", "Number of checks for Objective-C declaration nodes", 0, 0 };
+llvm::Statistic clang::cxx_decl_checks =
+ { "clang", "Number of checks for C++ declaration nodes", 0, 0 };
+#endif
+
#define DECL(Derived, Base) static int n##Derived##s = 0;
#include "clang/AST/DeclNodes.def"
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index b4e5a5d960..935a2080dc 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -27,6 +27,13 @@
#include <algorithm>
using namespace clang;
+#ifndef NDEBUG
+llvm::Statistic clang::objc_expr_checks =
+ { "clang", "Number of checks for Objective-C expression nodes", 0, 0 };
+llvm::Statistic clang::cxx_expr_checks =
+ { "clang", "Number of checks for C++ expression nodes", 0, 0 };
+#endif
+
//===----------------------------------------------------------------------===//
// Primary Expressions.
//===----------------------------------------------------------------------===//
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 8347249a46..bb6db228d2 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -22,6 +22,13 @@
#include <cstdio>
using namespace clang;
+#ifndef NDEBUG
+llvm::Statistic clang::objc_stmt_checks =
+ { "clang", "Number of checks for Objective-C statement nodes", 0, 0 };
+llvm::Statistic clang::cxx_stmt_checks =
+ { "clang", "Number of checks for C++ statement nodes", 0, 0 };
+#endif
+
static struct StmtClassNameTable {
const char *Name;
unsigned Counter;
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 8a64f8ea97..22dd2ecd64 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -22,6 +22,13 @@
#include "llvm/Support/raw_ostream.h"
using namespace clang;
+#ifndef NDEBUG
+llvm::Statistic clang::objc_type_checks =
+ { "clang", "Number of checks for Objective-C type nodes", 0, 0 };
+llvm::Statistic clang::cxx_type_checks =
+ { "clang", "Number of checks for C++ type nodes", 0, 0 };
+#endif
+
bool QualType::isConstant(QualType T, ASTContext &Ctx) {
if (T.isConstQualified())
return true;