mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
5bddf886bb
Fix that the `file` fields in ConstExtract JSON output are all prefix mapped path when caching and prefix mapping are all enabled. This can cause the consumers of the output failed to find the source file. Now the JSON file is correct updated with the correct source file location when caching is on. This allows both un-prefix-mapped source location and relocatable source file location. As a bonus, now CAS stores the compact version of the JSON file to save space without affecting the pretty formatted final output file. rdar://173736094
72 lines
2.5 KiB
C++
72 lines
2.5 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,
|
|
std::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;
|
|
|
|
/// Return true if the file type is stored into CAS Backend directly.
|
|
static bool isStoredDirectly(file_types::ID Kind);
|
|
|
|
public:
|
|
SwiftCASOutputBackend(llvm::cas::ObjectStore &CAS,
|
|
llvm::cas::ActionCache &Cache,
|
|
llvm::cas::ObjectRef BaseKey,
|
|
const FrontendInputsAndOutputs &InputsAndOutputs,
|
|
const FrontendOptions &Opts,
|
|
FrontendOptions::ActionType Action,
|
|
bool WriteOutputHashXAttr);
|
|
~SwiftCASOutputBackend();
|
|
|
|
llvm::Error storeCachedDiagnostics(unsigned InputIndex,
|
|
llvm::StringRef Bytes);
|
|
|
|
llvm::Error storeSupplementaryOutputFile(StringRef OutputFilename,
|
|
llvm::StringRef Bytes);
|
|
|
|
/// Store the MCCAS CASID \p ID as the object file output for the input
|
|
/// that corresponds to the \p OutputFilename
|
|
llvm::Error storeMCCASObjectID(StringRef OutputFilename, llvm::cas::CASID ID);
|
|
|
|
private:
|
|
class Implementation;
|
|
Implementation &Impl;
|
|
};
|
|
|
|
} // end namespace swift::cas
|
|
|
|
#endif
|