diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index 11343b2db92..00696c832b2 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -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 Imports[2]; + SmallVector, 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,