diff options
author | Gabor Marton <martongabesz@gmail.com> | 2018-12-07 11:55:22 +0000 |
---|---|---|
committer | Gabor Marton <martongabesz@gmail.com> | 2018-12-07 11:55:22 +0000 |
commit | fd01d8b9288b3558a597daeb0cb4481b37c5bf68 (patch) | |
tree | cf5b1db5746499243631dc9766e848aacbb31aec /lib/CrossTU/CrossTranslationUnit.cpp | |
parent | 4989c6df621c54e0975635284e20b04b52a420a9 (diff) |
[CTU] Add statistics
Reviewers: xazax.hun, a_sidorin
Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits
Differential Revision: https://reviews.llvm.org/D55133
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CrossTU/CrossTranslationUnit.cpp')
-rw-r--r-- | lib/CrossTU/CrossTranslationUnit.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/CrossTU/CrossTranslationUnit.cpp b/lib/CrossTU/CrossTranslationUnit.cpp index e20ea77022..08c9d99ec9 100644 --- a/lib/CrossTU/CrossTranslationUnit.cpp +++ b/lib/CrossTU/CrossTranslationUnit.cpp @@ -21,6 +21,7 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Index/USRGeneration.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/Statistic.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" @@ -32,6 +33,15 @@ namespace clang { namespace cross_tu { namespace { +#define DEBUG_TYPE "CrossTranslationUnit" +STATISTIC(NumGetCTUCalled, "The # of getCTUDefinition function called"); +STATISTIC( + NumNotInOtherTU, + "The # of getCTUDefinition called but the function is not in any other TU"); +STATISTIC(NumGetCTUSuccess, + "The # of getCTUDefinition successfully returned the " + "requested function's body"); + // FIXME: This class is will be removed after the transition to llvm::Error. class IndexErrorCategory : public std::error_category { public: @@ -151,6 +161,7 @@ CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD, StringRef CrossTUDir, StringRef IndexName) { assert(!FD->hasBody() && "FD has a definition in current translation unit!"); + ++NumGetCTUCalled; const std::string LookupFnName = getLookupName(FD); if (LookupFnName.empty()) return llvm::make_error<IndexError>( @@ -216,8 +227,10 @@ llvm::Expected<ASTUnit *> CrossTranslationUnitContext::loadExternalAST( } auto It = FunctionFileMap.find(LookupName); - if (It == FunctionFileMap.end()) + if (It == FunctionFileMap.end()) { + ++NumNotInOtherTU; return llvm::make_error<IndexError>(index_error_code::missing_definition); + } StringRef ASTFileName = It->second; auto ASTCacheEntry = FileASTUnitMap.find(ASTFileName); if (ASTCacheEntry == FileASTUnitMap.end()) { @@ -250,6 +263,7 @@ CrossTranslationUnitContext::importDefinition(const FunctionDecl *FD) { cast<FunctionDecl>(Importer.Import(const_cast<FunctionDecl *>(FD))); assert(ToDecl->hasBody()); assert(FD->hasBody() && "Functions already imported should have body."); + ++NumGetCTUSuccess; return ToDecl; } |