/// are regarded as "referenced" but not "used".
unsigned Referenced : 1;
+ /// \brief Whether statistic collection is enabled.
+ static bool StatisticsEnabled;
+
protected:
/// Access - Used by C++ decls for the access specifier.
// NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
{
- if (Decl::CollectingStats()) add(DK);
+ if (StatisticsEnabled) add(DK);
}
Decl(Kind DK, EmptyShell Empty)
IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
HasCachedLinkage(0)
{
- if (Decl::CollectingStats()) add(DK);
+ if (StatisticsEnabled) add(DK);
}
virtual ~Decl();
// global temp stats (until we have a per-module visitor)
static void add(Kind k);
- static bool CollectingStats(bool Enable = false);
+ static void EnableStatistics();
static void PrintStats();
/// isTemplateParameter - Determines whether this declaration is a
/// de-serialization).
struct EmptyShell { };
+private:
+ /// \brief Whether statistic collection is enabled.
+ static bool StatisticsEnabled;
+
protected:
/// \brief Construct an empty statement.
explicit Stmt(StmtClass SC, EmptyShell) {
StmtBits.sClass = SC;
- if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
+ if (StatisticsEnabled) Stmt::addStmtClass(SC);
}
public:
Stmt(StmtClass SC) {
StmtBits.sClass = SC;
- if (Stmt::CollectingStats()) Stmt::addStmtClass(SC);
+ if (StatisticsEnabled) Stmt::addStmtClass(SC);
}
StmtClass getStmtClass() const {
// global temp stats (until we have a per-module visitor)
static void addStmtClass(const StmtClass s);
- static bool CollectingStats(bool Enable = false);
+ static void EnableStatistics();
static void PrintStats();
/// dump - This does a local dump of the specified AST fragment. It dumps the
#define ABSTRACT_DECL(DECL)
#include "clang/AST/DeclNodes.inc"
-static bool StatSwitch = false;
-
void *Decl::AllocateDeserializedDecl(const ASTContext &Context,
unsigned ID,
unsigned Size) {
}
}
-bool Decl::CollectingStats(bool Enable) {
- if (Enable) StatSwitch = true;
- return StatSwitch;
+bool Decl::StatisticsEnabled = false;
+void Decl::EnableStatistics() {
+ StatisticsEnabled = true;
}
void Decl::PrintStats() {
++getStmtInfoTableEntry(s).Counter;
}
-static bool StatSwitch = false;
-
-bool Stmt::CollectingStats(bool Enable) {
- if (Enable) StatSwitch = true;
- return StatSwitch;
+bool Stmt::StatisticsEnabled = false;
+void Stmt::EnableStatistics() {
+ StatisticsEnabled = true;
}
Stmt *Stmt::IgnoreImplicit() {
void clang::ParseAST(Sema &S, bool PrintStats) {
// Collect global stats on Decls/Stmts (until we have a module streamer).
if (PrintStats) {
- Decl::CollectingStats(true);
- Stmt::CollectingStats(true);
+ Decl::EnableStatistics();
+ Stmt::EnableStatistics();
}
// Also turn on collection of stats inside of the Sema object.