Files
swift-mirror/include/swift/Basic/PrimarySpecificPaths.h
Vinicius Vendramini e123750c12 Add option to dump AST to files
This adds two things:
- Calling `swiftc -dump-ast foo.swift [...] -o foo.ast` will dump the AST to the file `foo.ast`, instead of dumping it to `stderr` as usual.
- Calling `swiftc -dump-ast -output-file-map=outputFileMap.json *.swift [...]`, given an `outputFileMap.json` file that contains entries in the form `"ast-dump": "foo.ast"`, will dump the ASTs of the input files to their respective output files in the file map.

This should serve as a valid workaround to a bug mentioned in [the forums](https://forums.swift.org/t/error-when-dumping-the-ast-for-hundreds-of-files/17578) where the AST dump functionality crashes when called with too many input files. A few implementation details were also discussed in the same forum post.

As an aside, this also fixes a comment in `include/swift/Basic/PrimarySpecificPaths.h` that was incorrect.
2018-11-14 13:38:01 -02:00

56 lines
2.0 KiB
C++

//===--- PrimarySpecificPaths.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_BASIC_PRIMARYSPECIFICPATHS_H
#define SWIFT_BASIC_PRIMARYSPECIFICPATHS_H
#include "swift/Basic/LLVM.h"
#include "swift/Basic/SupplementaryOutputPaths.h"
#include "llvm/ADT/StringRef.h"
#include <string>
namespace swift {
/// Holds all of the output paths, and debugging-info path that are
/// specific to which primary file is being compiled at the moment.
class PrimarySpecificPaths {
public:
/// The name of the main output file,
/// that is, the .o file for this input (or a file specified by -o).
/// If there is no such file, contains an empty string. If the output
/// is to be written to stdout, contains "-".
std::string OutputFilename;
SupplementaryOutputPaths SupplementaryOutputs;
/// The name of the "main" input file, used by the debug info.
std::string MainInputFilenameForDebugInfo;
PrimarySpecificPaths(StringRef OutputFilename = StringRef(),
StringRef MainInputFilenameForDebugInfo = StringRef(),
SupplementaryOutputPaths SupplementaryOutputs =
SupplementaryOutputPaths())
: OutputFilename(OutputFilename),
SupplementaryOutputs(SupplementaryOutputs),
MainInputFilenameForDebugInfo(MainInputFilenameForDebugInfo) {}
bool haveModuleOrModuleDocOutputPaths() const {
return !SupplementaryOutputs.ModuleOutputPath.empty() ||
!SupplementaryOutputs.ModuleDocOutputPath.empty();
}
};
} // namespace swift
#endif /* SWIFT_BASIC_PRIMARYSPECIFICPATHS_H */