[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL348594: [CTU] Add DisplayCTUProgress analyzer switch 
(authored by martong, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55135?vs=177204=177208#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135

Files:
  cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/ctu-main.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -283,6 +283,11 @@
 "expanded and included in the plist output.",
 false)
 
+ANALYZER_OPTION(bool, DisplayCTUProgress, "display-ctu-progress",
+"Whether to emit verbose output about "
+"the analyzer's progress related to ctu.",
+false)
+
 //===--===//
 // Unsinged analyzer options.
 //===--===//
Index: cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
===
--- cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
+++ cfe/trunk/include/clang/CrossTU/CrossTranslationUnit.h
@@ -108,7 +108,7 @@
   /// Note that the AST files should also be in the \p CrossTUDir.
   llvm::Expected
   getCrossTUDefinition(const FunctionDecl *FD, StringRef CrossTUDir,
-   StringRef IndexName);
+   StringRef IndexName, bool DisplayCTUProgress = false);
 
   /// This function loads a function definition from an external AST
   ///file.
@@ -124,7 +124,8 @@
   /// Note that the AST files should also be in the \p CrossTUDir.
   llvm::Expected loadExternalAST(StringRef LookupName,
 StringRef CrossTUDir,
-StringRef IndexName);
+StringRef IndexName,
+bool DisplayCTUProgress = false);
 
   /// This function merges a definition from a separate AST Unit into
   ///the current one which was created by the compiler instance that
Index: cfe/trunk/test/Analysis/analyzer-config.c
===
--- cfe/trunk/test/Analysis/analyzer-config.c
+++ cfe/trunk/test/Analysis/analyzer-config.c
@@ -21,6 +21,7 @@
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-index-name = externalFnMap.txt
+// CHECK-NEXT: display-ctu-progress = false
 // CHECK-NEXT: eagerly-assume = true
 // CHECK-NEXT: elide-constructors = true
 // CHECK-NEXT: expand-macros = false
@@ -51,4 +52,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 48
+// CHECK-NEXT: num-entries = 49
Index: cfe/trunk/test/Analysis/ctu-main.cpp
===
--- cfe/trunk/test/Analysis/ctu-main.cpp
+++ cfe/trunk/test/Analysis/ctu-main.cpp
@@ -10,6 +10,14 @@
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=%t/ctudir \
 // RUN:   -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -analyzer-config display-ctu-progress=true 2>&1 %s | FileCheck %s
+
+// CHECK: CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
===
--- cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
+++ cfe/trunk/lib/CrossTU/CrossTranslationUnit.cpp
@@ -159,7 +159,8 @@
 llvm::Expected
 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 

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 177204.
martong added a comment.

- Remove 'ANALYZE ' prefix from the log message


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,14 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%T/ctudir \
+// RUN:   -analyzer-config display-ctu-progress=true 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -21,6 +21,7 @@
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-index-name = externalFnMap.txt
+// CHECK-NEXT: display-ctu-progress = false
 // CHECK-NEXT: eagerly-assume = true
 // CHECK-NEXT: elide-constructors = true
 // CHECK-NEXT: expand-macros = false
@@ -51,4 +52,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 48
+// CHECK-NEXT: num-entries = 49
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,8 +560,8 @@
   cross_tu::CrossTranslationUnitContext  =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir,
-  Opts.CTUIndexName);
+  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName,
+  Opts.DisplayCTUProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected 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
@@ -233,6 +235,10 @@
   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();
 }
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===
--- 

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added a comment.

> While Static Analyzer is the only client of CTU library at the moment, we 
> might have more in the future. I would not use the phrase ANALYZE in the log 
> message. Once this is resolved the rest looks good.

Ok, I removed the "ANALYZE " prefix from the log message.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-07 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

While Static Analyzer is the only client of CTU library at the moment, we might 
have more in the future. I would not use the phrase `ANALYZE` in the log 
message.  Once this is resolved the rest looks good.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM! :)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> should be an -analyzer-config option.

Ok, just changed it to be.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 176653.
martong added a comment.

- Use clang_analyze_cc1
- Change to be an analyzer config option


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,14 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%T/ctudir \
+// RUN:   -analyzer-config display-ctu-progress=true 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -21,6 +21,7 @@
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-index-name = externalFnMap.txt
+// CHECK-NEXT: display-ctu-progress = false
 // CHECK-NEXT: eagerly-assume = true
 // CHECK-NEXT: elide-constructors = true
 // CHECK-NEXT: expand-macros = false
@@ -51,4 +52,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 48
+// CHECK-NEXT: num-entries = 49
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,8 +560,8 @@
   cross_tu::CrossTranslationUnitContext  =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir,
-  Opts.CTUIndexName);
+  CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName,
+  Opts.DisplayCTUProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected 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
@@ -233,6 +235,10 @@
   ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
   Unit = LoadedUnit.get();
   FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);
+  if (DisplayCTUProgress) {
+llvm::errs() << "ANALYZE CTU loaded AST file: "
+ << ASTFileName << "\n";
+  }
 } else {
   Unit = ASTCacheEntry->second.get();
 }
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.def

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Having an analyzer config option makes sense.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

The code not directly related to adding the actual flag looks great, but this 
still should be an `-analyzer-config` option.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Kristüf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/ctu-main.cpp:6
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+

martong wrote:
> martong wrote:
> > Szelethus wrote:
> > > I think these RUN lines would really benefit from introducing line breaks.
> > Yes, I agree. Unfortunately, I could not figure out how to break them. 
> > Using a simple "\" at around the 80th column gives `Test has unterminated 
> > run lines (with '\')`. If I use block comments with "\" the same happens. 
> > If I use block comments and don't use the "\" then the second line is not 
> > interpreted. Is it really possible to break RUN lines? I could not find 
> > anything about that in the online docs.
> Oh, I just have found your other comment to the other patch. So yes, it is 
> indeed possible to break this line. I updated the patch accordingly. The 
> other long lines which are already there I am going to change in an 
> independent patch: (https://reviews.llvm.org/D55129).
Is there any particular reason why we use `%clang_cc1 -analyze` as opposed to 
`%clang_analyze_cc1`? If not, lets change it.

By the way, thanks! This looks neat.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 176590.
martong marked an inline comment as done.
martong added a comment.

- Break long RUN line


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,14 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%T/ctudir \
+// RUN:   -analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,7 +560,8 @@
   cross_tu::CrossTranslationUnitContext  =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName());
+  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName(),
+  Opts.AnalyzerDisplayCTUProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -289,6 +289,8 @@
   Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
   Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
   Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
+  Opts.AnalyzerDisplayCTUProgress =
+  Args.hasArg(OPT_analyzer_display_ctu_progress);
   Opts.AnalyzeNestedBlocks =
 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
   Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected 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
@@ -233,6 +235,10 @@
   ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
   Unit = LoadedUnit.get();
   FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);
+  if (DisplayCTUProgress) {
+llvm::errs() << "ANALYZE CTU loaded AST file: "
+ << ASTFileName << "\n";
+  }
 } else {
   Unit = ASTCacheEntry->second.get();
 }
Index: 

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: test/Analysis/ctu-main.cpp:6
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+

martong wrote:
> Szelethus wrote:
> > I think these RUN lines would really benefit from introducing line breaks.
> Yes, I agree. Unfortunately, I could not figure out how to break them. Using 
> a simple "\" at around the 80th column gives `Test has unterminated run lines 
> (with '\')`. If I use block comments with "\" the same happens. If I use 
> block comments and don't use the "\" then the second line is not interpreted. 
> Is it really possible to break RUN lines? I could not find anything about 
> that in the online docs.
Oh, I just have found your other comment to the other patch. So yes, it is 
indeed possible to break this line. I updated the patch accordingly. The other 
long lines which are already there I am going to change in an independent 
patch: (https://reviews.llvm.org/D55129).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 176582.
martong added a comment.

- Change the CTU progress message in the test too


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE CTU loaded AST file: {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,7 +560,8 @@
   cross_tu::CrossTranslationUnitContext  =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName());
+  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName(),
+  Opts.AnalyzerDisplayCTUProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -289,6 +289,8 @@
   Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
   Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
   Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
+  Opts.AnalyzerDisplayCTUProgress =
+  Args.hasArg(OPT_analyzer_display_ctu_progress);
   Opts.AnalyzeNestedBlocks =
 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
   Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected 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
@@ -233,6 +235,10 @@
   ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
   Unit = LoadedUnit.get();
   FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);
+  if (DisplayCTUProgress) {
+llvm::errs() << "ANALYZE CTU loaded AST file: "
+ << ASTFileName << "\n";
+  }
 } else {
   Unit = ASTCacheEntry->second.get();
 }
Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 176581.
martong marked 4 inline comments as done.
martong added a comment.

- Rename AnalyzerDisplayCtuProgress to Opts.AnalyzerDisplayCTUProgress
- Change the CTU progress message


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE (CTU loaded AST for source file): {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE (CTU loaded AST for source file): {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,7 +560,8 @@
   cross_tu::CrossTranslationUnitContext  =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName());
+  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName(),
+  Opts.AnalyzerDisplayCTUProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -289,6 +289,8 @@
   Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
   Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
   Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
+  Opts.AnalyzerDisplayCTUProgress =
+  Args.hasArg(OPT_analyzer_display_ctu_progress);
   Opts.AnalyzeNestedBlocks =
 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
   Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected 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
@@ -233,6 +235,10 @@
   ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));
   Unit = LoadedUnit.get();
   FileASTUnitMap[ASTFileName] = std::move(LoadedUnit);
+  if (DisplayCTUProgress) {
+llvm::errs() << "ANALYZE CTU loaded AST file: "
+ << ASTFileName << "\n";
+  }
 } else {
   Unit = ASTCacheEntry->second.get();
 }

[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-04 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> Also, almost everywhere CTU is capitalized, so I guess it should be in the 
> field name too.

Ok, I renamed it to have CTU all capitalized.




Comment at: lib/CrossTU/CrossTranslationUnit.cpp:239
+  if (DisplayCTUProgress) {
+llvm::errs() << "ANALYZE (CTU loaded AST for source file): "
+ << ASTFileName << "\n";

a_sidorin wrote:
> I think we can remove parens from the message.
Ok, I removed the parens. And also changed the text from `CTU loaded AST for 
source file` to `CTU loaded AST file` since we dump the path to the AST, not 
the path to the source file from which we generated the AST file.



Comment at: test/Analysis/ctu-main.cpp:6
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+

Szelethus wrote:
> I think these RUN lines would really benefit from introducing line breaks.
Yes, I agree. Unfortunately, I could not figure out how to break them. Using a 
simple "\" at around the 80th column gives `Test has unterminated run lines 
(with '\')`. If I use block comments with "\" the same happens. If I use block 
comments and don't use the "\" then the second line is not interpreted. Is it 
really possible to break RUN lines? I could not find anything about that in the 
online docs.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-03 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

Also, `AnalyzerOptions.def` was recently clan-formatted, feel free to run it 
again after the changes you make in it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-12-01 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,
In addition to Umann remarks, there is a small comment inline.




Comment at: lib/CrossTU/CrossTranslationUnit.cpp:239
+  if (DisplayCTUProgress) {
+llvm::errs() << "ANALYZE (CTU loaded AST for source file): "
+ << ASTFileName << "\n";

I think we can remove parens from the message.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-11-30 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

The idea is great!

I think this should rather be an -analyzer-config flag, since the actual 
analysis changes with a new output (refer to `AnalyzerOption`'s doxygen 
comments). Please note that I'm about to land some patches that modifies 
`AnalyzerOptions.def` quite a bit, but rebasing shouldn't be too bad anyways.

Also, almost everywhere CTU is capitalized, so I guess it should be in the 
field name too.




Comment at: test/Analysis/ctu-main.cpp:6
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config 
experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir 
-analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+

I think these RUN lines would really benefit from introducing line breaks.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55135/new/

https://reviews.llvm.org/D55135



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55135: [CTU][Analyzer]Add DisplayCTUProgress analyzer switch

2018-11-30 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: xazax.hun, Szelethus, a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.
Herald added a reviewer: george.karpenkov.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D55135

Files:
  include/clang/CrossTU/CrossTranslationUnit.h
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/CrossTU/CrossTranslationUnit.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/ctu-main.cpp

Index: test/Analysis/ctu-main.cpp
===
--- test/Analysis/ctu-main.cpp
+++ test/Analysis/ctu-main.cpp
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-pch -o %T/ctudir/ctu-chain.cpp.ast %S/Inputs/ctu-chain.cpp
 // RUN: cp %S/Inputs/externalFnMap.txt %T/ctudir/
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config experimental-enable-naive-ctu-analysis=true -analyzer-config ctu-dir=%T/ctudir -analyzer-display-ctu-progress 2>&1 %s | FileCheck %s
+
+// CHECK: ANALYZE (CTU loaded AST for source file): {{.*}}/ctu-other.cpp
+// CHECK: ANALYZE (CTU loaded AST for source file): {{.*}}/ctu-chain.cpp
 
 #include "ctu-hdr.h"
 
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -560,7 +560,8 @@
   cross_tu::CrossTranslationUnitContext  =
   *Engine->getCrossTranslationUnitContext();
   llvm::Expected CTUDeclOrError =
-  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName());
+  CTUCtx.getCrossTUDefinition(FD, Opts.getCTUDir(), Opts.getCTUIndexName(),
+  Opts.AnalyzerDisplayCtuProgress);
 
   if (!CTUDeclOrError) {
 handleAllErrors(CTUDeclOrError.takeError(),
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -289,6 +289,8 @@
   Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
   Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
   Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
+  Opts.AnalyzerDisplayCtuProgress =
+  Args.hasArg(OPT_analyzer_display_ctu_progress);
   Opts.AnalyzeNestedBlocks =
 Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
   Opts.AnalyzeSpecificFunction = Args.getLastArgValue(OPT_analyze_function);
Index: lib/CrossTU/CrossTranslationUnit.cpp
===
--- lib/CrossTU/CrossTranslationUnit.cpp
+++ lib/CrossTU/CrossTranslationUnit.cpp
@@ -149,14 +149,15 @@
 llvm::Expected
 CrossTranslationUnitContext::getCrossTUDefinition(const FunctionDecl *FD,
   StringRef CrossTUDir,
-  StringRef IndexName) {
+  StringRef IndexName,
+  bool DisplayCTUProgress) {
   assert(!FD->hasBody() && "FD has a definition in current translation unit!");
   const std::string LookupFnName = getLookupName(FD);
   if (LookupFnName.empty())
 return llvm::make_error(
 index_error_code::failed_to_generate_usr);
   llvm::Expected ASTUnitOrError =
-  loadExternalAST(LookupFnName, CrossTUDir, IndexName);
+  loadExternalAST(LookupFnName, CrossTUDir, IndexName, DisplayCTUProgress);
   if (!ASTUnitOrError)
 return ASTUnitOrError.takeError();
   ASTUnit *Unit = *ASTUnitOrError;
@@ -193,7 +194,8 @@
 }
 
 llvm::Expected 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
@@ -233,6 +235,10 @@
   ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts()));