1a7dea167SDimitry Andric //===- DependencyScanningService.h - clang-scan-deps service ===-*- C++ -*-===// 2a7dea167SDimitry Andric // 3a7dea167SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4a7dea167SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5a7dea167SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6a7dea167SDimitry Andric // 7a7dea167SDimitry Andric //===----------------------------------------------------------------------===// 8a7dea167SDimitry Andric 904eeddc0SDimitry Andric #ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H 1004eeddc0SDimitry Andric #define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H 11a7dea167SDimitry Andric 12a7dea167SDimitry Andric #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h" 13*5f757f3fSDimitry Andric #include "llvm/ADT/BitmaskEnum.h" 14a7dea167SDimitry Andric 15a7dea167SDimitry Andric namespace clang { 16a7dea167SDimitry Andric namespace tooling { 17a7dea167SDimitry Andric namespace dependencies { 18a7dea167SDimitry Andric 19a7dea167SDimitry Andric /// The mode in which the dependency scanner will operate to find the 20a7dea167SDimitry Andric /// dependencies. 21a7dea167SDimitry Andric enum class ScanningMode { 22a7dea167SDimitry Andric /// This mode is used to compute the dependencies by running the preprocessor 2381ad6265SDimitry Andric /// over the source files. 24a7dea167SDimitry Andric CanonicalPreprocessing, 25a7dea167SDimitry Andric 26a7dea167SDimitry Andric /// This mode is used to compute the dependencies by running the preprocessor 2781ad6265SDimitry Andric /// with special kind of lexing after scanning header and source files to get 2881ad6265SDimitry Andric /// the minimum necessary preprocessor directives for evaluating includes. 2981ad6265SDimitry Andric DependencyDirectivesScan, 30a7dea167SDimitry Andric }; 31a7dea167SDimitry Andric 32480093f4SDimitry Andric /// The format that is output by the dependency scanner. 33480093f4SDimitry Andric enum class ScanningOutputFormat { 34480093f4SDimitry Andric /// This is the Makefile compatible dep format. This will include all of the 35480093f4SDimitry Andric /// deps necessary for an implicit modules build, but won't include any 36480093f4SDimitry Andric /// intermodule dependency information. 37480093f4SDimitry Andric Make, 38480093f4SDimitry Andric 391ac55f4cSDimitry Andric /// This outputs the full clang module dependency graph suitable for use for 40480093f4SDimitry Andric /// explicitly building modules. 41480093f4SDimitry Andric Full, 421ac55f4cSDimitry Andric 431ac55f4cSDimitry Andric /// This outputs the dependency graph for standard c++ modules in P1689R5 441ac55f4cSDimitry Andric /// format. 451ac55f4cSDimitry Andric P1689, 46480093f4SDimitry Andric }; 47480093f4SDimitry Andric 48*5f757f3fSDimitry Andric enum class ScanningOptimizations { 49*5f757f3fSDimitry Andric None = 0, 50*5f757f3fSDimitry Andric 51*5f757f3fSDimitry Andric /// Remove unused header search paths including header maps. 52*5f757f3fSDimitry Andric HeaderSearch = 1, 53*5f757f3fSDimitry Andric 54*5f757f3fSDimitry Andric /// Remove warnings from system modules. 55*5f757f3fSDimitry Andric SystemWarnings = 2, 56*5f757f3fSDimitry Andric 57*5f757f3fSDimitry Andric LLVM_MARK_AS_BITMASK_ENUM(SystemWarnings), 58*5f757f3fSDimitry Andric All = HeaderSearch | SystemWarnings, 59*5f757f3fSDimitry Andric Default = All 60*5f757f3fSDimitry Andric }; 61*5f757f3fSDimitry Andric 62bdd1243dSDimitry Andric /// The dependency scanning service contains shared configuration and state that 63bdd1243dSDimitry Andric /// is used by the individual dependency scanning workers. 64a7dea167SDimitry Andric class DependencyScanningService { 65a7dea167SDimitry Andric public: 66*5f757f3fSDimitry Andric DependencyScanningService( 67*5f757f3fSDimitry Andric ScanningMode Mode, ScanningOutputFormat Format, 68*5f757f3fSDimitry Andric ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default, 69bdd1243dSDimitry Andric bool EagerLoadModules = false); 70a7dea167SDimitry Andric getMode()71a7dea167SDimitry Andric ScanningMode getMode() const { return Mode; } 72a7dea167SDimitry Andric getFormat()73480093f4SDimitry Andric ScanningOutputFormat getFormat() const { return Format; } 74480093f4SDimitry Andric getOptimizeArgs()75*5f757f3fSDimitry Andric ScanningOptimizations getOptimizeArgs() const { return OptimizeArgs; } 76349cc55cSDimitry Andric shouldEagerLoadModules()77bdd1243dSDimitry Andric bool shouldEagerLoadModules() const { return EagerLoadModules; } 78bdd1243dSDimitry Andric getSharedCache()79a7dea167SDimitry Andric DependencyScanningFilesystemSharedCache &getSharedCache() { 80a7dea167SDimitry Andric return SharedCache; 81a7dea167SDimitry Andric } 82a7dea167SDimitry Andric 83a7dea167SDimitry Andric private: 84a7dea167SDimitry Andric const ScanningMode Mode; 85480093f4SDimitry Andric const ScanningOutputFormat Format; 86349cc55cSDimitry Andric /// Whether to optimize the modules' command-line arguments. 87*5f757f3fSDimitry Andric const ScanningOptimizations OptimizeArgs; 88bdd1243dSDimitry Andric /// Whether to set up command-lines to load PCM files eagerly. 89bdd1243dSDimitry Andric const bool EagerLoadModules; 90a7dea167SDimitry Andric /// The global file system cache. 91a7dea167SDimitry Andric DependencyScanningFilesystemSharedCache SharedCache; 92a7dea167SDimitry Andric }; 93a7dea167SDimitry Andric 94a7dea167SDimitry Andric } // end namespace dependencies 95a7dea167SDimitry Andric } // end namespace tooling 96a7dea167SDimitry Andric } // end namespace clang 97a7dea167SDimitry Andric 9804eeddc0SDimitry Andric #endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H 99