Clean up implicit import code: use SmallVector instead of a plain array

Swift SVN r9716
This commit is contained in:
Dmitri Hrybenko
2013-10-28 18:43:46 +00:00
parent eecac1fd9c
commit 9e346b6b80

View File

@@ -1136,7 +1136,7 @@ static void performAutoImport(SourceFile &SF, bool hasBuiltinModuleAccess) {
// If we're building the standard library, import the magic Builtin module,
// otherwise, import the standard library.
std::pair<Module::ImportedModule, bool> Imports[2];
SmallVector<std::pair<Module::ImportedModule, bool>, 2> Imports;
Module *M;
if (hasBuiltinModuleAccess)
M = SF.TU.Ctx.TheBuiltinModule;
@@ -1148,16 +1148,15 @@ static void performAutoImport(SourceFile &SF, bool hasBuiltinModuleAccess) {
// FIXME: These will be the same for most source files, but we copy them
// over and over again.
Imports[0] = std::make_pair(Module::ImportedModule({}, M), false);
Imports.push_back(std::make_pair(Module::ImportedModule({}, M), false));
if (SF.TU.Ctx.LangOpts.Axle && !hasBuiltinModuleAccess) {
Module* AxleM =
SF.TU.Ctx.getModule({{SF.TU.Ctx.AxleStdlibModuleName, SourceLoc()}});
Imports[1] = std::make_pair(Module::ImportedModule({}, AxleM), false);
SF.setImports(SF.TU.Ctx.AllocateCopy(llvm::makeArrayRef(Imports, 2)));
} else
SF.setImports(SF.TU.Ctx.AllocateCopy(llvm::makeArrayRef(Imports, 1)));
Module *AxleModule =
SF.TU.Ctx.getModule({{SF.TU.Ctx.AxleStdlibModuleName, SourceLoc()}});
if(AxleModule)
Imports.push_back(
std::make_pair(Module::ImportedModule({}, AxleModule), false));
}
SF.setImports(SF.TU.Ctx.AllocateCopy(Imports));
}
SourceFile::SourceFile(TranslationUnit &tu, SourceKind K,