| 1 | //===--- ClangCLArgs.h - clang-cl arguments ---------------------*- 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_LIB_DRIVER_CLANGCLARGS_H |
| 10 | #define LLVM_CLANG_LIB_DRIVER_CLANGCLARGS_H |
| 11 | |
| 12 | #include "llvm/Support/Compiler.h" |
| 13 | |
| 14 | namespace llvm { |
| 15 | class Triple; |
| 16 | namespace opt { |
| 17 | class Arg; |
| 18 | class ArgList; |
| 19 | class DerivedArgList; |
| 20 | } // namespace opt |
| 21 | } // namespace llvm |
| 22 | |
| 23 | namespace clang::driver { |
| 24 | |
| 25 | /// Translate clang-cl options before and after offload argument filtering. |
| 26 | class LLVM_LIBRARY_VISIBILITY ClangCLArgs { |
| 27 | const char *ExpandChar = nullptr; |
| 28 | bool SupportsForcingFramePointer; |
| 29 | |
| 30 | public: |
| 31 | /// The argument values must outlive this translator. |
| 32 | ClangCLArgs(const llvm::opt::ArgList &Args, const llvm::Triple &HostTriple); |
| 33 | |
| 34 | /// Append the canonical translation of A to DAL. Return false without |
| 35 | /// modifying DAL if A is not handled. If supplied, Owner owns synthesized |
| 36 | /// arguments instead of DAL and must outlive its consumers. |
| 37 | bool translateArg(llvm::opt::Arg *A, llvm::opt::DerivedArgList &DAL, |
| 38 | const llvm::opt::DerivedArgList *Owner = nullptr) const; |
| 39 | |
| 40 | /// Translate a filtered list that may contain new clang-cl options, replacing |
| 41 | /// earlier /O expansions. The caller owns the returned list; Owner owns its |
| 42 | /// synthesized arguments and must outlive its consumers. |
| 43 | static llvm::opt::DerivedArgList * |
| 44 | translateArgs(const llvm::opt::DerivedArgList &Args, |
| 45 | const llvm::Triple &HostTriple, |
| 46 | const llvm::opt::DerivedArgList &Owner); |
| 47 | |
| 48 | /// Normalize MSVC's '#' macro separator, also used by Clang targeting MSVC |
| 49 | /// and by arguments parsed after host/device filtering. Any replacement |
| 50 | /// string has the lifetime of Args; otherwise return Value unchanged. |
| 51 | static const char *translateMacroDefinition(const char *Value, |
| 52 | const llvm::opt::ArgList &Args); |
| 53 | }; |
| 54 | |
| 55 | } // namespace clang::driver |
| 56 | |
| 57 | #endif // LLVM_CLANG_LIB_DRIVER_CLANGCLARGS_H |
| 58 | |