clang 22.0.0git
LifetimeStats.cpp
Go to the documentation of this file.
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
15#include "clang/AST/TypeBase.h"
16#include "llvm/Support/raw_ostream.h"
17
18namespace clang::lifetimes {
19void 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] :
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] :
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
C Language Family Type Representation.
A (possibly-)qualified type.
Definition TypeBase.h:937
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Definition TypeBase.h:1332
void printStats(const LifetimeSafetyStats &Stats)
Utility function to print missing origin stats.
A structure to hold the statistics related to LifetimeAnalysis.
llvm::StringMap< unsigned > ExprStmtClassToMissingOriginCount
A map from StmtClassName to their missing origin counts.
llvm::DenseMap< const clang::Type *, unsigned > ExprTypeToMissingOriginCount
A map from QualType to their missing origin counts.