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(
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(
// CHECK-NEXT: cplusplus.SmartPtrModeling:ModelSmartPtrDereference = false
// 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
// 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
std::unique_ptr<clang::ASTConsumer>
CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
CI.getAnalyzerOpts()->CTUImportThreshold = OverrideLimit;
+ CI.getAnalyzerOpts()->CTUImportCppThreshold = OverrideLimit;
return std::make_unique<CTUASTConsumer>(CI, Success);
}