Files
swift-mirror/include/swift/Frontend/CASOutputBackends.h
Steven Wu 76bde39ee7 [Caching] Encoding cache key for input file with index instead of path
Avoid path encoding difference (for example, real_path vs. path from
symlink) by eliminating the path from cache key. Cache key is now
encoded with the index of the input file from all the input files from
the command-line, reguardless if those inputs will produce output or
not. This is to ensure stable ordering even the batching is different.

Add a new cache computation API that is preferred for using input index
directly. Old API for cache key is deprecated but still updated to
fallback to real_path comparsion if needed.

As a result of swift scan API change, rename the feature in JSON file to
avoid version confusion between swift-driver and libSwiftScan.

rdar://119387650
2023-12-18 14:06:00 -08:00

60 lines
2.0 KiB
C++

//===------CASOutputBackends.h-- ---------------------------------*-C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_FRONTEND_CASOUTPUTBACKENDS_H
#define SWIFT_FRONTEND_CASOUTPUTBACKENDS_H
#include "swift/Frontend/FrontendInputsAndOutputs.h"
#include "swift/Frontend/FrontendOptions.h"
#include "llvm/CAS/ActionCache.h"
#include "llvm/CAS/ObjectStore.h"
#include "llvm/Support/VirtualOutputBackends.h"
#include "llvm/Support/VirtualOutputFile.h"
namespace swift::cas {
class SwiftCASOutputBackend : public llvm::vfs::OutputBackend {
void anchor() override;
protected:
llvm::IntrusiveRefCntPtr<OutputBackend> cloneImpl() const override;
llvm::Expected<std::unique_ptr<llvm::vfs::OutputFileImpl>>
createFileImpl(llvm::StringRef ResolvedPath,
llvm::Optional<llvm::vfs::OutputConfig> Config) override;
virtual llvm::Error storeImpl(llvm::StringRef Path, llvm::StringRef Bytes,
unsigned InputIndex, file_types::ID OutputKind);
private:
file_types::ID getOutputFileType(llvm::StringRef Path) const;
public:
SwiftCASOutputBackend(llvm::cas::ObjectStore &CAS,
llvm::cas::ActionCache &Cache,
llvm::cas::ObjectRef BaseKey,
const FrontendInputsAndOutputs &InputsAndOutputs,
FrontendOptions::ActionType Action);
~SwiftCASOutputBackend();
llvm::Error storeCachedDiagnostics(unsigned InputIndex,
llvm::StringRef Bytes);
private:
class Implementation;
Implementation &Impl;
};
} // end namespace swift::cas
#endif