Debian Codegraph @

clang/lib/Analysis/LifetimeSafety/LifetimeStats.cpp

raw
1 //===- LifetimeStats.cpp - Lifetime Safety Statistics -*------------ C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the data structures and utility function for collection of
10 // staticstics related to Lifetimesafety analysis.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "clang/Analysis/Analyses/LifetimeSafety/LifetimeStats.h"
15 #include "clang/AST/TypeBase.h"
16 #include "llvm/Support/raw_ostream.h"
17
18 namespace clang::lifetimes {
19 void printStats(const LifetimeSafetyStats &Stats) {
20 llvm::errs() << "\n*** LifetimeSafety Missing Origin per QualType: "
21 "(QualType : count) :\n\n";
22 unsigned TotalMissingOrigins = 0;
23 for (const auto &[ExprType, MissingOriginCount] :
24 Stats.ExprTypeToMissingOriginCount) {
25 QualType QT = QualType(ExprType, 0);
26 llvm::errs() << QT.getAsString() << " : " << MissingOriginCount << '\n';
27 TotalMissingOrigins += MissingOriginCount;
28 }
29 llvm::errs() << "\n\n*** LifetimeSafety Missing Origin per StmtClassName: "
30 "(StmtClassName : count) :\n\n";
31 for (const auto &[ExprStmtClassName, MissingOriginCount] :
32 Stats.ExprStmtClassToMissingOriginCount) {
33 llvm::errs() << ExprStmtClassName << " : " << MissingOriginCount << '\n';
34 }
35 llvm::errs() << "\nTotal missing origins: " << TotalMissingOrigins << "\n";
36 llvm::errs() << "\n****************************************\n";
37 }
38 } // namespace clang::lifetimes