[PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 9 06:02:55 PDT 2020


martong updated this revision to Diff 276722.
martong marked an inline comment as done.
martong added a comment.

- Remove extra whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83475

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


Index: clang/test/Analysis/ctu-import-threshold.c
===================================================================
--- clang/test/Analysis/ctu-import-threshold.c
+++ clang/test/Analysis/ctu-import-threshold.c
@@ -1,5 +1,6 @@
 // Ensure analyzer option 'ctu-import-threshold' is a recognized option.
 //
 // RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-cpp-threshold=30 -verify %s
 //
 // expected-no-diagnostics
Index: clang/test/Analysis/analyzer-config.c
===================================================================
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -42,7 +42,8 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 8
+// CHECK-NEXT: ctu-import-cpp-threshold = 8
+// CHECK-NEXT: ctu-import-threshold = 24
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -367,7 +367,9 @@
     CompilerInstance &CI)
     : Loader(CI, CI.getAnalyzerOpts()->CTUDir,
              CI.getAnalyzerOpts()->CTUInvocationList),
-      LoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+      LoadGuard(CI.getASTContext().getLangOpts().CPlusPlus
+                    ? CI.getAnalyzerOpts()->CTUImportCppThreshold
+                    : CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 llvm::Expected<ASTUnit *>
 CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -321,9 +321,16 @@
 ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
                 "The maximal amount of translation units that is considered "
                 "for import when inlining functions during CTU analysis. "
-                "Lowering this threshold can alleviate the memory burder of "
+                "Lowering this threshold can alleviate the memory burden of "
                 "analysis with many interdependent definitions located in "
-                "various translation units.",
+                "various translation units. This is valid only for non C++ "
+                "source files.",
+                24u)
+
+ANALYZER_OPTION(unsigned, CTUImportCppThreshold, "ctu-import-cpp-threshold",
+                "The maximal amount of translation units that is considered "
+                "for import when inlining functions during CTU analysis of C++ "
+                "source files.",
                 8u)
 
 ANALYZER_OPTION(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83475.276722.patch
Type: text/x-patch
Size: 3093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200709/d26f4f31/attachment-0001.bin>


More information about the cfe-commits mailing list