mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[NFC] Fixup InputFile Convenience Getters
Follow programming guidelines for these getters more closely and have them return a non-owning view of the underlying data instead of relying on callers to take const references to the copy that is returned here.
This commit is contained in:
@@ -121,17 +121,17 @@ public:
|
||||
// FrontendInputsAndOutputs. They merely make the call sites
|
||||
// a bit shorter. Add more forwarding methods as needed.
|
||||
|
||||
std::string dependenciesFilePath() const {
|
||||
StringRef getDependenciesFilePath() const {
|
||||
return getPrimarySpecificPaths().SupplementaryOutputs.DependenciesFilePath;
|
||||
}
|
||||
std::string loadedModuleTracePath() const {
|
||||
StringRef getLoadedModuleTracePath() const {
|
||||
return getPrimarySpecificPaths().SupplementaryOutputs.LoadedModuleTracePath;
|
||||
}
|
||||
std::string serializedDiagnosticsPath() const {
|
||||
StringRef getSerializedDiagnosticsPath() const {
|
||||
return getPrimarySpecificPaths().SupplementaryOutputs
|
||||
.SerializedDiagnosticsPath;
|
||||
}
|
||||
std::string fixItsOutputPath() const {
|
||||
StringRef getFixItsOutputPath() const {
|
||||
return getPrimarySpecificPaths().SupplementaryOutputs.FixItsOutputPath;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -127,7 +127,7 @@ getFileOutputStream(StringRef OutputFilename, ASTContext &Ctx) {
|
||||
}
|
||||
|
||||
/// Writes the Syntax tree to the given file
|
||||
static bool emitSyntax(SourceFile &SF, StringRef OutputFilename) {
|
||||
static bool emitSyntax(const SourceFile &SF, StringRef OutputFilename) {
|
||||
auto os = getFileOutputStream(OutputFilename, SF.getASTContext());
|
||||
if (!os) return true;
|
||||
|
||||
@@ -221,7 +221,7 @@ class JSONFixitWriter
|
||||
public:
|
||||
JSONFixitWriter(std::string fixitsOutputPath,
|
||||
const DiagnosticOptions &DiagOpts)
|
||||
: FixitsOutputPath(fixitsOutputPath),
|
||||
: FixitsOutputPath(std::move(fixitsOutputPath)),
|
||||
FixitAll(DiagOpts.FixitCodeForAllDiagnostics) {}
|
||||
|
||||
private:
|
||||
@@ -1612,10 +1612,13 @@ static void emitIndexDataForSourceFile(SourceFile *PrimarySourceFile,
|
||||
if (moduleToken.empty())
|
||||
moduleToken = opts.InputsAndOutputs.getSingleOutputFilename();
|
||||
|
||||
(void) index::indexAndRecord(Instance.getMainModule(), opts.InputsAndOutputs.copyOutputFilenames(),
|
||||
(void) index::indexAndRecord(Instance.getMainModule(),
|
||||
opts.InputsAndOutputs.copyOutputFilenames(),
|
||||
moduleToken, opts.IndexStorePath,
|
||||
opts.IndexSystemModules, opts.IndexIgnoreStdlib,
|
||||
isDebugCompilation, Invocation.getTargetTriple(),
|
||||
opts.IndexSystemModules,
|
||||
opts.IndexIgnoreStdlib,
|
||||
isDebugCompilation,
|
||||
Invocation.getTargetTriple(),
|
||||
*Instance.getDependencyTracker());
|
||||
}
|
||||
}
|
||||
@@ -1683,10 +1686,11 @@ createSerializedDiagnosticConsumerIfNeeded(
|
||||
return createDispatchingDiagnosticConsumerIfNeeded(
|
||||
inputsAndOutputs,
|
||||
[](const InputFile &input) -> std::unique_ptr<DiagnosticConsumer> {
|
||||
std::string serializedDiagnosticsPath = input.serializedDiagnosticsPath();
|
||||
auto serializedDiagnosticsPath = input.getSerializedDiagnosticsPath();
|
||||
if (serializedDiagnosticsPath.empty())
|
||||
return nullptr;
|
||||
return serialized_diagnostics::createConsumer(serializedDiagnosticsPath);
|
||||
return serialized_diagnostics::createConsumer(
|
||||
serializedDiagnosticsPath);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1704,11 +1708,11 @@ createJSONFixItDiagnosticConsumerIfNeeded(
|
||||
return createDispatchingDiagnosticConsumerIfNeeded(
|
||||
invocation.getFrontendOptions().InputsAndOutputs,
|
||||
[&](const InputFile &input) -> std::unique_ptr<DiagnosticConsumer> {
|
||||
std::string fixItsOutputPath = input.fixItsOutputPath();
|
||||
auto fixItsOutputPath = input.getFixItsOutputPath();
|
||||
if (fixItsOutputPath.empty())
|
||||
return nullptr;
|
||||
return std::make_unique<JSONFixitWriter>(
|
||||
fixItsOutputPath, invocation.getDiagnosticOptions());
|
||||
fixItsOutputPath.str(), invocation.getDiagnosticOptions());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -699,7 +699,7 @@ bool swift::emitLoadedModuleTraceIfNeeded(ModuleDecl *mainModule,
|
||||
assert(!ctxt.hadError() &&
|
||||
"We should've already exited earlier if there was an error.");
|
||||
|
||||
auto loadedModuleTracePath = input.loadedModuleTracePath();
|
||||
auto loadedModuleTracePath = input.getLoadedModuleTracePath();
|
||||
if (loadedModuleTracePath.empty())
|
||||
return false;
|
||||
std::error_code EC;
|
||||
|
||||
@@ -91,7 +91,7 @@ bool swift::emitMakeDependenciesIfNeeded(DiagnosticEngine &diags,
|
||||
DependencyTracker *depTracker,
|
||||
const FrontendOptions &opts,
|
||||
const InputFile &input) {
|
||||
const std::string &dependenciesFilePath = input.dependenciesFilePath();
|
||||
auto dependenciesFilePath = input.getDependenciesFilePath();
|
||||
if (dependenciesFilePath.empty())
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user