Lines Matching +full:output +full:- +full:sarif

1 //===--- CompilerInstance.cpp ---------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
45 #include "llvm/Config/llvm-config.h"
75 assert(OutputFiles.empty() && "Still output files in flight?"); in ~CompilerInstance()
85 (TheASTReader && TheASTReader->isGlobalIndexUnavailable() && in shouldBuildGlobalModuleIndex()
121 TO->Triple = llvm::Triple::normalize(getFrontendOpts().AuxTriple); in createTarget()
123 TO->CPU = *getFrontendOpts().AuxTargetCPU; in createTarget()
125 TO->FeaturesAsWritten = *getFrontendOpts().AuxTargetFeatures; in createTarget()
126 TO->HostTriple = getTarget().getTriple().str(); in createTarget()
206 assert(ModuleCache.get() == &Reader->getModuleManager().getModuleCache() && in setASTReader()
226 MDC->addFile(Name); in collectHeaderMaps()
239 MDC->addFile(PCHInclude); in collectIncludePCH()
245 llvm::sys::path::native(PCHDir->getName(), DirNative); in collectIncludePCH()
254 Dir->path(), FileMgr, CI.getModuleCache(), in collectIncludePCH()
258 MDC->addFile(Dir->path()); in collectIncludePCH()
279 MDC->addFile(E.VPath, E.RPath); in collectVFSEntries()
289 if (DiagOpts->DiagnosticLogFile != "-") { in SetUpDiagnosticLog()
290 // Create the output stream. in SetUpDiagnosticLog()
292 DiagOpts->DiagnosticLogFile, EC, in SetUpDiagnosticLog()
296 << DiagOpts->DiagnosticLogFile << EC.message(); in SetUpDiagnosticLog()
298 FileOS->SetUnbuffered(); in SetUpDiagnosticLog()
308 Logger->setDwarfDebugFlags(CodeGenOpts->DwarfDebugFlags); in SetUpDiagnosticLog()
349 // implementing -verify. in createDiagnostics()
351 Diags->setClient(Client, ShouldOwnClient); in createDiagnostics()
352 } else if (Opts->getFormat() == DiagnosticOptions::SARIF) { in createDiagnostics()
353 Diags->setClient(new SARIFDiagnosticPrinter(llvm::errs(), Opts)); in createDiagnostics()
355 Diags->setClient(new TextDiagnosticPrinter(llvm::errs(), Opts)); in createDiagnostics()
357 // Chain in -verify checker, if requested. in createDiagnostics()
358 if (Opts->VerifyDiagnostics) in createDiagnostics()
359 Diags->setClient(new VerifyDiagnosticConsumer(*Diags)); in createDiagnostics()
361 // Chain in -diagnostic-log-file dumper, if requested. in createDiagnostics()
362 if (!Opts->DiagnosticLogFile.empty()) in createDiagnostics()
365 if (!Opts->DiagnosticSerializationFile.empty()) in createDiagnostics()
367 Opts->DiagnosticSerializationFile); in createDiagnostics()
380 VFS = FileMgr ? &FileMgr->getVirtualFileSystem() in createFileManager()
404 FileMgr.getVirtualFileRef(RB.first, RB.second->getBufferSize(), 0); in InitializeFileRemapping()
411 SourceMgr.overrideFileContents(FromFile, RB.second->getMemBufferRef()); in InitializeFileRemapping()
428 FileMgr.getVirtualFile(RF.first, ToFile->getSize(), 0); in InitializeFileRemapping()
455 PP = std::make_shared<Preprocessor>(Invocation->getPreprocessorOptsPtr(), in createPreprocessor()
461 PP->Initialize(getTarget(), getAuxTarget()); in createPreprocessor()
464 PP->createPreprocessingRecord(); in createPreprocessor()
467 InitializeFileRemapping(PP->getDiagnostics(), PP->getSourceManager(), in createPreprocessor()
468 PP->getFileManager(), PPOpts); in createPreprocessor()
477 const llvm::Triple *HeaderSearchTriple = &PP->getTargetInfo().getTriple(); in createPreprocessor()
478 if (PP->getTargetInfo().getTriple().getOS() == llvm::Triple::CUDA && in createPreprocessor()
479 PP->getAuxTargetInfo()) in createPreprocessor()
480 HeaderSearchTriple = &PP->getAuxTargetInfo()->getTriple(); in createPreprocessor()
482 ApplyHeaderSearchOptions(PP->getHeaderSearchInfo(), getHeaderSearchOpts(), in createPreprocessor()
483 PP->getLangOpts(), *HeaderSearchTriple); in createPreprocessor()
485 PP->setPreprocessedOutput(getPreprocessorOutputOpts().ShowCPP); in createPreprocessor()
487 if (PP->getLangOpts().Modules && PP->getLangOpts().ImplicitModules) { in createPreprocessor()
489 PP->getHeaderSearchInfo().setModuleHash(ModuleHash); in createPreprocessor()
490 PP->getHeaderSearchInfo().setModuleCachePath( in createPreprocessor()
513 collectHeaderMaps(PP->getHeaderSearchInfo(), ModuleDepCollector); in createPreprocessor()
519 Listener->attachToPreprocessor(*PP); in createPreprocessor()
526 if (OutputPath == "-") in createPreprocessor()
541 // Set up the module path, including the hash for the module-creation options. in getSpecificModuleCachePath()
555 Context->InitBuiltinTypes(getTarget(), getAuxTarget()); in createASTContext()
589 M->HasIncompatibleModuleFile = true; in markAllUnavailable()
597 if (Current->IsUnimportable) continue; in markAllUnavailable()
598 Current->IsAvailable = true; in markAllUnavailable()
599 auto SubmodulesRange = Current->submodules(); in markAllUnavailable()
644 // eagerly-deserialized declarations may use it. in createPCHExternalASTSource()
647 Reader->setDeserializationListener( in createPCHExternalASTSource()
652 Listener->attachToASTReader(*Reader); in createPCHExternalASTSource()
659 switch (Reader->ReadAST(Path, in createPCHExternalASTSource()
667 PP.setPredefines(Reader->getSuggestedPredefines()); in createPCHExternalASTSource()
725 new llvm::TimerGroup("frontend", "Clang front-end time report")); in createFrontendTimer()
727 new llvm::Timer("frontend", "Clang front-end timer", in createFrontendTimer()
741 // Set up the creation routine for code-completion. in createCodeCompletionConsumer()
751 TheSema->APINotes.setSwiftVersion(getAPINotesOpts().SwiftVersion); in createSema()
755 TheSema->addExternalSource(ExternalSemaSrc.get()); in createSema()
756 ExternalSemaSrc->InitializeSema(*TheSema); in createSema()
762 (void)TheSema->APINotes.loadCurrentModuleAPINotes( in createSema()
768 // Output Files
771 // The ASTConsumer can own streams that write to the output files. in clearOutputFiles()
777 consumeError(OF.File->discard()); in clearOutputFiles()
786 if (OF.File->TmpName.empty()) { in clearOutputFiles()
787 consumeError(OF.File->discard()); in clearOutputFiles()
791 llvm::Error E = OF.File->keep(OF.Filename); in clearOutputFiles()
796 << OF.File->TmpName << OF.Filename << std::move(E); in clearOutputFiles()
798 llvm::sys::fs::remove(OF.File->TmpName); in clearOutputFiles()
814 if (InFile == "-" || Extension.empty()) { in createDefaultOutputFile()
815 OutputPath = "-"; in createDefaultOutputFile()
854 // If '-working-directory' was passed, the output filename should be in createOutputFileImpl()
857 if (OutputPath != "-" && !llvm::sys::path::is_absolute(OutputPath)) { in createOutputFileImpl()
862 FileMgr->FixupRelativePath(*AbsPath); in createOutputFileImpl()
870 if (OutputPath == "-") in createOutputFileImpl()
881 // Don't use a temporary if the output is a special file. This handles in createOutputFileImpl()
882 // things like '-o /dev/null' in createOutputFileImpl()
892 // Insert -%%%%%%%% before the extension (if any), and because some tools in createOutputFileImpl()
898 TempPath += "-%%%%%%%%"; in createOutputFileImpl()
909 ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error { in createOutputFileImpl()
931 OS.reset(new llvm::raw_fd_ostream(Temp->FD, /*shouldClose=*/false)); in createOutputFileImpl()
932 OSFile = Temp->TmpName; in createOutputFileImpl()
949 // Add the output file -- but don't try to remove "-", since this means we are in createOutputFileImpl()
951 OutputFiles.emplace_back(((OutputPath != "-") ? OutputPath : "").str(), in createOutputFileImpl()
954 if (!Binary || OS->supportsSeeking()) in createOutputFileImpl()
988 auto FileOrErr = InputFile == "-" in InitializeSourceManager()
993 if (InputFile != "-") in InitializeSourceManager()
1008 // High-Level Operations
1012 assert(!getFrontendOpts().ShowHelp && "Client must handle '-help'!"); in ExecuteAction()
1013 assert(!getFrontendOpts().ShowVersion && "Client must handle '-version'!"); in ExecuteAction()
1033 // rewriter project will change target built-in bool type from its default. in ExecuteAction()
1039 OS << "clang -cc1 version " CLANG_VERSION_STRING << " based upon LLVM " in ExecuteAction()
1093 return !getDiagnostics().getClient()->getNumErrors(); in ExecuteAction()
1104 unsigned NumWarnings = getDiagnostics().getClient()->getNumWarnings(); in printDiagnosticStats()
1105 unsigned NumErrors = getDiagnostics().getClient()->getNumErrors(); in printDiagnosticStats()
1139 if (P->getActionType() == PluginASTAction::ReplaceAction) { in LoadRequestedPlugins()
1172 // Never compile a module that's already finalized - this would cause the
1185 PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts();
1189 Invocation->resetNonModularOptions();
1193 HeaderSearchOptions &HSOpts = Invocation->getHeaderSearchOpts();
1201 // If the original compiler invocation had -fmodule-name, pass it through.
1202 Invocation->getLangOpts().ModuleName =
1206 Invocation->getLangOpts().CurrentModule = std::string(ModuleName);
1211 FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
1217 // Force implicitly-built modules to hash the content of the module file.
1224 DiagnosticOptions &DiagOpts = Invocation->getDiagnosticOpts();
1228 Invocation->getModuleHash() && "Module hash mismatch!");
1231 // module. Since we're sharing an in-memory module cache,
1233 // buffers to prevent use-after-frees.
1261 // Make sure that the failed-module structure has been allocated in
1262 // the importing instance, and propagate the pointer to the newly-created
1270 // want to produce any dependency output from the module build.
1280 // Execute the action to actually build the module in-place. Use a separate
1301 // that must be closed before clearing output files.
1344 // We want to use the top-level module map. If we don't, the compiling in compileModule()
1345 // instance may think the containing module map is a top-level one, while in compileModule()
1356 assert(ModuleMapFile && "Top-level module map with no FileID"); in compileModule()
1365 StringRef ModuleMapFilePath = ModuleMapFile->getNameAsRequested(); in compileModule()
1369 ImportingInstance, ImportLoc, Module->getTopLevelModuleName(), in compileModule()
1370 FrontendInputFile(ModuleMapFilePath, IK, +Module->IsSystem), in compileModule()
1371 ModMap.getModuleMapFileForUniquing(Module)->getName(), ModuleFileName); in compileModule()
1377 SmallString<128> FakeModuleMapFile(Module->Directory->getName()); in compileModule()
1382 Module->print(OS); in compileModule()
1386 ImportingInstance, ImportLoc, Module->getTopLevelModuleName(), in compileModule()
1387 FrontendInputFile(FakeModuleMapFile, IK, +Module->IsSystem), in compileModule()
1388 ModMap.getModuleMapFileForUniquing(Module)->getName(), in compileModule()
1423 ImportingInstance.getASTReader()->ReadAST( in readASTAfterCompileModule()
1429 // The caller wants to handle out-of-date failures. in readASTAfterCompileModule()
1438 << Module->Name << SourceRange(ImportLoc, ModuleNameLoc); in readASTAfterCompileModule()
1454 << Module->Name << SourceRange(ImportLoc, ModuleNameLoc); in compileModuleAndReadASTImpl()
1477 << ModuleFileName << Module->Name; in compileModuleAndReadASTBehindLock()
1492 << Module->Name << Locked.getErrorMessage(); in compileModuleAndReadASTBehindLock()
1517 << Module->Name; in compileModuleAndReadASTBehindLock()
1565 if (!Id->hadMacroDefinition()) in checkConfigMacro()
1571 for (auto *MD = LatestLocalMD; MD; MD = MD->getPrevious()) { in checkConfigMacro()
1573 FileID FID = SourceMgr.getFileID(MD->getLocation()); in checkConfigMacro()
1577 CmdLineDefinition = DMD->getMacroInfo(); in checkConfigMacro()
1588 << true << ConfigMacro << Mod->getFullModuleName(); in checkConfigMacro()
1589 auto LatestDef = LatestLocalMD->getDefinition(); in checkConfigMacro()
1599 << false << ConfigMacro << Mod->getFullModuleName(); in checkConfigMacro()
1600 PP.Diag(CurrentDefinition->getDefinitionLoc(), in checkConfigMacro()
1603 } else if (!CurrentDefinition->isIdenticalTo(*CmdLineDefinition, PP, in checkConfigMacro()
1607 << false << ConfigMacro << Mod->getFullModuleName(); in checkConfigMacro()
1608 PP.Diag(CurrentDefinition->getDefinitionLoc(), in checkConfigMacro()
1616 clang::Module *TopModule = M->getTopLevelModule(); in checkConfigMacros()
1617 for (const StringRef ConMacro : TopModule->ConfigMacros) { in checkConfigMacros()
1651 if (CurrentTime - TimeStampModTime <= time_t(HSOpts.ModuleCachePruneInterval)) in pruneModuleCache()
1656 // notice at the same time that the timestamp is out-of-date. in pruneModuleCache()
1667 if (!llvm::sys::fs::is_directory(Dir->path())) in pruneModuleCache()
1671 for (llvm::sys::fs::directory_iterator File(Dir->path(), EC), FileEnd; in pruneModuleCache()
1674 StringRef Extension = llvm::sys::path::extension(File->path()); in pruneModuleCache()
1676 llvm::sys::path::filename(File->path()) != "modules.idx") in pruneModuleCache()
1681 if (llvm::sys::fs::status(File->path(), StatBuf)) in pruneModuleCache()
1686 if (CurrentTime - FileAccessTime <= in pruneModuleCache()
1692 llvm::sys::fs::remove(File->path()); in pruneModuleCache()
1695 std::string TimpestampFilename = File->path() + ".timestamp"; in pruneModuleCache()
1701 if (llvm::sys::fs::directory_iterator(Dir->path(), EC) == in pruneModuleCache()
1703 llvm::sys::fs::remove(Dir->path()); in pruneModuleCache()
1743 TheASTReader->setDeserializationListener( in createASTReader()
1750 TheASTReader->InitializeSema(getSema()); in createASTReader()
1752 TheASTReader->StartTranslationUnit(&getASTConsumer()); in createASTReader()
1755 Listener->attachToASTReader(*TheASTReader); in createASTReader()
1770 // If -Wmodule-file-config-mismatch is mapped as an error or worse, allow the in loadModuleFile()
1783 switch (TheASTReader->ReadAST( in loadModuleFile()
1828 ModuleFilename = BuiltModuleIt->second; in selectModuleSource()
1856 HeaderSearch &HS = PP->getHeaderSearchInfo(); in findOrCompileModuleAndReadAST()
1878 if (M && M->HasIncompatibleModuleFile) { in findOrCompileModuleAndReadAST()
1909 switch (getASTReader()->ReadAST(ModuleFilename, in findOrCompileModuleAndReadAST()
1927 if (M && M->getASTFile()) in findOrCompileModuleAndReadAST()
1928 if (auto ModuleFile = FileMgr->getFile(ModuleFilename)) in findOrCompileModuleAndReadAST()
1929 if (*ModuleFile == M->getASTFile()) in findOrCompileModuleAndReadAST()
1971 // The module file is missing or out-of-date. Build it. in findOrCompileModuleAndReadAST()
1978 if (Pos->first == ModuleName) in findOrCompileModuleAndReadAST()
1985 CyclePath += Pos->first; in findOrCompileModuleAndReadAST()
1986 CyclePath += " -> "; in findOrCompileModuleAndReadAST()
1996 if (FailedModules && FailedModules->hasAlreadyFailed(ModuleName)) { in findOrCompileModuleAndReadAST()
2008 FailedModules->addFailed(ModuleName); in findOrCompileModuleAndReadAST()
2022 StringRef ModuleName = Path[0].first->getName(); in loadModule()
2026 // This one-element cache is important to eliminate redundant diagnostics in loadModule()
2031 TheASTReader->makeModuleVisible(LastModuleImportResult, Visibility, in loadModule()
2049 Module = PP->getHeaderSearchInfo().lookupModule( in loadModule()
2080 StringRef Name = Path[I].first->getName(); in loadModule()
2081 clang::Module *Sub = Module->findSubmodule(Name); in loadModule()
2087 if (!Sub && Name == "Private" && Module == Module->getTopLevelModule()) { in loadModule()
2088 SmallString<128> PrivateModule(Module->Name); in loadModule()
2092 auto &II = PP->getIdentifierTable().get( in loadModule()
2093 PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID()); in loadModule()
2098 if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, true, in loadModule()
2101 PP->getHeaderSearchInfo()) != MS_ModuleNotFound) in loadModule()
2105 PP->markClangModuleAsAffecting(Module); in loadModule()
2110 << Path[I].first << Module->getFullModuleName() << PrivateModule in loadModule()
2114 getDiagnostics().Report(Sub->DefinitionLoc, in loadModule()
2125 for (class Module *SubModule : Module->submodules()) { in loadModule()
2127 Name.edit_distance(SubModule->Name, in loadModule()
2135 Best.push_back(SubModule->Name); in loadModule()
2142 << Path[I].first << Module->getFullModuleName() << Best[0] in loadModule()
2143 << SourceRange(Path[0].second, Path[I - 1].second) in loadModule()
2147 Sub = Module->findSubmodule(Best[0]); in loadModule()
2155 << Path[I].first << Module->getFullModuleName() in loadModule()
2156 << SourceRange(Path[0].second, Path[I - 1].second); in loadModule()
2166 if (!Module->IsFromModuleFile && !MapPrivateSubModToTopLevel) { in loadModule()
2174 << Module->getFullModuleName() in loadModule()
2190 TheASTReader->makeModuleVisible(Module, Visibility, ImportLoc); in loadModule()
2197 .resolveLinkAsDependencies(Module->getTopLevelModule()); in loadModule()
2214 // output is nondeterministic (as .pcm files refer to each other by name). in createModuleFromSource()
2215 // Can this affect the output in any way? in createModuleFromSource()
2227 InputKind(getLanguageFromOptions(Invocation->getLangOpts()), in createModuleFromSource()
2264 TheASTReader->makeModuleVisible(Mod, Visibility, ImportLoc); in makeModuleVisible()
2278 TheASTReader->loadGlobalIndex(); in loadGlobalModuleIndex()
2279 GlobalModuleIndex *GlobalIndex = TheASTReader->getGlobalIndex(); in loadGlobalModuleIndex()
2295 TheASTReader->resetForReload(); in loadGlobalModuleIndex()
2296 TheASTReader->loadGlobalIndex(); in loadGlobalModuleIndex()
2297 GlobalIndex = TheASTReader->getGlobalIndex(); in loadGlobalModuleIndex()
2306 Module *TheModule = I->second; in loadGlobalModuleIndex()
2307 OptionalFileEntryRef Entry = TheModule->getASTFile(); in loadGlobalModuleIndex()
2311 getPreprocessor().getIdentifierInfo(TheModule->Name), TriggerLoc)); in loadGlobalModuleIndex()
2314 loadModule(TheModule->DefinitionLoc, Path, Module::Hidden, false); in loadGlobalModuleIndex()
2326 TheASTReader->resetForReload(); in loadGlobalModuleIndex()
2327 TheASTReader->loadGlobalIndex(); in loadGlobalModuleIndex()
2328 GlobalIndex = TheASTReader->getGlobalIndex(); in loadGlobalModuleIndex()
2339 // Look for the symbol in non-imported modules, but only if an error in lookupMissingImports()
2351 // Note that this only finds top-level modules. in lookupMissingImports()
2353 if (GlobalIndex->lookupIdentifier(Name, FoundModules)) in lookupMissingImports()