//===--- Driver.h - Clang GCC Compatible Driver -----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_DRIVER_DRIVER_H #define LLVM_CLANG_DRIVER_DRIVER_H #include "clang/Basic/Diagnostic.h" #include "clang/Basic/HeaderInclude.h" #include "clang/Basic/LLVM.h" #include "clang/Driver/Action.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/InputInfo.h" #include "clang/Driver/Options.h" #include "clang/Driver/Phases.h" #include "clang/Driver/ToolChain.h" #include "clang/Driver/Types.h" #include "clang/Driver/Util.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLFunctionalExtras.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Support/StringSaver.h" #include <map> #include <set> #include <string> #include <vector> namespace llvm { class Triple; namespace vfs { class FileSystem; } namespace cl { class ExpansionContext; } } // namespace llvm namespace clang { namespace driver { InputInfoList; class Command; class Compilation; class JobAction; class ToolChain; /// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options. enum LTOKind { … }; /// Whether headers used to construct C++20 module units should be looked /// up by the path supplied on the command line, or in the user or system /// search paths. enum ModuleHeaderMode { … }; /// Driver - Encapsulate logic for constructing compilation processes /// from a set of gcc-driver-like command line arguments. class Driver { … }; /// \return True if the last defined optimization level is -Ofast. /// And False otherwise. bool isOptimizationLevelFast(const llvm::opt::ArgList &Args); /// \return True if the argument combination will end up generating remarks. bool willEmitRemarks(const llvm::opt::ArgList &Args); /// Returns the driver mode option's value, i.e. `X` in `--driver-mode=X`. If \p /// Args doesn't mention one explicitly, tries to deduce from `ProgName`. /// Returns empty on failure. /// Common values are "gcc", "g++", "cpp", "cl" and "flang". Returned value need /// not be one of these. llvm::StringRef getDriverMode(StringRef ProgName, ArrayRef<const char *> Args); /// Checks whether the value produced by getDriverMode is for CL mode. bool IsClangCL(StringRef DriverMode); /// Expand response files from a clang driver or cc1 invocation. /// /// \param Args The arguments that will be expanded. /// \param ClangCLMode Whether clang is in CL mode. /// \param Alloc Allocator for new arguments. /// \param FS Filesystem to use when expanding files. llvm::Error expandResponseFiles(SmallVectorImpl<const char *> &Args, bool ClangCLMode, llvm::BumpPtrAllocator &Alloc, llvm::vfs::FileSystem *FS = nullptr); /// Apply a space separated list of edits to the input argument lists. /// See applyOneOverrideOption. void applyOverrideOptions(SmallVectorImpl<const char *> &Args, const char *OverrideOpts, llvm::StringSet<> &SavedStrings, raw_ostream *OS = nullptr); } // end namespace driver } // end namespace clang #endif