1 //===- DependencyScanningService.h - clang-scan-deps service ===-*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H 10 #define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H 11 12 #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h" 13 #include "llvm/ADT/BitmaskEnum.h" 14 15 namespace clang { 16 namespace tooling { 17 namespace dependencies { 18 19 /// The mode in which the dependency scanner will operate to find the 20 /// dependencies. 21 enum class ScanningMode { 22 /// This mode is used to compute the dependencies by running the preprocessor 23 /// over the source files. 24 CanonicalPreprocessing, 25 26 /// This mode is used to compute the dependencies by running the preprocessor 27 /// with special kind of lexing after scanning header and source files to get 28 /// the minimum necessary preprocessor directives for evaluating includes. 29 DependencyDirectivesScan, 30 }; 31 32 /// The format that is output by the dependency scanner. 33 enum class ScanningOutputFormat { 34 /// This is the Makefile compatible dep format. This will include all of the 35 /// deps necessary for an implicit modules build, but won't include any 36 /// intermodule dependency information. 37 Make, 38 39 /// This outputs the full clang module dependency graph suitable for use for 40 /// explicitly building modules. 41 Full, 42 43 /// This outputs the dependency graph for standard c++ modules in P1689R5 44 /// format. 45 P1689, 46 }; 47 48 #define DSS_LAST_BITMASK_ENUM(Id) \ 49 LLVM_MARK_AS_BITMASK_ENUM(Id), All = llvm::NextPowerOf2(Id) - 1 50 51 enum class ScanningOptimizations { 52 None = 0, 53 54 /// Remove unused header search paths including header maps. 55 HeaderSearch = 1, 56 57 /// Remove warnings from system modules. 58 SystemWarnings = 2, 59 60 /// Remove unused -ivfsoverlay arguments. 61 VFS = 4, 62 63 /// Canonicalize -D and -U options. 64 Macros = 8, 65 66 DSS_LAST_BITMASK_ENUM(Macros), 67 Default = All 68 }; 69 70 #undef DSS_LAST_BITMASK_ENUM 71 72 /// The dependency scanning service contains shared configuration and state that 73 /// is used by the individual dependency scanning workers. 74 class DependencyScanningService { 75 public: 76 DependencyScanningService( 77 ScanningMode Mode, ScanningOutputFormat Format, 78 ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default, 79 bool EagerLoadModules = false); 80 getMode()81 ScanningMode getMode() const { return Mode; } 82 getFormat()83 ScanningOutputFormat getFormat() const { return Format; } 84 getOptimizeArgs()85 ScanningOptimizations getOptimizeArgs() const { return OptimizeArgs; } 86 shouldEagerLoadModules()87 bool shouldEagerLoadModules() const { return EagerLoadModules; } 88 getSharedCache()89 DependencyScanningFilesystemSharedCache &getSharedCache() { 90 return SharedCache; 91 } 92 93 private: 94 const ScanningMode Mode; 95 const ScanningOutputFormat Format; 96 /// Whether to optimize the modules' command-line arguments. 97 const ScanningOptimizations OptimizeArgs; 98 /// Whether to set up command-lines to load PCM files eagerly. 99 const bool EagerLoadModules; 100 /// The global file system cache. 101 DependencyScanningFilesystemSharedCache SharedCache; 102 }; 103 104 } // end namespace dependencies 105 } // end namespace tooling 106 } // end namespace clang 107 108 #endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H 109