Skip to content

Commit 71f0197

Browse files
committed
Updates for review
(cherry picked from commit cb7bc8c)
1 parent 87b9f40 commit 71f0197

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

clang/include/clang/CAS/CASOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class CASOptions : public CASConfiguration {
117117
/// default on-disk CAS, otherwise this is a noop.
118118
void ensurePersistentCAS();
119119

120-
std::string getResolvedCASPath() const;
120+
void getResolvedCASPath(llvm::SmallVectorImpl<char> &Result) const;
121121

122122
private:
123123
/// Initialize Cached CAS and ActionCache.

clang/lib/CAS/CASOptions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ llvm::Error CASOptions::initCache() const {
108108
}
109109

110110
SmallString<256> PathBuf;
111+
getResolvedCASPath(PathBuf);
111112
if (CASPath == "auto") {
112113
getDefaultOnDiskCASPath(PathBuf);
113114
CASPath = PathBuf;
@@ -120,11 +121,10 @@ llvm::Error CASOptions::initCache() const {
120121
return llvm::Error::success();
121122
}
122123

123-
std::string CASOptions::getResolvedCASPath() const {
124-
if (CASPath != "auto")
125-
return CASPath;
126-
127-
SmallString<256> PathBuf;
128-
getDefaultOnDiskCASPath(PathBuf);
129-
return std::string(PathBuf);
124+
void CASOptions::getResolvedCASPath(SmallVectorImpl<char> &Result) const {
125+
if (CASPath == "auto") {
126+
getDefaultOnDiskCASPath(Result);
127+
} else {
128+
Result.assign(CASPath.begin(), CASPath.end());
129+
}
130130
}

clang/tools/driver/cc1depscan_main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,10 @@ void ScanServer::start(bool Exclusive, ArrayRef<const char *> CASArgs) {
836836
if (CASOpts.CASPath.empty() || !CASOpts.PluginPath.empty())
837837
return;
838838
SmallString<64> LLVMCasStorage;
839+
SmallString<64> CASPath;
840+
CASOpts.getResolvedCASPath(CASPath);
839841
ExitOnErr(llvm::cas::validateOnDiskUnifiedCASDatabasesIfNeeded(
840-
CASOpts.getResolvedCASPath(), /*CheckHash=*/true,
842+
CASPath, /*CheckHash=*/true,
841843
/*AllowRecovery=*/true,
842844
/*Force=*/false, findLLVMCasBinary(Argv0, LLVMCasStorage)));
843845
});

llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ enum class ValidationResult {
2929
/// The data is already valid.
3030
Valid,
3131
/// The data was invalid, but was recovered.
32-
RecoveredValid,
32+
Recovered,
3333
/// Validation was skipped, as it was not needed.
3434
Skipped,
3535
};
@@ -46,7 +46,7 @@ enum class ValidationResult {
4646
/// using the given \c llvm-cas executable which protects against crashes
4747
/// during validation. Otherwise validation is performed in-process.
4848
///
49-
/// \returns \c Valid if the data is already valid, \c RecoveredValid if data
49+
/// \returns \c Valid if the data is already valid, \c Recovered if data
5050
/// was invalid but has been cleared, \c Skipped if validation is not needed,
5151
/// or an \c Error if validation cannot be performed or if the data is left
5252
/// in an invalid state because \p AllowRecovery is false.

llvm/include/llvm/CAS/UnifiedOnDiskCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class UnifiedOnDiskCache {
102102
/// using the given \c llvm-cas executable which protects against crashes
103103
/// during validation. Otherwise validation is performed in-process.
104104
///
105-
/// \returns \c Valid if the data is already valid, \c RecoveredValid if data
105+
/// \returns \c Valid if the data is already valid, \c Recovered if data
106106
/// was invalid but has been cleared, \c Skipped if validation is not needed,
107107
/// or an \c Error if validation cannot be performed or if the data is left
108108
/// in an invalid state because \p AllowRecovery is false.

llvm/lib/CAS/UnifiedOnDiskCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ UnifiedOnDiskCache::validateIfNeeded(StringRef RootPath, StringRef HashName,
469469
return createFileError(PathBuf, OS.error());
470470
}
471471

472-
return NeedsRecovery ? ValidationResult::RecoveredValid
472+
return NeedsRecovery ? ValidationResult::Recovered
473473
: ValidationResult::Valid;
474474
}
475475

llvm/tools/llvm-cas/llvm-cas.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ int validateIfNeeded(StringRef Path, StringRef PluginPath,
776776
case ValidationResult::Valid:
777777
outs() << "validated successfully\n";
778778
break;
779-
case ValidationResult::RecoveredValid:
779+
case ValidationResult::Recovered:
780780
outs() << "recovered from invalid data\n";
781781
break;
782782
case ValidationResult::Skipped:

0 commit comments

Comments
 (0)