Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:11

0001 //===- DependencyScanningService.h - clang-scan-deps service ===-*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
0010 #define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
0011 
0012 #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h"
0013 #include "llvm/ADT/BitmaskEnum.h"
0014 
0015 namespace clang {
0016 namespace tooling {
0017 namespace dependencies {
0018 
0019 /// The mode in which the dependency scanner will operate to find the
0020 /// dependencies.
0021 enum class ScanningMode {
0022   /// This mode is used to compute the dependencies by running the preprocessor
0023   /// over the source files.
0024   CanonicalPreprocessing,
0025 
0026   /// This mode is used to compute the dependencies by running the preprocessor
0027   /// with special kind of lexing after scanning header and source files to get
0028   /// the minimum necessary preprocessor directives for evaluating includes.
0029   DependencyDirectivesScan,
0030 };
0031 
0032 /// The format that is output by the dependency scanner.
0033 enum class ScanningOutputFormat {
0034   /// This is the Makefile compatible dep format. This will include all of the
0035   /// deps necessary for an implicit modules build, but won't include any
0036   /// intermodule dependency information.
0037   Make,
0038 
0039   /// This outputs the full clang module dependency graph suitable for use for
0040   /// explicitly building modules.
0041   Full,
0042 
0043   /// This outputs the dependency graph for standard c++ modules in P1689R5
0044   /// format.
0045   P1689,
0046 };
0047 
0048 #define DSS_LAST_BITMASK_ENUM(Id)                                              \
0049   LLVM_MARK_AS_BITMASK_ENUM(Id), All = llvm::NextPowerOf2(Id) - 1
0050 
0051 enum class ScanningOptimizations {
0052   None = 0,
0053 
0054   /// Remove unused header search paths including header maps.
0055   HeaderSearch = 1,
0056 
0057   /// Remove warnings from system modules.
0058   SystemWarnings = 2,
0059 
0060   /// Remove unused -ivfsoverlay arguments.
0061   VFS = 4,
0062 
0063   /// Canonicalize -D and -U options.
0064   Macros = 8,
0065 
0066   DSS_LAST_BITMASK_ENUM(Macros),
0067   Default = All
0068 };
0069 
0070 #undef DSS_LAST_BITMASK_ENUM
0071 
0072 /// The dependency scanning service contains shared configuration and state that
0073 /// is used by the individual dependency scanning workers.
0074 class DependencyScanningService {
0075 public:
0076   DependencyScanningService(
0077       ScanningMode Mode, ScanningOutputFormat Format,
0078       ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default,
0079       bool EagerLoadModules = false, bool TraceVFS = false);
0080 
0081   ScanningMode getMode() const { return Mode; }
0082 
0083   ScanningOutputFormat getFormat() const { return Format; }
0084 
0085   ScanningOptimizations getOptimizeArgs() const { return OptimizeArgs; }
0086 
0087   bool shouldEagerLoadModules() const { return EagerLoadModules; }
0088 
0089   bool shouldTraceVFS() const { return TraceVFS; }
0090 
0091   DependencyScanningFilesystemSharedCache &getSharedCache() {
0092     return SharedCache;
0093   }
0094 
0095 private:
0096   const ScanningMode Mode;
0097   const ScanningOutputFormat Format;
0098   /// Whether to optimize the modules' command-line arguments.
0099   const ScanningOptimizations OptimizeArgs;
0100   /// Whether to set up command-lines to load PCM files eagerly.
0101   const bool EagerLoadModules;
0102   /// Whether to trace VFS accesses.
0103   const bool TraceVFS;
0104   /// The global file system cache.
0105   DependencyScanningFilesystemSharedCache SharedCache;
0106 };
0107 
0108 } // end namespace dependencies
0109 } // end namespace tooling
0110 } // end namespace clang
0111 
0112 #endif // LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H