Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit cd92a65

Browse files
committed
Start switching the AST stats printing to use llvm::errs() instead of
fprintf. There is more cleanup to be done to the AST stats printing... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134373 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent de7738c commit cd92a65

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

lib/AST/ASTContext.cpp

+27-26
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ ASTContext::setExternalSource(llvm::OwningPtr<ExternalASTSource> &Source) {
289289
}
290290

291291
void ASTContext::PrintStats() const {
292-
fprintf(stderr, "*** AST Context Stats:\n");
293-
fprintf(stderr, " %d types total.\n", (int)Types.size());
292+
llvm::errs() << "\n*** AST Context Stats:\n";
293+
llvm::errs() << " " << Types.size() << " types total.\n";
294294

295295
unsigned counts[] = {
296296
#define TYPE(Name, Parent) 0,
@@ -308,40 +308,42 @@ void ASTContext::PrintStats() const {
308308
unsigned TotalBytes = 0;
309309
#define TYPE(Name, Parent) \
310310
if (counts[Idx]) \
311-
fprintf(stderr, " %d %s types\n", (int)counts[Idx], #Name); \
311+
llvm::errs() << " " << counts[Idx] << " " << #Name \
312+
<< " types\n"; \
312313
TotalBytes += counts[Idx] * sizeof(Name##Type); \
313314
++Idx;
314315
#define ABSTRACT_TYPE(Name, Parent)
315316
#include "clang/AST/TypeNodes.def"
316317

317-
fprintf(stderr, "Total bytes = %d\n", int(TotalBytes));
318-
318+
llvm::errs() << "Total bytes = " << TotalBytes << "\n";
319+
319320
// Implicit special member functions.
320-
fprintf(stderr, " %u/%u implicit default constructors created\n",
321-
NumImplicitDefaultConstructorsDeclared,
322-
NumImplicitDefaultConstructors);
323-
fprintf(stderr, " %u/%u implicit copy constructors created\n",
324-
NumImplicitCopyConstructorsDeclared,
325-
NumImplicitCopyConstructors);
321+
llvm::errs() << NumImplicitDefaultConstructorsDeclared << "/"
322+
<< NumImplicitDefaultConstructors
323+
<< " implicit default constructors created\n";
324+
llvm::errs() << NumImplicitCopyConstructorsDeclared << "/"
325+
<< NumImplicitCopyConstructors
326+
<< " implicit copy constructors created\n";
326327
if (getLangOptions().CPlusPlus)
327-
fprintf(stderr, " %u/%u implicit move constructors created\n",
328-
NumImplicitMoveConstructorsDeclared,
329-
NumImplicitMoveConstructors);
330-
fprintf(stderr, " %u/%u implicit copy assignment operators created\n",
331-
NumImplicitCopyAssignmentOperatorsDeclared,
332-
NumImplicitCopyAssignmentOperators);
328+
llvm::errs() << NumImplicitMoveConstructorsDeclared << "/"
329+
<< NumImplicitMoveConstructors
330+
<< " implicit move constructors created\n";
331+
llvm::errs() << NumImplicitCopyAssignmentOperatorsDeclared << "/"
332+
<< NumImplicitCopyAssignmentOperators
333+
<< " implicit copy assignment operators created\n";
333334
if (getLangOptions().CPlusPlus)
334-
fprintf(stderr, " %u/%u implicit move assignment operators created\n",
335-
NumImplicitMoveAssignmentOperatorsDeclared,
336-
NumImplicitMoveAssignmentOperators);
337-
fprintf(stderr, " %u/%u implicit destructors created\n",
338-
NumImplicitDestructorsDeclared, NumImplicitDestructors);
339-
335+
llvm::errs() << NumImplicitMoveAssignmentOperatorsDeclared << "/"
336+
<< NumImplicitMoveAssignmentOperators
337+
<< " implicit move assignment operators created\n";
338+
llvm::errs() << NumImplicitDestructorsDeclared << "/"
339+
<< NumImplicitDestructors
340+
<< " implicit destructors created\n";
341+
340342
if (ExternalSource.get()) {
341-
fprintf(stderr, "\n");
343+
llvm::errs() << "\n";
342344
ExternalSource->PrintStats();
343345
}
344-
346+
345347
BumpAlloc.PrintStats();
346348
}
347349

@@ -6478,4 +6480,3 @@ size_t ASTContext::getSideTableAllocatedMemory() const {
64786480
bytes += InstantiatedFromUnnamedFieldDecl.getMemorySize();
64796481
return bytes;
64806482
}
6481-

lib/Parse/ParseAST.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void clang::ParseAST(Sema &S, bool PrintStats) {
9797
Consumer->HandleTranslationUnit(S.getASTContext());
9898

9999
if (PrintStats) {
100-
fprintf(stderr, "\nSTATISTICS:\n");
100+
llvm::errs() << "\nSTATISTICS:\n";
101101
P.getActions().PrintStats();
102102
S.getASTContext().PrintStats();
103103
Decl::PrintStats();

0 commit comments

Comments
 (0)