mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rename FrontendInputs::AllFiles to AllInputs, getAllFiles to getAllInputs, etc.
This commit is contained in:
@@ -32,7 +32,7 @@ namespace swift {
|
|||||||
class FrontendInputs {
|
class FrontendInputs {
|
||||||
friend class ArgsToFrontendInputsConverter;
|
friend class ArgsToFrontendInputsConverter;
|
||||||
|
|
||||||
std::vector<InputFile> AllFiles;
|
std::vector<InputFile> AllInputs;
|
||||||
typedef llvm::StringMap<unsigned> InputFileMap;
|
typedef llvm::StringMap<unsigned> InputFileMap;
|
||||||
InputFileMap PrimaryInputs;
|
InputFileMap PrimaryInputs;
|
||||||
|
|
||||||
@@ -45,13 +45,13 @@ public:
|
|||||||
|
|
||||||
// Readers:
|
// Readers:
|
||||||
|
|
||||||
ArrayRef<InputFile> getAllFiles() const { return AllFiles; }
|
ArrayRef<InputFile> getAllInputs() const { return AllInputs; }
|
||||||
|
|
||||||
std::vector<std::string> getInputFilenames() const;
|
std::vector<std::string> getInputFilenames() const;
|
||||||
|
|
||||||
unsigned inputCount() const { return getAllFiles().size(); }
|
unsigned inputCount() const { return AllInputs.size(); }
|
||||||
|
|
||||||
bool hasInputs() const { return !AllFiles.empty(); }
|
bool hasInputs() const { return !AllInputs.empty(); }
|
||||||
|
|
||||||
bool hasSingleInput() const { return inputCount() == 1; }
|
bool hasSingleInput() const { return inputCount() == 1; }
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
/// there isn't one.
|
/// there isn't one.
|
||||||
StringRef getNameOfUniquePrimaryInputFile() const;
|
StringRef getNameOfUniquePrimaryInputFile() const;
|
||||||
|
|
||||||
bool isFilePrimary(StringRef file) const;
|
bool isInputPrimary(StringRef file) const;
|
||||||
|
|
||||||
unsigned numberOfPrimaryInputsEndingWith(const char *extension) const;
|
unsigned numberOfPrimaryInputsEndingWith(const char *extension) const;
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
void addInput(const InputFile &input);
|
void addInput(const InputFile &input);
|
||||||
|
|
||||||
void clearInputs() {
|
void clearInputs() {
|
||||||
AllFiles.clear();
|
AllInputs.clear();
|
||||||
PrimaryInputs.clear();
|
PrimaryInputs.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ bool CompilerInstance::setUpInputs() {
|
|||||||
const Optional<unsigned> codeCompletionBufferID = setUpCodeCompletionBuffer();
|
const Optional<unsigned> codeCompletionBufferID = setUpCodeCompletionBuffer();
|
||||||
|
|
||||||
for (const InputFile &input :
|
for (const InputFile &input :
|
||||||
Invocation.getFrontendOptions().Inputs.getAllFiles())
|
Invocation.getFrontendOptions().Inputs.getAllInputs())
|
||||||
if (setUpForInput(input))
|
if (setUpForInput(input))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -30,20 +30,20 @@ using namespace swift;
|
|||||||
using namespace llvm::opt;
|
using namespace llvm::opt;
|
||||||
|
|
||||||
FrontendInputs::FrontendInputs(const FrontendInputs &other) {
|
FrontendInputs::FrontendInputs(const FrontendInputs &other) {
|
||||||
for (InputFile input : other.getAllFiles())
|
for (InputFile input : other.AllInputs)
|
||||||
addInput(input);
|
addInput(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
FrontendInputs &FrontendInputs::operator=(const FrontendInputs &other) {
|
FrontendInputs &FrontendInputs::operator=(const FrontendInputs &other) {
|
||||||
clearInputs();
|
clearInputs();
|
||||||
for (InputFile input : other.getAllFiles())
|
for (InputFile input : other.AllInputs)
|
||||||
addInput(input);
|
addInput(input);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> FrontendInputs::getInputFilenames() const {
|
std::vector<std::string> FrontendInputs::getInputFilenames() const {
|
||||||
std::vector<std::string> filenames;
|
std::vector<std::string> filenames;
|
||||||
for (auto &input : getAllFiles()) {
|
for (auto &input : AllInputs) {
|
||||||
filenames.push_back(input.file());
|
filenames.push_back(input.file());
|
||||||
}
|
}
|
||||||
return filenames;
|
return filenames;
|
||||||
@@ -61,7 +61,7 @@ void FrontendInputs::assertMustNotBeMoreThanOnePrimaryInput() const {
|
|||||||
const InputFile *FrontendInputs::getUniquePrimaryInput() const {
|
const InputFile *FrontendInputs::getUniquePrimaryInput() const {
|
||||||
assertMustNotBeMoreThanOnePrimaryInput();
|
assertMustNotBeMoreThanOnePrimaryInput();
|
||||||
const auto b = PrimaryInputs.begin();
|
const auto b = PrimaryInputs.begin();
|
||||||
return b == PrimaryInputs.end() ? nullptr : &AllFiles[b->second];
|
return b == PrimaryInputs.end() ? nullptr : &AllInputs[b->second];
|
||||||
}
|
}
|
||||||
|
|
||||||
const InputFile &FrontendInputs::getRequiredUniquePrimaryInput() const {
|
const InputFile &FrontendInputs::getRequiredUniquePrimaryInput() const {
|
||||||
@@ -75,15 +75,15 @@ StringRef FrontendInputs::getNameOfUniquePrimaryInputFile() const {
|
|||||||
return input == nullptr ? StringRef() : input->file();
|
return input == nullptr ? StringRef() : input->file();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FrontendInputs::isFilePrimary(StringRef file) const {
|
bool FrontendInputs::isInputPrimary(StringRef file) const {
|
||||||
auto iterator = PrimaryInputs.find(file);
|
auto iterator = PrimaryInputs.find(file);
|
||||||
return iterator != PrimaryInputs.end() &&
|
return iterator != PrimaryInputs.end() &&
|
||||||
AllFiles[iterator->second].isPrimary();
|
AllInputs[iterator->second].isPrimary();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef FrontendInputs::getFilenameOfFirstInput() const {
|
StringRef FrontendInputs::getFilenameOfFirstInput() const {
|
||||||
assert(hasInputs());
|
assert(hasInputs());
|
||||||
const InputFile &inp = getAllFiles()[0];
|
const InputFile &inp = AllInputs[0];
|
||||||
StringRef f = inp.file();
|
StringRef f = inp.file();
|
||||||
assert(!f.empty());
|
assert(!f.empty());
|
||||||
return f;
|
return f;
|
||||||
@@ -120,15 +120,15 @@ bool FrontendInputs::shouldTreatAsSIL() const {
|
|||||||
|
|
||||||
void FrontendInputs::addInput(const InputFile &input) {
|
void FrontendInputs::addInput(const InputFile &input) {
|
||||||
if (!input.file().empty() && input.isPrimary())
|
if (!input.file().empty() && input.isPrimary())
|
||||||
PrimaryInputs.insert(std::make_pair(input.file(), AllFiles.size()));
|
PrimaryInputs.insert(std::make_pair(input.file(), AllInputs.size()));
|
||||||
AllFiles.push_back(input);
|
AllInputs.push_back(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
FrontendInputs::numberOfPrimaryInputsEndingWith(const char *extension) const {
|
FrontendInputs::numberOfPrimaryInputsEndingWith(const char *extension) const {
|
||||||
return count_if(
|
return count_if(
|
||||||
PrimaryInputs, [&](const llvm::StringMapEntry<unsigned> &elem) -> bool {
|
PrimaryInputs, [&](const llvm::StringMapEntry<unsigned> &elem) -> bool {
|
||||||
StringRef filename = AllFiles[elem.second].file();
|
StringRef filename = AllInputs[elem.second].file();
|
||||||
return llvm::sys::path::extension(filename).endswith(extension);
|
return llvm::sys::path::extension(filename).endswith(extension);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ bool FrontendInputs::verifyInputs(DiagnosticEngine &diags, bool treatAsSIL,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FrontendInputs::areAllNonPrimariesSIB() const {
|
bool FrontendInputs::areAllNonPrimariesSIB() const {
|
||||||
for (const InputFile &input : getAllFiles()) {
|
for (const InputFile &input : AllInputs) {
|
||||||
if (input.isPrimary())
|
if (input.isPrimary())
|
||||||
continue;
|
continue;
|
||||||
if (!llvm::sys::path::extension(input.file()).endswith(SIB_EXTENSION)) {
|
if (!llvm::sys::path::extension(input.file()).endswith(SIB_EXTENSION)) {
|
||||||
|
|||||||
@@ -811,10 +811,10 @@ static bool performCompile(CompilerInstance &Instance,
|
|||||||
// have a primary serialized input.
|
// have a primary serialized input.
|
||||||
for (FileUnit *fileUnit : mod->getFiles()) {
|
for (FileUnit *fileUnit : mod->getFiles()) {
|
||||||
if (auto SASTF = dyn_cast<SerializedASTFile>(fileUnit)) {
|
if (auto SASTF = dyn_cast<SerializedASTFile>(fileUnit)) {
|
||||||
if (Invocation.getFrontendOptions().Inputs.isFilePrimary(
|
if (Invocation.getFrontendOptions().Inputs.isInputPrimary(
|
||||||
InputFile::
|
InputFile::
|
||||||
convertBufferNameFromLLVM_getFileOrSTDIN_toSwiftConventions(
|
convertBufferNameFromLLVM_getFileOrSTDIN_toSwiftConventions(
|
||||||
SASTF->getFilename()))) {
|
SASTF->getFilename()))) {
|
||||||
assert(PSGIs.empty() && "Can only handle one primary AST input");
|
assert(PSGIs.empty() && "Can only handle one primary AST input");
|
||||||
auto SM = performSILGeneration(*SASTF, SILOpts, None);
|
auto SM = performSILGeneration(*SASTF, SILOpts, None);
|
||||||
PSGIs.push_back(
|
PSGIs.push_back(
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ Migrator::performAFixItMigration(version::Version SwiftLanguageVersion) {
|
|||||||
|
|
||||||
assert(OrigFrontendOpts.Inputs.hasPrimaryInputs() &&
|
assert(OrigFrontendOpts.Inputs.hasPrimaryInputs() &&
|
||||||
"Migration must have a primary");
|
"Migration must have a primary");
|
||||||
for (const auto &input : OrigFrontendOpts.Inputs.getAllFiles()) {
|
for (const auto &input : OrigFrontendOpts.Inputs.getAllInputs()) {
|
||||||
Invocation.getFrontendOptions().Inputs.addInput(
|
Invocation.getFrontendOptions().Inputs.addInput(
|
||||||
InputFile(input.file(), input.isPrimary(),
|
InputFile(input.file(), input.isPrimary(),
|
||||||
input.isPrimary() ? InputBuffer.get() : input.buffer()));
|
input.isPrimary() ? InputBuffer.get() : input.buffer()));
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ resolveSymbolicLinksInInputs(FrontendInputs &inputs,
|
|||||||
// FIXME: The frontend should be dealing with symlinks, maybe similar to
|
// FIXME: The frontend should be dealing with symlinks, maybe similar to
|
||||||
// clang's FileManager ?
|
// clang's FileManager ?
|
||||||
FrontendInputs replacementInputs;
|
FrontendInputs replacementInputs;
|
||||||
for (const InputFile &input : inputs.getAllFiles()) {
|
for (const InputFile &input : inputs.getAllInputs()) {
|
||||||
std::string newFilename =
|
std::string newFilename =
|
||||||
SwiftLangSupport::resolvePathSymlinks(input.file());
|
SwiftLangSupport::resolvePathSymlinks(input.file());
|
||||||
bool newIsPrimary = input.isPrimary() ||
|
bool newIsPrimary = input.isPrimary() ||
|
||||||
@@ -709,7 +709,7 @@ bool ASTProducer::shouldRebuild(SwiftASTManager::Implementation &MgrImpl,
|
|||||||
InputStamps.reserve(
|
InputStamps.reserve(
|
||||||
Invok.Opts.Invok.getFrontendOptions().Inputs.inputCount());
|
Invok.Opts.Invok.getFrontendOptions().Inputs.inputCount());
|
||||||
for (const auto &input :
|
for (const auto &input :
|
||||||
Invok.Opts.Invok.getFrontendOptions().Inputs.getAllFiles()) {
|
Invok.Opts.Invok.getFrontendOptions().Inputs.getAllInputs()) {
|
||||||
StringRef File = input.file();
|
StringRef File = input.file();
|
||||||
bool FoundSnapshot = false;
|
bool FoundSnapshot = false;
|
||||||
for (auto &Snap : Snapshots) {
|
for (auto &Snap : Snapshots) {
|
||||||
@@ -896,7 +896,7 @@ void ASTProducer::findSnapshotAndOpenFiles(
|
|||||||
SmallVectorImpl<FileContent> &Contents, std::string &Error) const {
|
SmallVectorImpl<FileContent> &Contents, std::string &Error) const {
|
||||||
const InvocationOptions &Opts = InvokRef->Impl.Opts;
|
const InvocationOptions &Opts = InvokRef->Impl.Opts;
|
||||||
for (const auto &input :
|
for (const auto &input :
|
||||||
Opts.Invok.getFrontendOptions().Inputs.getAllFiles()) {
|
Opts.Invok.getFrontendOptions().Inputs.getAllInputs()) {
|
||||||
StringRef File = input.file();
|
StringRef File = input.file();
|
||||||
bool IsPrimary = input.isPrimary();
|
bool IsPrimary = input.isPrimary();
|
||||||
bool FoundSnapshot = false;
|
bool FoundSnapshot = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user