Skip to content

Commit

Permalink
[Tooling] Remove unused function setRestoreWorkingDir
Browse files Browse the repository at this point in the history
The last use was removed by:

  commit 146ec74
  Author: Jan Svoboda <jan_svoboda@apple.com>
  Date:   Fri Sep 10 10:24:16 2021 +0200

Once I remove the function, RestoreCWD is always true, so this patch
removes the variable and propagates the constant.

Differential Revision: https://reviews.llvm.org/D151786
  • Loading branch information
kazutakahirata committed May 31, 2023
1 parent 4324937 commit 5a0d53c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
6 changes: 0 additions & 6 deletions clang/include/clang/Tooling/Tooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ class ClangTool {
/// append them to ASTs.
int buildASTs(std::vector<std::unique_ptr<ASTUnit>> &ASTs);

/// Sets whether working directory should be restored after calling run(). By
/// default, working directory is restored. However, it could be useful to
/// turn this off when running on multiple threads to avoid the raciness.
void setRestoreWorkingDir(bool RestoreCWD);

/// Sets whether an error message should be printed out if an action fails. By
/// default, if an action fails, a message is printed out to stderr.
void setPrintErrorMessage(bool PrintErrorMessage);
Expand Down Expand Up @@ -395,7 +390,6 @@ class ClangTool {

DiagnosticConsumer *DiagConsumer = nullptr;

bool RestoreCWD = true;
bool PrintErrorMessage = true;
};

Expand Down
16 changes: 5 additions & 11 deletions clang/lib/Tooling/Tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,11 @@ int ClangTool::run(ToolAction *Action) {

// Remember the working directory in case we need to restore it.
std::string InitialWorkingDir;
if (RestoreCWD) {
if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
InitialWorkingDir = std::move(*CWD);
} else {
llvm::errs() << "Could not get working directory: "
<< CWD.getError().message() << "\n";
}
if (auto CWD = OverlayFileSystem->getCurrentWorkingDirectory()) {
InitialWorkingDir = std::move(*CWD);
} else {
llvm::errs() << "Could not get working directory: "
<< CWD.getError().message() << "\n";
}

for (llvm::StringRef File : AbsolutePaths) {
Expand Down Expand Up @@ -662,10 +660,6 @@ int ClangTool::buildASTs(std::vector<std::unique_ptr<ASTUnit>> &ASTs) {
return run(&Action);
}

void ClangTool::setRestoreWorkingDir(bool RestoreCWD) {
this->RestoreCWD = RestoreCWD;
}

void ClangTool::setPrintErrorMessage(bool PrintErrorMessage) {
this->PrintErrorMessage = PrintErrorMessage;
}
Expand Down

0 comments on commit 5a0d53c

Please sign in to comment.