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.4 KiB
C++
72 lines
2.4 KiB
C++
//===---- ConstExtract.h -- Gather Compile-Time-Known Values ----*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2022 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_CONST_EXTRACT_H
|
|
#define SWIFT_CONST_EXTRACT_H
|
|
|
|
#include "swift/AST/ConstTypeInfo.h"
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
#include <string>
|
|
#include <unordered_set>
|
|
#include <vector>
|
|
|
|
namespace llvm {
|
|
class StringRef;
|
|
class raw_fd_ostream;
|
|
namespace vfs{
|
|
class FileSystem;
|
|
} // namespace vfs
|
|
} // namespace llvm
|
|
|
|
namespace swift {
|
|
class SourceFile;
|
|
class DiagnosticEngine;
|
|
class ModuleDecl;
|
|
} // namespace swift
|
|
|
|
namespace swift {
|
|
/// Parse a list of string identifiers from a file at the given path,
|
|
/// representing names of protocols.
|
|
bool
|
|
parseProtocolListFromFile(llvm::StringRef protocolListFilePath,
|
|
DiagnosticEngine &diags,
|
|
llvm::vfs::FileSystem &fs,
|
|
std::unordered_set<std::string> &protocols);
|
|
|
|
/// Gather compile-time-known values of properties in nominal type declarations
|
|
/// in this file, of types which conform to one of the protocols listed in
|
|
/// \c Protocols
|
|
std::vector<ConstValueTypeInfo>
|
|
gatherConstValuesForPrimary(const std::unordered_set<std::string> &Protocols,
|
|
const SourceFile *File);
|
|
|
|
/// Gather compile-time-known values of properties in nominal type declarations
|
|
/// in this module, of types which conform to one of the protocols listed in
|
|
/// \c Protocols
|
|
std::vector<ConstValueTypeInfo>
|
|
gatherConstValuesForModule(const std::unordered_set<std::string> &Protocols,
|
|
ModuleDecl *Module);
|
|
|
|
/// Serialize a collection of \c ConstValueInfos to JSON at the
|
|
/// provided output stream.
|
|
bool writeAsJSONToFile(const std::vector<ConstValueTypeInfo> &ConstValueInfos,
|
|
llvm::raw_ostream &OS, bool Compact = false);
|
|
|
|
/// Remap prefix-mapped paths in const values JSON output. Scans for
|
|
/// Returns true on error.
|
|
bool remapConstValuesJSON(
|
|
llvm::StringRef Input, llvm::raw_ostream &OS,
|
|
llvm::ArrayRef<std::pair<std::string, std::string>> PrefixMap);
|
|
} // namespace swift
|
|
|
|
#endif
|