mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rename accessors to InputFile data.
This commit is contained in:
@@ -49,9 +49,9 @@ public:
|
||||
llvm::MemoryBuffer *buffer = nullptr)
|
||||
: Filename(name), IsPrimary(isPrimary), Buffer(buffer) {}
|
||||
|
||||
bool getIsPrimary() const { return IsPrimary; }
|
||||
llvm::MemoryBuffer *getBuffer() const { return Buffer; }
|
||||
StringRef getFile() const { return Filename; }
|
||||
bool isPrimary() const { return IsPrimary; }
|
||||
llvm::MemoryBuffer *buffer() const { return Buffer; }
|
||||
StringRef file() const { return Filename; }
|
||||
|
||||
void setBuffer(llvm::MemoryBuffer *buffer) { Buffer = buffer; }
|
||||
};
|
||||
@@ -86,8 +86,8 @@ public:
|
||||
std::vector<std::string> getInputFilenames() const {
|
||||
std::vector<std::string> filenames;
|
||||
for (auto &input : getAllFiles()) {
|
||||
assert(!input.getFile().empty());
|
||||
filenames.push_back(input.getFile());
|
||||
assert(!input.file().empty());
|
||||
filenames.push_back(input.file());
|
||||
}
|
||||
return filenames;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
StringRef getFilenameOfFirstInput() const {
|
||||
assert(hasInputs());
|
||||
const InputFile &inp = getAllFiles()[0];
|
||||
StringRef f = inp.getFile();
|
||||
StringRef f = inp.file();
|
||||
assert(!f.empty());
|
||||
return f;
|
||||
}
|
||||
@@ -153,14 +153,14 @@ public:
|
||||
/// isn't one.
|
||||
StringRef getNameOfUniquePrimaryInputFile() const {
|
||||
const auto *input = getUniquePrimaryInput();
|
||||
return input == nullptr ? StringRef() : input->getFile();
|
||||
return input == nullptr ? StringRef() : input->file();
|
||||
}
|
||||
|
||||
bool isFilePrimary(StringRef file) {
|
||||
StringRef correctedName = file.equals("<stdin>") ? "-" : file;
|
||||
auto iterator = PrimaryInputs.find(correctedName);
|
||||
return iterator != PrimaryInputs.end() &&
|
||||
AllFiles[iterator->second].getIsPrimary();
|
||||
AllFiles[iterator->second].isPrimary();
|
||||
}
|
||||
|
||||
unsigned numberOfPrimaryInputsEndingWith(const char *extension) const;
|
||||
@@ -188,8 +188,8 @@ public:
|
||||
}
|
||||
|
||||
void addInput(const InputFile &input) {
|
||||
if (!input.getFile().empty() && input.getIsPrimary())
|
||||
PrimaryInputs.insert(std::make_pair(input.getFile(), AllFiles.size()));
|
||||
if (!input.file().empty() && input.isPrimary())
|
||||
PrimaryInputs.insert(std::make_pair(input.file(), AllFiles.size()));
|
||||
AllFiles.push_back(input);
|
||||
}
|
||||
void clearInputs() {
|
||||
|
||||
@@ -753,7 +753,7 @@ void FrontendArgsToOptionsConverter::deriveOutputFilenameFromParts(
|
||||
std::string FrontendArgsToOptionsConverter::determineBaseNameOfOutput() const {
|
||||
std::string nameToStem;
|
||||
if (Opts.Inputs.hasPrimaryInputs()) {
|
||||
nameToStem = Opts.Inputs.getRequiredUniquePrimaryInput().getFile();
|
||||
nameToStem = Opts.Inputs.getRequiredUniquePrimaryInput().file();
|
||||
} else if (auto UserSpecifiedModuleName =
|
||||
Args.getLastArg(options::OPT_module_name)) {
|
||||
nameToStem = UserSpecifiedModuleName->getValue();
|
||||
@@ -1645,7 +1645,7 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
Opts.MainInputFilename = SILOpts.SILOutputFileNameForDebugging;
|
||||
} else if (const InputFile *input =
|
||||
FrontendOpts.Inputs.getUniquePrimaryInput()) {
|
||||
Opts.MainInputFilename = input->getFile();
|
||||
Opts.MainInputFilename = input->file();
|
||||
} else if (FrontendOpts.Inputs.hasSingleInput()) {
|
||||
Opts.MainInputFilename = FrontendOpts.Inputs.getFilenameOfFirstInput();
|
||||
}
|
||||
|
||||
@@ -197,11 +197,11 @@ bool CompilerInstance::setupInputs(Optional<unsigned> codeCompletionBufferID) {
|
||||
}
|
||||
|
||||
bool CompilerInstance::setupForInput(const InputFile &input) {
|
||||
if (llvm::MemoryBuffer *inputBuffer = input.getBuffer()) {
|
||||
setupForBuffer(inputBuffer, input.getIsPrimary());
|
||||
if (llvm::MemoryBuffer *inputBuffer = input.buffer()) {
|
||||
setupForBuffer(inputBuffer, input.isPrimary());
|
||||
return false;
|
||||
}
|
||||
return setUpForFile(input.getFile(), input.getIsPrimary());
|
||||
return setUpForFile(input.file(), input.isPrimary());
|
||||
}
|
||||
void CompilerInstance::setupForBuffer(llvm::MemoryBuffer *buffer,
|
||||
bool isPrimary) {
|
||||
|
||||
@@ -60,7 +60,7 @@ unsigned
|
||||
FrontendInputs::numberOfPrimaryInputsEndingWith(const char *extension) const {
|
||||
return count_if(
|
||||
PrimaryInputs, [&](const llvm::StringMapEntry<unsigned> &elem) -> bool {
|
||||
StringRef filename = AllFiles[elem.second].getFile();
|
||||
StringRef filename = AllFiles[elem.second].file();
|
||||
return llvm::sys::path::extension(filename).endswith(extension);
|
||||
});
|
||||
}
|
||||
@@ -98,10 +98,10 @@ bool FrontendInputs::verifyInputs(DiagnosticEngine &diags, bool treatAsSIL,
|
||||
|
||||
bool FrontendInputs::areAllNonPrimariesSIB() const {
|
||||
for (const InputFile &input : getAllFiles()) {
|
||||
assert(!input.getFile().empty() && "all files have (perhaps pseudo) names");
|
||||
if (input.getIsPrimary())
|
||||
assert(!input.file().empty() && "all files have (perhaps pseudo) names");
|
||||
if (input.isPrimary())
|
||||
continue;
|
||||
if (!llvm::sys::path::extension(input.getFile()).endswith(SIB_EXTENSION)) {
|
||||
if (!llvm::sys::path::extension(input.file()).endswith(SIB_EXTENSION)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ StringRef FrontendOptions::originalPath() const {
|
||||
// serialized diagnostics file, otherwise fall back on the
|
||||
// module name.
|
||||
const auto input = Inputs.getUniquePrimaryInput();
|
||||
return input ? llvm::sys::path::filename(input->getFile())
|
||||
return input ? llvm::sys::path::filename(input->file())
|
||||
: StringRef(ModuleName);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,9 +147,9 @@ Migrator::performAFixItMigration(version::Version SwiftLanguageVersion) {
|
||||
assert(OrigFrontendOpts.Inputs.hasPrimaryInputs() &&
|
||||
"Migration must have a primary");
|
||||
for (const auto &input : OrigFrontendOpts.Inputs.getAllFiles()) {
|
||||
Invocation.getFrontendOptions().Inputs.addInput(InputFile(
|
||||
input.getFile(), input.getIsPrimary(),
|
||||
input.getIsPrimary() ? InputBuffer.get() : input.getBuffer()));
|
||||
Invocation.getFrontendOptions().Inputs.addInput(
|
||||
InputFile(input.file(), input.isPrimary(),
|
||||
input.isPrimary() ? InputBuffer.get() : input.buffer()));
|
||||
}
|
||||
|
||||
auto Instance = llvm::make_unique<swift::CompilerInstance>();
|
||||
@@ -439,6 +439,6 @@ const MigratorOptions &Migrator::getMigratorOptions() const {
|
||||
const StringRef Migrator::getInputFilename() const {
|
||||
auto &PrimaryInput = StartInvocation.getFrontendOptions()
|
||||
.Inputs.getRequiredUniquePrimaryInput();
|
||||
assert(!PrimaryInput.getFile().empty());
|
||||
return PrimaryInput.getFile();
|
||||
assert(!PrimaryInput.file().empty());
|
||||
return PrimaryInput.file();
|
||||
}
|
||||
|
||||
@@ -403,15 +403,15 @@ resolveSymbolicLinksInInputs(FrontendInputs &inputs,
|
||||
FrontendInputs replacementInputs;
|
||||
for (const InputFile &input : inputs.getAllFiles()) {
|
||||
std::string newFilename =
|
||||
SwiftLangSupport::resolvePathSymlinks(input.getFile());
|
||||
bool newIsPrimary = input.getIsPrimary() ||
|
||||
SwiftLangSupport::resolvePathSymlinks(input.file());
|
||||
bool newIsPrimary = input.isPrimary() ||
|
||||
(!PrimaryFile.empty() && PrimaryFile == newFilename);
|
||||
if (newIsPrimary) {
|
||||
++primaryCount;
|
||||
}
|
||||
assert(primaryCount < 2 && "cannot handle multiple primaries");
|
||||
replacementInputs.addInput(
|
||||
InputFile(newFilename, newIsPrimary, input.getBuffer()));
|
||||
InputFile(newFilename, newIsPrimary, input.buffer()));
|
||||
}
|
||||
|
||||
if (PrimaryFile.empty() || primaryCount == 1) {
|
||||
@@ -682,7 +682,7 @@ bool ASTProducer::shouldRebuild(SwiftASTManager::Implementation &MgrImpl,
|
||||
Invok.Opts.Invok.getFrontendOptions().Inputs.inputCount());
|
||||
for (const auto &input :
|
||||
Invok.Opts.Invok.getFrontendOptions().Inputs.getAllFiles()) {
|
||||
StringRef File = input.getFile();
|
||||
StringRef File = input.file();
|
||||
if (File.empty())
|
||||
continue;
|
||||
bool FoundSnapshot = false;
|
||||
@@ -773,7 +773,7 @@ ASTUnitRef ASTProducer::createASTUnit(SwiftASTManager::Implementation &MgrImpl,
|
||||
SmallVector<FileContent, 8> Contents;
|
||||
for (const auto &input :
|
||||
Opts.Invok.getFrontendOptions().Inputs.getAllFiles()) {
|
||||
StringRef File = input.getFile();
|
||||
StringRef File = input.file();
|
||||
if (File.empty())
|
||||
continue;
|
||||
bool FoundSnapshot = false;
|
||||
|
||||
Reference in New Issue
Block a user