1 //===--- Types.h - Input & Temporary Driver Types ---------------*- 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_DRIVER_TYPES_H 10 #define LLVM_CLANG_DRIVER_TYPES_H 11 12 #include "clang/Driver/Phases.h" 13 #include "llvm/ADT/SmallVector.h" 14 #include "llvm/Option/ArgList.h" 15 16 namespace llvm { 17 class StringRef; 18 } 19 namespace clang { 20 namespace driver { 21 class Driver; 22 namespace types { 23 enum ID { 24 TY_INVALID, 25 #define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, ...) TY_##ID, 26 #include "clang/Driver/Types.def" 27 #undef TYPE 28 TY_LAST 29 }; 30 31 /// getTypeName - Return the name of the type for \p Id. 32 const char *getTypeName(ID Id); 33 34 /// getPreprocessedType - Get the ID of the type for this input when 35 /// it has been preprocessed, or INVALID if this input is not 36 /// preprocessed. 37 ID getPreprocessedType(ID Id); 38 39 /// getPrecompiledType - Get the ID of the type for this input when 40 /// it has been precompiled, or INVALID if this input is not 41 /// precompiled. 42 ID getPrecompiledType(ID Id); 43 44 /// getTypeTempSuffix - Return the suffix to use when creating a 45 /// temp file of this type, or null if unspecified. 46 const char *getTypeTempSuffix(ID Id, bool CLMode = false); 47 48 /// onlyPrecompileType - Should this type only be precompiled. 49 bool onlyPrecompileType(ID Id); 50 51 /// canTypeBeUserSpecified - Can this type be specified on the 52 /// command line (by the type name); this is used when forwarding 53 /// commands to gcc. 54 bool canTypeBeUserSpecified(ID Id); 55 56 /// appendSuffixForType - When generating outputs of this type, 57 /// should the suffix be appended (instead of replacing the existing 58 /// suffix). 59 bool appendSuffixForType(ID Id); 60 61 /// canLipoType - Is this type acceptable as the output of a 62 /// universal build (currently, just the Nothing, Image, and Object 63 /// types). 64 bool canLipoType(ID Id); 65 66 /// isAcceptedByClang - Can clang handle this input type. 67 bool isAcceptedByClang(ID Id); 68 69 /// isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers). 70 bool isCXX(ID Id); 71 72 /// Is this LLVM IR. 73 bool isLLVMIR(ID Id); 74 75 /// isCuda - Is this a CUDA input. 76 bool isCuda(ID Id); 77 78 /// isHIP - Is this a HIP input. 79 bool isHIP(ID Id); 80 81 /// isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers). 82 bool isObjC(ID Id); 83 84 /// isOpenCL - Is this an "OpenCL" input. 85 bool isOpenCL(ID Id); 86 87 /// isFortran - Is this a Fortran input. 88 bool isFortran(ID Id); 89 90 /// isSrcFile - Is this a source file, i.e. something that still has to be 91 /// preprocessed. The logic behind this is the same that decides if the first 92 /// compilation phase is a preprocessing one. 93 bool isSrcFile(ID Id); 94 95 /// lookupTypeForExtension - Lookup the type to use for the file 96 /// extension \p Ext. 97 ID lookupTypeForExtension(llvm::StringRef Ext); 98 99 /// lookupTypeForTypSpecifier - Lookup the type to use for a user 100 /// specified type name. 101 ID lookupTypeForTypeSpecifier(const char *Name); 102 103 /// getCompilationPhases - Get the list of compilation phases ('Phases') to be 104 /// done for type 'Id' up until including LastPhase. 105 llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> 106 getCompilationPhases(ID Id, phases::ID LastPhase = phases::LastPhase); 107 llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> 108 getCompilationPhases(const clang::driver::Driver &Driver, 109 llvm::opt::DerivedArgList &DAL, ID Id); 110 111 /// lookupCXXTypeForCType - Lookup CXX input type that corresponds to given 112 /// C type (used for clang++ emulation of g++ behaviour) 113 ID lookupCXXTypeForCType(ID Id); 114 115 /// Lookup header file input type that corresponds to given 116 /// source file type (used for clang-cl emulation of \Yc). 117 ID lookupHeaderTypeForSourceType(ID Id); 118 119 } // end namespace types 120 } // end namespace driver 121 } // end namespace clang 122 123 #endif 124