Skip to content

Commit a7a2259

Browse files
committed
[clang][analyzer] Delay checking the ctu-dir
1 parent 2e96cd6 commit a7a2259

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

clang/lib/CrossTU/CrossTranslationUnit.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "clang/AST/ASTImporter.h"
1414
#include "clang/AST/Decl.h"
1515
#include "clang/AST/ParentMapContext.h"
16+
#include "clang/Basic/DiagnosticDriver.h"
1617
#include "clang/Basic/TargetInfo.h"
1718
#include "clang/CrossTU/CrossTUDiagnostic.h"
1819
#include "clang/Frontend/ASTUnit.h"
@@ -237,7 +238,16 @@ template <typename T> static bool hasBodyOrInit(const T *D) {
237238
}
238239

239240
CrossTranslationUnitContext::CrossTranslationUnitContext(CompilerInstance &CI)
240-
: Context(CI.getASTContext()), ASTStorage(CI) {}
241+
: Context(CI.getASTContext()), ASTStorage(CI) {
242+
if (CI.getAnalyzerOpts().ShouldEmitErrorsOnInvalidConfigValue &&
243+
!CI.getAnalyzerOpts().CTUDir.empty()) {
244+
auto S = CI.getVirtualFileSystem().status(CI.getAnalyzerOpts().CTUDir);
245+
if (!S || S->getType() != llvm::sys::fs::file_type::directory_file)
246+
CI.getDiagnostics().Report(diag::err_analyzer_config_invalid_input)
247+
<< "ctu-dir"
248+
<< "a filename";
249+
}
250+
}
241251

242252
CrossTranslationUnitContext::~CrossTranslationUnitContext() {}
243253

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,6 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
13221322
if (AnOpts.ShouldTrackConditionsDebug && !AnOpts.ShouldTrackConditions)
13231323
Diags->Report(diag::err_analyzer_config_invalid_input)
13241324
<< "track-conditions-debug" << "'track-conditions' to also be enabled";
1325-
1326-
if (!AnOpts.CTUDir.empty() && !llvm::sys::fs::is_directory(AnOpts.CTUDir))
1327-
Diags->Report(diag::err_analyzer_config_invalid_input) << "ctu-dir"
1328-
<< "a filename";
13291325
}
13301326

13311327
/// Generate a remark argument. This is an inverse of `ParseOptimizationRemark`.

0 commit comments

Comments
 (0)