summaryrefslogtreecommitdiffstats
path: root/lib/CrossTU/CrossTranslationUnit.cpp
diff options
context:
space:
mode:
authorGabor Marton <martongabesz@gmail.com>2018-12-07 14:56:02 +0000
committerGabor Marton <martongabesz@gmail.com>2018-12-07 14:56:02 +0000
commiteab2c7ba4dc75b5655adc74b1e89fbaf0a60f75e (patch)
tree3b0ded8c42641deca004f00a72513d3b1fcdb729 /lib/CrossTU/CrossTranslationUnit.cpp
parentecb70d1e9182f70e044f037e5e225c96dd06ef8f (diff)
[CTU] Add DisplayCTUProgress analyzer switch
Summary: With a new switch we may be able to print to stderr if a new TU is being loaded during CTU. This is very important for higher level scripts (like CodeChecker) to be able to parse this output so they can create e.g. a zip file in case of a Clang crash which contains all the related TU files. Reviewers: xazax.hun, Szelethus, a_sidorin, george.karpenkov Subscribers: whisperity, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, Differential Revision: https://reviews.llvm.org/D55135 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CrossTU/CrossTranslationUnit.cpp')
-rw-r--r--lib/CrossTU/CrossTranslationUnit.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/CrossTU/CrossTranslationUnit.cpp b/lib/CrossTU/CrossTranslationUnit.cpp
index 97563b05b0..7d4f0ec9b4 100644
--- a/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/lib/CrossTU/CrossTranslationUnit.cpp
@@ -159,7 +159,8 @@ CrossTranslationUnitContext::findFunctionInDeclContext(const DeclContext *DC,
llvm::Expected<const FunctionDecl *>
CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
StringRef CrossTUDir,
- StringRef IndexName) {
+ StringRef IndexName,
+ bool DisplayCTUProgress) {
assert(FD && "FD is missing, bad call to this function!");
assert(!FD->hasBody() && "FD has a definition in current translation unit!");
++NumGetCTUCalled;
@@ -168,7 +169,7 @@ CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
return llvm::make_error<IndexError>(
index_error_code::failed_to_generate_usr);
llvm::Expected<ASTUnit *> ASTUnitOrError =
- loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+ loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
if (!ASTUnitOrError)
return ASTUnitOrError.takeError();
ASTUnit *Unit = *ASTUnitOrError;
@@ -205,7 +206,8 @@ void CrossTranslationUnitContext::emitCrossTUDiagnostics(const IndexError &IE) {
}
llvm::Expected<ASTUnit *> CrossTranslationUnitContext::loadExternalAST(
- StringRef LookupName, StringRef CrossTUDir, StringRef IndexName) {
+ StringRef LookupName, StringRef CrossTUDir, StringRef IndexName,
+ bool DisplayCTUProgress) {
// FIXME: The current implementation only supports loading functions with
// a lookup name from a single translation unit. If multiple
// translation units contains functions with the same lookup name an
@@ -247,6 +249,10 @@ llvm::Expected<ASTUnit *> CrossTranslationUnitContext::loadExternalAST(
ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
Unit = LoadedUnit.get();
FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);
+ if (DisplayCTUProgress) {
+ llvm::errs() << "CTU loaded AST file: "
+ << ASTFileName << "\n";
+ }
} else {
Unit = ASTCacheEntry->second.get();
}