27 #include "llvm/ADT/APFloat.h" 28 using namespace clang;
31 while (!MacroBody.empty() &&
isWhitespace(MacroBody.back()))
32 MacroBody = MacroBody.drop_back();
33 return !MacroBody.empty() && MacroBody.back() ==
'\\';
41 std::pair<StringRef, StringRef> MacroPair = Macro.split(
'=');
42 StringRef MacroName = MacroPair.first;
43 StringRef MacroBody = MacroPair.second;
44 if (MacroName.size() != Macro.size()) {
46 StringRef::size_type
End = MacroBody.find_first_of(
"\n\r");
47 if (End != StringRef::npos)
48 Diags.
Report(diag::warn_fe_macro_contains_embedded_newline)
50 MacroBody = MacroBody.substr(0, End);
55 Builder.
defineMacro(MacroName, Twine(MacroBody) +
"\\\n");
69 Builder.
append(Twine(
"#include \"") + File +
"\"");
73 Builder.
append(Twine(
"#__include_macros \"") + File +
"\"");
82 StringRef ImplicitIncludePCH) {
83 std::string OriginalFile =
86 if (OriginalFile.empty())
95 static T
PickFP(
const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal,
96 T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal,
98 if (Sem == (
const llvm::fltSemantics*)&llvm::APFloat::IEEEhalf())
100 if (Sem == (
const llvm::fltSemantics*)&llvm::APFloat::IEEEsingle())
101 return IEEESingleVal;
102 if (Sem == (
const llvm::fltSemantics*)&llvm::APFloat::IEEEdouble())
103 return IEEEDoubleVal;
104 if (Sem == (
const llvm::fltSemantics*)&llvm::APFloat::x87DoubleExtended())
105 return X87DoubleExtendedVal;
106 if (Sem == (
const llvm::fltSemantics*)&llvm::APFloat::PPCDoubleDouble())
107 return PPCDoubleDoubleVal;
108 assert(Sem == (
const llvm::fltSemantics*)&llvm::APFloat::IEEEquad());
113 const llvm::fltSemantics *Sem, StringRef Ext) {
114 const char *DenormMin, *Epsilon, *Max, *Min;
115 DenormMin =
PickFP(Sem,
"5.9604644775390625e-8",
"1.40129846e-45",
116 "4.9406564584124654e-324",
"3.64519953188247460253e-4951",
117 "4.94065645841246544176568792868221e-324",
118 "6.47517511943802511092443895822764655e-4966");
119 int Digits =
PickFP(Sem, 3, 6, 15, 18, 31, 33);
120 int DecimalDigits =
PickFP(Sem, 5, 9, 17, 21, 33, 36);
121 Epsilon =
PickFP(Sem,
"9.765625e-4",
"1.19209290e-7",
122 "2.2204460492503131e-16",
"1.08420217248550443401e-19",
123 "4.94065645841246544176568792868221e-324",
124 "1.92592994438723585305597794258492732e-34");
125 int MantissaDigits =
PickFP(Sem, 11, 24, 53, 64, 106, 113);
126 int Min10Exp =
PickFP(Sem, -13, -37, -307, -4931, -291, -4931);
127 int Max10Exp =
PickFP(Sem, 4, 38, 308, 4932, 308, 4932);
128 int MinExp =
PickFP(Sem, -14, -125, -1021, -16381, -968, -16381);
129 int MaxExp =
PickFP(Sem, 15, 128, 1024, 16384, 1024, 16384);
130 Min =
PickFP(Sem,
"6.103515625e-5",
"1.17549435e-38",
"2.2250738585072014e-308",
131 "3.36210314311209350626e-4932",
132 "2.00416836000897277799610805135016e-292",
133 "3.36210314311209350626267781732175260e-4932");
134 Max =
PickFP(Sem,
"6.5504e+4",
"3.40282347e+38",
"1.7976931348623157e+308",
135 "1.18973149535723176502e+4932",
136 "1.79769313486231580793728971405301e+308",
137 "1.18973149535723176508575932662800702e+4932");
144 Builder.
defineMacro(DefPrefix +
"DENORM_MIN__", Twine(DenormMin)+Ext);
146 Builder.
defineMacro(DefPrefix +
"DIG__", Twine(Digits));
147 Builder.
defineMacro(DefPrefix +
"DECIMAL_DIG__", Twine(DecimalDigits));
148 Builder.
defineMacro(DefPrefix +
"EPSILON__", Twine(Epsilon)+Ext);
150 Builder.
defineMacro(DefPrefix +
"HAS_QUIET_NAN__");
151 Builder.
defineMacro(DefPrefix +
"MANT_DIG__", Twine(MantissaDigits));
153 Builder.
defineMacro(DefPrefix +
"MAX_10_EXP__", Twine(Max10Exp));
154 Builder.
defineMacro(DefPrefix +
"MAX_EXP__", Twine(MaxExp));
155 Builder.
defineMacro(DefPrefix +
"MAX__", Twine(Max)+Ext);
157 Builder.
defineMacro(DefPrefix +
"MIN_10_EXP__",
"("+Twine(Min10Exp)+
")");
158 Builder.
defineMacro(DefPrefix +
"MIN_EXP__",
"("+Twine(MinExp)+
")");
159 Builder.
defineMacro(DefPrefix +
"MIN__", Twine(Min)+Ext);
167 StringRef ValSuffix,
bool isSigned,
169 llvm::APInt MaxVal = isSigned ? llvm::APInt::getSignedMaxValue(TypeWidth)
170 : llvm::APInt::getMaxValue(TypeWidth);
171 Builder.
defineMacro(MacroName, MaxVal.toString(10, isSigned) + ValSuffix);
186 for (
const char *Fmt = IsSigned ?
"di" :
"ouxX"; *Fmt; ++Fmt) {
187 Builder.
defineMacro(Prefix +
"_FMT" + Twine(*Fmt) +
"__",
188 Twine(
"\"") + FmtModifier + Twine(*Fmt) +
"\"");
219 const char *Prefix = IsSigned ?
"__INT" :
"__UINT";
221 DefineType(Prefix + Twine(TypeWidth) +
"_TYPE__", Ty, Builder);
222 DefineFmt(Prefix + Twine(TypeWidth), Ty, TI, Builder);
225 Builder.
defineMacro(Prefix + Twine(TypeWidth) +
"_C_SUFFIX__", ConstSuffix);
239 const char *Prefix = IsSigned ?
"__INT" :
"__UINT";
240 DefineTypeSize(Prefix + Twine(TypeWidth) +
"_MAX__", Ty, TI, Builder);
250 const char *Prefix = IsSigned ?
"__INT_LEAST" :
"__UINT_LEAST";
251 DefineType(Prefix + Twine(TypeWidth) +
"_TYPE__", Ty, Builder);
252 DefineTypeSize(Prefix + Twine(TypeWidth) +
"_MAX__", Ty, TI, Builder);
253 DefineFmt(Prefix + Twine(TypeWidth), Ty, TI, Builder);
264 const char *Prefix = IsSigned ?
"__INT_FAST" :
"__UINT_FAST";
265 DefineType(Prefix + Twine(TypeWidth) +
"_TYPE__", Ty, Builder);
266 DefineTypeSize(Prefix + Twine(TypeWidth) +
"_MAX__", Ty, TI, Builder);
268 DefineFmt(Prefix + Twine(TypeWidth), Ty, TI, Builder);
275 unsigned InlineWidth) {
278 if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
279 TypeWidth <= InlineWidth)
290 Builder.
defineMacro(
"_GLIBCXX_PREDEFINED_OBJC_ARC_IS_SCALAR");
299 llvm::raw_string_ostream Out(Result);
301 Out <<
"namespace std {\n" 303 <<
"struct __true_type;\n" 304 <<
"struct __false_type;\n" 307 Out <<
"template<typename _Tp> struct __is_scalar;\n" 310 if (LangOpts.ObjCAutoRefCount) {
311 Out <<
"template<typename _Tp>\n" 312 <<
"struct __is_scalar<__attribute__((objc_ownership(strong))) _Tp> {\n" 313 <<
" enum { __value = 0 };\n" 314 <<
" typedef __false_type __type;\n" 319 if (LangOpts.ObjCWeak) {
320 Out <<
"template<typename _Tp>\n" 321 <<
"struct __is_scalar<__attribute__((objc_ownership(weak))) _Tp> {\n" 322 <<
" enum { __value = 0 };\n" 323 <<
" typedef __false_type __type;\n" 328 if (LangOpts.ObjCAutoRefCount) {
329 Out <<
"template<typename _Tp>\n" 330 <<
"struct __is_scalar<__attribute__((objc_ownership(autoreleasing)))" 332 <<
" enum { __value = 0 };\n" 333 <<
" typedef __false_type __type;\n" 347 if (!LangOpts.MSVCCompat && !LangOpts.TraditionalCPP)
349 if (LangOpts.Freestanding)
354 if (!LangOpts.CPlusPlus) {
356 Builder.
defineMacro(
"__STDC_VERSION__",
"201710L");
357 else if (LangOpts.C11)
358 Builder.
defineMacro(
"__STDC_VERSION__",
"201112L");
359 else if (LangOpts.C99)
360 Builder.
defineMacro(
"__STDC_VERSION__",
"199901L");
361 else if (!LangOpts.GNUMode && LangOpts.Digraphs)
362 Builder.
defineMacro(
"__STDC_VERSION__",
"199409L");
365 if (LangOpts.CPlusPlus2a)
370 else if (LangOpts.CPlusPlus17)
375 else if (LangOpts.CPlusPlus14)
380 else if (LangOpts.CPlusPlus11)
393 Builder.
defineMacro(
"__STDCPP_DEFAULT_NEW_ALIGNMENT__",
410 if (LangOpts.OpenCL) {
411 if (LangOpts.CPlusPlus) {
412 if (LangOpts.OpenCLCPlusPlusVersion == 100)
413 Builder.
defineMacro(
"__OPENCL_CPP_VERSION__",
"100");
415 llvm_unreachable(
"Unsupported OpenCL C++ version");
416 Builder.
defineMacro(
"__CL_CPP_VERSION_1_0__",
"100");
425 switch (LangOpts.OpenCLVersion) {
427 Builder.
defineMacro(
"__OPENCL_C_VERSION__",
"100");
430 Builder.
defineMacro(
"__OPENCL_C_VERSION__",
"110");
433 Builder.
defineMacro(
"__OPENCL_C_VERSION__",
"120");
436 Builder.
defineMacro(
"__OPENCL_C_VERSION__",
"200");
439 llvm_unreachable(
"Unsupported OpenCL version");
449 if (LangOpts.FastRelaxedMath)
454 if (LangOpts.AsmPreprocessor)
456 if (LangOpts.CUDA && !LangOpts.HIP)
461 if (LangOpts.CUDAIsDevice)
473 if (LangOpts.CXXExceptions)
474 Builder.
defineMacro(
"__cpp_exceptions",
"199711L");
477 if (LangOpts.CPlusPlus11) {
478 Builder.
defineMacro(
"__cpp_unicode_characters",
"200704L");
479 Builder.
defineMacro(
"__cpp_raw_strings",
"200710L");
480 Builder.
defineMacro(
"__cpp_unicode_literals",
"200710L");
481 Builder.
defineMacro(
"__cpp_user_defined_literals",
"200809L");
484 LangOpts.CPlusPlus17 ?
"201603L" :
485 LangOpts.CPlusPlus14 ?
"201304L" :
"200704");
487 LangOpts.CPlusPlus17 ?
"201603L" :
"200907");
489 LangOpts.CPlusPlus17 ?
"201411L" :
"200410");
491 Builder.
defineMacro(
"__cpp_attributes",
"200809L");
492 Builder.
defineMacro(
"__cpp_rvalue_references",
"200610L");
493 Builder.
defineMacro(
"__cpp_variadic_templates",
"200704L");
494 Builder.
defineMacro(
"__cpp_initializer_lists",
"200806L");
495 Builder.
defineMacro(
"__cpp_delegating_constructors",
"200604L");
497 Builder.
defineMacro(
"__cpp_inheriting_constructors",
"201511L");
498 Builder.
defineMacro(
"__cpp_ref_qualifiers",
"200710L");
499 Builder.
defineMacro(
"__cpp_alias_templates",
"200704L");
501 if (LangOpts.ThreadsafeStatics)
502 Builder.
defineMacro(
"__cpp_threadsafe_static_init",
"200806L");
505 if (LangOpts.CPlusPlus14) {
506 Builder.
defineMacro(
"__cpp_binary_literals",
"201304L");
507 Builder.
defineMacro(
"__cpp_digit_separators",
"201309L");
508 Builder.
defineMacro(
"__cpp_init_captures",
"201304L");
509 Builder.
defineMacro(
"__cpp_generic_lambdas",
"201304L");
510 Builder.
defineMacro(
"__cpp_decltype_auto",
"201304L");
511 Builder.
defineMacro(
"__cpp_return_type_deduction",
"201304L");
512 Builder.
defineMacro(
"__cpp_aggregate_nsdmi",
"201304L");
513 Builder.
defineMacro(
"__cpp_variable_templates",
"201304L");
515 if (LangOpts.SizedDeallocation)
516 Builder.
defineMacro(
"__cpp_sized_deallocation",
"201309L");
519 if (LangOpts.CPlusPlus17) {
521 Builder.
defineMacro(
"__cpp_inline_variables",
"201606L");
522 Builder.
defineMacro(
"__cpp_noexcept_function_type",
"201510L");
523 Builder.
defineMacro(
"__cpp_capture_star_this",
"201603L");
524 Builder.
defineMacro(
"__cpp_if_constexpr",
"201606L");
525 Builder.
defineMacro(
"__cpp_deduction_guides",
"201703L");
526 Builder.
defineMacro(
"__cpp_template_auto",
"201606L");
527 Builder.
defineMacro(
"__cpp_namespace_attributes",
"201411L");
528 Builder.
defineMacro(
"__cpp_enumerator_attributes",
"201411L");
529 Builder.
defineMacro(
"__cpp_nested_namespace_definitions",
"201411L");
530 Builder.
defineMacro(
"__cpp_variadic_using",
"201611L");
531 Builder.
defineMacro(
"__cpp_aggregate_bases",
"201603L");
532 Builder.
defineMacro(
"__cpp_structured_bindings",
"201606L");
533 Builder.
defineMacro(
"__cpp_nontype_template_args",
"201411L");
534 Builder.
defineMacro(
"__cpp_fold_expressions",
"201603L");
535 Builder.
defineMacro(
"__cpp_guaranteed_copy_elision",
"201606L");
536 Builder.
defineMacro(
"__cpp_nontype_template_parameter_auto",
"201606L");
538 if (LangOpts.AlignedAllocation && !LangOpts.AlignedAllocationUnavailable)
539 Builder.
defineMacro(
"__cpp_aligned_new",
"201606L");
540 if (LangOpts.RelaxedTemplateTemplateArgs)
541 Builder.
defineMacro(
"__cpp_template_template_args",
"201611L");
546 Builder.
defineMacro(
"__cpp_impl_destroying_delete",
"201806L");
549 if (LangOpts.ConceptsTS)
550 Builder.
defineMacro(
"__cpp_experimental_concepts",
"1L");
551 if (LangOpts.CoroutinesTS)
552 Builder.
defineMacro(
"__cpp_coroutines",
"201703L");
563 #define TOSTR(X) TOSTR2(X) 566 Builder.
defineMacro(
"__clang_patchlevel__",
TOSTR(CLANG_VERSION_PATCHLEVEL));
570 "\"" CLANG_VERSION_STRING
" " 572 if (!LangOpts.MSVCCompat) {
596 "Invalid OpenCL memory scope enum definition");
597 Builder.
defineMacro(
"__OPENCL_MEMORY_SCOPE_WORK_ITEM",
"0");
598 Builder.
defineMacro(
"__OPENCL_MEMORY_SCOPE_WORK_GROUP",
"1");
599 Builder.
defineMacro(
"__OPENCL_MEMORY_SCOPE_DEVICE",
"2");
600 Builder.
defineMacro(
"__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES",
"3");
601 Builder.
defineMacro(
"__OPENCL_MEMORY_SCOPE_SUB_GROUP",
"4");
604 Builder.
defineMacro(
"__PRAGMA_REDEFINE_EXTNAME",
"1");
609 Builder.
defineMacro(
"__VERSION__",
"\"4.2.1 Compatible " +
615 if (!LangOpts.GNUMode && !LangOpts.MSVCCompat)
618 if (!LangOpts.MSVCCompat && LangOpts.CPlusPlus11)
625 if (LangOpts.ObjCExceptions)
637 std::string versionString =
"1";
641 if (version >= VersionTuple(2, 0))
642 Builder.
defineMacro(
"__OBJC_GNUSTEP_RUNTIME_ABI__",
"20");
644 Builder.
defineMacro(
"__OBJC_GNUSTEP_RUNTIME_ABI__",
645 "1" + Twine(
std::min(8U, version.getMinor().getValueOr(0))));
652 if (tuple.getMinor().hasValue())
653 minor = tuple.getMinor().getValue();
655 unsigned subminor = 0;
656 if (tuple.getSubminor().hasValue())
657 subminor = tuple.getSubminor().getValue();
660 Twine(tuple.getMajor() * 10000 + minor * 100 +
664 Builder.
defineMacro(
"IBOutlet",
"__attribute__((iboutlet))");
665 Builder.
defineMacro(
"IBOutletCollection(ClassName)",
666 "__attribute__((iboutletcollection(ClassName)))");
667 Builder.
defineMacro(
"IBAction",
"void)__attribute__((ibaction)");
677 if (LangOpts.CPlusPlus)
682 if (!LangOpts.NoConstantCFStrings)
688 if (LangOpts.PascalStrings)
691 if (LangOpts.Blocks) {
692 Builder.
defineMacro(
"__block",
"__attribute__((__blocks__(byref)))");
696 if (!LangOpts.MSVCCompat && LangOpts.Exceptions)
698 if (!LangOpts.MSVCCompat && LangOpts.RTTI)
701 if (LangOpts.SjLjExceptions)
703 else if (LangOpts.SEHExceptions)
705 else if (LangOpts.DWARFExceptions &&
709 if (LangOpts.Deprecated)
712 if (!LangOpts.MSVCCompat && LangOpts.CPlusPlus) {
715 Builder.
defineMacro(
"__private_extern__",
"extern");
718 if (LangOpts.MicrosoftExt) {
719 if (LangOpts.WChar) {
726 if (LangOpts.Optimize)
728 if (LangOpts.OptimizeSize)
731 if (LangOpts.FastMath)
741 Builder.
defineMacro(
"__ORDER_LITTLE_ENDIAN__",
"1234");
742 Builder.
defineMacro(
"__ORDER_BIG_ENDIAN__",
"4321");
743 Builder.
defineMacro(
"__ORDER_PDP_ENDIAN__",
"3412");
745 Builder.
defineMacro(
"__BYTE_ORDER__",
"__ORDER_BIG_ENDIAN__");
748 Builder.
defineMacro(
"__BYTE_ORDER__",
"__ORDER_LITTLE_ENDIAN__");
765 assert(TI.
getCharWidth() == 8 &&
"Only support 8-bit char so far");
847 if (!LangOpts.CharIsSigned)
917 char UserLabelPrefix[2] = {TI.
getDataLayout().getGlobalPrefix(), 0};
918 Builder.
defineMacro(
"__USER_LABEL_PREFIX__", UserLabelPrefix);
920 if (LangOpts.FastMath || LangOpts.FiniteMathOnly)
925 if (!LangOpts.MSVCCompat) {
926 if (LangOpts.GNUInline || LangOpts.CPlusPlus)
933 Builder.
defineMacro(
"__GCC_ATOMIC_TEST_AND_SET_TRUEVAL",
"1");
936 auto addLockFreeMacros = [&](
const llvm::Twine &Prefix) {
939 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \ 940 Builder.defineMacro(Prefix + #TYPE "_LOCK_FREE", \ 941 getLockFreeValue(TI.get##Type##Width(), \ 942 TI.get##Type##Align(), \ 959 #undef DEFINE_LOCK_FREE_MACRO 961 addLockFreeMacros(
"__CLANG_ATOMIC_");
962 if (!LangOpts.MSVCCompat)
963 addLockFreeMacros(
"__GCC_ATOMIC_");
965 if (LangOpts.NoInlineDefine)
968 if (
unsigned PICLevel = LangOpts.PICLevel) {
980 Builder.
defineMacro(
"__DECIMAL_DIG__",
"__LDBL_DECIMAL_DIG__");
993 if (LangOpts.FastRelaxedMath)
998 Builder.
defineMacro(
"__weak",
"__attribute__((objc_gc(weak)))");
999 Builder.
defineMacro(
"__strong",
"__attribute__((objc_gc(strong)))");
1002 }
else if (LangOpts.ObjC) {
1003 Builder.
defineMacro(
"__weak",
"__attribute__((objc_ownership(weak)))");
1004 Builder.
defineMacro(
"__strong",
"__attribute__((objc_ownership(strong)))");
1006 "__attribute__((objc_ownership(autoreleasing)))");
1008 "__attribute__((objc_ownership(none)))");
1015 Builder.
defineMacro(
"__null_unspecified",
"_Null_unspecified");
1022 Builder.
defineMacro(
"__APPLE_EMBEDDED_SIMULATOR__",
"1");
1030 if (!LangOpts.OpenMPSimd) {
1031 switch (LangOpts.OpenMP) {
1048 if (LangOpts.CUDAIsDevice && !LangOpts.HIP) {
1056 if (LangOpts.CUDADeviceApproxTranscendentals || LangOpts.FastMath) {
1057 Builder.
defineMacro(
"__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
1061 if (LangOpts.OpenCL) {
1062 #define OPENCLEXT(Ext) \ 1063 if (TI.getSupportedOpenCLOpts().isSupported(#Ext, LangOpts)) \ 1064 Builder.defineMacro(#Ext); 1065 #include "clang/Basic/OpenCLExtensions.def" 1068 if (Arch == llvm::Triple::spir || Arch == llvm::Triple::spir64)
1072 if (TI.
hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) {
1076 Builder.
defineMacro(
"__GLIBCXX_TYPE_INT_N_0",
"__int128");
1077 Builder.
defineMacro(
"__GLIBCXX_BITSIZE_INT_N_0",
"128");
1092 std::string PredefineBuffer;
1093 PredefineBuffer.reserve(4080);
1094 llvm::raw_string_ostream Predefines(PredefineBuffer);
1101 Builder.
append(
"# 1 \"<built-in>\" 3");
1115 if (LangOpts.ObjC && LangOpts.CPlusPlus &&
1116 (LangOpts.ObjCAutoRefCount || LangOpts.ObjCWeak)) {
1138 Builder.
append(
"# 1 \"<command line>\" 1");
1141 for (
unsigned i = 0, e = InitOpts.
Macros.size(); i != e; ++i) {
1142 if (InitOpts.
Macros[i].second)
1151 Builder.
append(
"# 1 \"<built-in>\" 2");
1155 for (
unsigned i = 0, e = InitOpts.
MacroIncludes.size(); i != e; ++i)
1164 for (
unsigned i = 0, e = InitOpts.
Includes.size(); i != e; ++i) {
1165 const std::string &Path = InitOpts.
Includes[i];
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
IntType getInt64Type() const
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of 'float'.
std::vector< std::pair< std::string, bool > > Macros
Defines the clang::MacroBuilder utility class.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
Defines the clang::FileManager interface and associated types.
unsigned getSuitableAlign() const
Return the alignment that is suitable for storing any object with a fundamental alignment requirement...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Defines the SourceManager interface.
virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return the smallest integer type with at least the specified width.
FileManager & getFileManager() const
static T PickFP(const llvm::fltSemantics *Sem, T IEEEHalfVal, T IEEESingleVal, T IEEEDoubleVal, T X87DoubleExtendedVal, T PPCDoubleDoubleVal, T IEEEQuadVal)
PickFP - This is used to pick a value based on the FP semantics of the specified FP model...
static void DefineFmt(const Twine &Prefix, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
std::vector< std::string > Includes
static void AddImplicitIncludeMacros(MacroBuilder &Builder, StringRef File)
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
unsigned getCharWidth() const
const llvm::fltSemantics & getHalfFormat() const
static void DefineTypeSizeof(StringRef MacroName, unsigned BitWidth, const TargetInfo &TI, MacroBuilder &Builder)
void setPredefines(const char *P)
Set the predefines for this Preprocessor.
static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, const PCHContainerReader &PCHContainerRdr, StringRef ImplicitIncludePCH)
Add an implicit #include using the original file used to generate a PCH file.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
const char * getTypeConstantSuffix(IntType T) const
Return the constant suffix for the specified integer type enum.
static void AddObjCXXARCLibstdcxxDefines(const LangOptions &LangOpts, MacroBuilder &Builder)
Add definitions required for a smooth interaction between Objective-C++ automated reference counting ...
IntType getChar32Type() const
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with '::operator new(size_t)' is g...
const TargetInfo & getTargetInfo() const
void undefineMacro(const Twine &Name)
Append a #undef line for Name.
IntType getSizeType() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const LangOptions & getLangOpts() const
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t', '\f', '\v', '\n', '\r'.
Concrete class used by the front-end to report problems and issues.
static void InitializePredefinedMacros(const TargetInfo &TI, const LangOptions &LangOpts, const FrontendOptions &FEOpts, MacroBuilder &Builder)
void append(const Twine &Str)
Directly append Str and a newline to the underlying buffer.
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
static void DefineType(const Twine &MacroName, TargetInfo::IntType Ty, MacroBuilder &Builder)
const TargetInfo * getAuxTargetInfo() const
static void DefineFloatMacros(MacroBuilder &Builder, StringRef Prefix, const llvm::fltSemantics *Sem, StringRef Ext)
static void AddImplicitInclude(MacroBuilder &Builder, StringRef File)
AddImplicitInclude - Add an implicit #include of the specified file to the predefines buffer...
static void DefineExactWidthIntTypeSize(TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
bool isLittleEndian() const
const llvm::fltSemantics & getDoubleFormat() const
static void DefineExactWidthIntType(TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
const llvm::fltSemantics & getLongDoubleFormat() const
Exposes information about the current target.
static void DefineLeastWidthIntType(unsigned TypeWidth, bool IsSigned, const TargetInfo &TI, MacroBuilder &Builder)
IntType getUIntPtrType() const
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
static void DefineTypeSize(const Twine &MacroName, unsigned TypeWidth, StringRef ValSuffix, bool isSigned, MacroBuilder &Builder)
DefineTypeSize - Emit a macro to the predefines buffer that declares a macro named MacroName with the...
Defines version macros and version-related utility functions for Clang.
Defines the clang::Preprocessor interface.
IntType getChar16Type() const
clang::ObjCRuntime ObjCRuntime
'gnustep' is the modern non-fragile GNUstep runtime.
IntType getUIntMaxType() const
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
static const char * getTypeName(IntType T)
Return the user string for the specified integer type enum.
static const char * getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign, unsigned InlineWidth)
Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with the specified properties...
static bool MacroBodyEndsInBackslash(StringRef MacroBody)
IntType getPtrDiffType(unsigned AddrSpace) const
IntType getSigAtomicType() const
static void DefineFastIntType(unsigned TypeWidth, bool IsSigned, const TargetInfo &TI, MacroBuilder &Builder)
static void InitializeStandardPredefinedMacros(const TargetInfo &TI, const LangOptions &LangOpts, const FrontendOptions &FEOpts, MacroBuilder &Builder)
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
static void DefineBuiltinMacro(MacroBuilder &Builder, StringRef Macro, DiagnosticsEngine &Diags)
static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, MacroBuilder &Builder)
Initialize the predefined C++ language feature test macros defined in ISO/IEC JTC1/SC22/WG21 (C++) SD...
IntType getWIntType() const
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
'objfw' is the Objective-C runtime included in ObjFW
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
IntType getIntMaxType() const
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
const llvm::DataLayout & getDataLayout() const
virtual unsigned getFloatEvalMethod() const
Return the value for the C99 FLT_EVAL_METHOD macro.
IntType getUInt64Type() const
const VersionTuple & getVersion() const
unsigned getLongDoubleWidth() const
getLongDoubleWidth/Align/Format - Return the size/align/format of 'long double'.
std::vector< std::string > MacroIncludes
IntType
===-— Target Data Type Query Methods ----------------------------—===//
Dataflow Directional Tag Classes.
static const char * getTypeFormatModifier(IntType T)
Return the printf format modifier for the specified integer type enum.
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
frontend::ActionKind ProgramAction
The frontend action to perform.
FrontendOptions - Options for controlling the behavior of the frontend.
#define DEFINE_LOCK_FREE_MACRO(TYPE, Type)
bool useSignedCharForObjCBool() const
Check if the Objective-C built-in boolean type should be signed char.
virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const =0
===-— Other target property query methods --------------------——===//
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
std::string getClangFullCPPVersion()
Retrieves a string representing the complete clang version suitable for use in the CPP VERSION macro...
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
Provides definitions for the atomic synchronization scopes.
DiagnosticsEngine & getDiagnostics() const
const llvm::fltSemantics & getFloatFormat() const
void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts, const PCHContainerReader &PCHContainerRdr, const FrontendOptions &FEOpts)
InitializePreprocessor - Initialize the preprocessor getting it and the environment ready to process ...
IntType getWCharType() const
Run one or more source code analyses.
uint64_t getPointerAlign(unsigned AddrSpace) const
std::pair< unsigned, bool > PrecompiledPreambleBytes
If non-zero, the implicit PCH include is actually a precompiled preamble that covers this number of b...
Defines the clang::TargetInfo interface.
IntType getIntPtrType() const
__DEVICE__ int min(int __a, int __b)
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
void setSkipMainFilePreamble(unsigned Bytes, bool StartOfLine)
Instruct the preprocessor to skip part of the main source file.
static void DefineTypeWidth(StringRef MacroName, TargetInfo::IntType Ty, const TargetInfo &TI, MacroBuilder &Builder)
Engages in a tight little dance with the lexer to efficiently preprocess tokens.