diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 00000000..d8f34c3e --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "module": "nodenext", + "target": "esnext", + "lib": ["esnext"], + "types": ["node"], + + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + + "strict": true, + // "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedSideEffectImports": true, + "moduleDetection": "force", + "skipLibCheck": true + } +} diff --git a/scripts/update-toolchain.ts b/scripts/update-toolchain.ts index ca77a117..6e6cf09f 100644 --- a/scripts/update-toolchain.ts +++ b/scripts/update-toolchain.ts @@ -26,23 +26,307 @@ const configs: Config[] = [ ["x86_64", "windows", "c23"], ]; -function configMatches({ - config, +async function main() { + const { predefinedMacrosByConfig } = await getConfigPredefinedMacros(); + + const getMacros = (config: Config): Set => { + const configKey = config.join("-"); + const macros = predefinedMacrosByConfig.get(configKey); + if (!macros) { + throw new Error(`No predefined macros found for config: ${configKey}`); + } + return macros; + }; + + const { + commonMacros: linuxCommonMacros, + machineMacros: linuxMachineMacros, + cMacros: linuxCMacros, + cxxMacros: linuxCxxMacros, + } = genToolchain({ + os: "linux", + machineVariants: ["aarch64", "x86_64"], + configs, + getMacros, + }); + + const { + commonMacros: macosxCommonMacros, + machineMacros: macosxMachineMacros, + cMacros: macosxCMacros, + cxxMacros: macosxCxxMacros, + } = genToolchain({ + os: "macosx", + machineVariants: ["aarch64", "x86_64"], + configs, + getMacros, + }); + + const { + commonMacros: windowsCommonMacros, + machineMacros: windowsMachineMacros, + cMacros: windowsCMacros, + cxxMacros: windowsCxxMacros, + } = genToolchain({ + os: "windows", + machineVariants: ["aarch64", "x86_64"], + configs, + getMacros, + }); + + const { + commonMacros: wasiCommonMacros, + machineMacros: wasiMachineMacros, + cMacros: wasiCMacros, + cxxMacros: wasiCxxMacros, + } = genToolchain({ + os: "wasi", + machineVariants: ["wasm32"], + configs, + getMacros, + }); + + const commonMacrosByOS: Map> = new Map([ + ["linux", linuxCommonMacros], + ["macosx", macosxCommonMacros], + ["windows", windowsCommonMacros], + ["wasi", wasiCommonMacros], + ]); + + const machineMacrosByOS: Map>> = new Map([ + ["linux", linuxMachineMacros], + ["macosx", macosxMachineMacros], + ["windows", windowsMachineMacros], + ["wasi", wasiMachineMacros], + ]); + + const cCompilerMacrosByOS: Map> = new Map([ + ["linux", linuxCMacros], + ["macosx", macosxCMacros], + ["windows", windowsCMacros], + ["wasi", wasiCMacros], + ]); + + const cxxCompilerMacrosByOS: Map> = new Map([ + ["linux", linuxCxxMacros], + ["macosx", macosxCxxMacros], + ["windows", windowsCxxMacros], + ["wasi", wasiCxxMacros], + ]); + + const commonMacros = intersection(commonMacrosByOS.values()); + const cCompilerCommonMacros = intersection(cCompilerMacrosByOS.values()); + const cxxCompilerCommonMacros = intersection(cxxCompilerMacrosByOS.values()); + + oses.forEach((os) => { + commonMacrosByOS.set( + os, + commonMacrosByOS.get(os)!.difference(commonMacros) + ); + + cCompilerMacrosByOS.set( + os, + cCompilerMacrosByOS.get(os)!.difference(cCompilerCommonMacros) + ); + + cxxCompilerMacrosByOS.set( + os, + cxxCompilerMacrosByOS.get(os)!.difference(cxxCompilerCommonMacros) + ); + }); + + const out: string[] = []; + const emit = (text: string = "") => out.push(text); + + emitMacros({ + common: true, + macros: commonMacros, + emit, + }); + + emitMacros({ + common: true, + macros: cCompilerCommonMacros, + compiler: "c23", + emit, + }); + + emitMacros({ + common: true, + macros: cxxCompilerCommonMacros, + compiler: "c++26", + emit, + }); + + commonMacrosByOS.forEach((macros, os) => { + emitMacros({ + common: true, + macros, + os, + emit, + }); + }); + + machineMacrosByOS.forEach((macrosByMachine, os) => { + macrosByMachine.forEach((macros, machine) => { + emitMacros({ + common: false, + macros, + os, + machine, + emit, + }); + }); + }); + + cCompilerMacrosByOS.forEach((macros, os) => { + emitMacros({ + common: false, + macros, + os, + compiler: "c23", + emit, + }); + }); + + cxxCompilerMacrosByOS.forEach((macros, os) => { + emitMacros({ + common: false, + macros, + os, + compiler: "c++26", + emit, + }); + }); + + console.log(out.join("\n")); +} + +function intersection(sets: Iterable>): Set { + let result: Set | undefined; + for (const set of sets) { + if (!result) { + result = new Set(set); + } else { + result = result.intersection(set); + } + } + return result ?? new Set(); +} + +function genToolchain({ + os, + configs, + machineVariants, + getMacros, +}: { + os: OS; + configs: Config[]; + machineVariants: readonly Machine[]; + getMacros: (config: Config) => Set; +}) { + const os_configs = configs.filter((config) => config[1] === os); + + let commonMacros: Set | undefined; + os_configs.forEach((config) => { + const macros = getMacros(config); + if (!commonMacros) { + commonMacros = new Set(macros); + } else { + commonMacros = commonMacros.intersection(macros); + } + }); + + if (!commonMacros) { + throw new Error(`No common macros found for OS: ${os}`); + } + + let [first_machine, second_machine] = machineVariants; + + if (!first_machine) { + throw new Error(`No first machine found for OS: ${os}`); + } + + if (!second_machine) { + second_machine = first_machine; + } + + let machine1_c = getMacros([first_machine, os, "c23"]); + let machine1_cxx = getMacros([first_machine, os, "c++26"]); + let machine2_c = getMacros([second_machine, os, "c23"]); + let machine2_cxx = getMacros([second_machine, os, "c++26"]); + + machine1_c = machine1_c.difference(commonMacros); + machine1_cxx = machine1_cxx.difference(commonMacros); + machine2_c = machine2_c.difference(commonMacros); + machine2_cxx = machine2_cxx.difference(commonMacros); + + const machine_diff = machine1_c.symmetricDifference(machine2_c); + const lang_diff = machine1_c.symmetricDifference(machine1_cxx); + const first_machine_macros = machine1_c.intersection(machine_diff); + const second_machine_macros = machine2_c.intersection(machine_diff); + const cMacros = machine1_c.intersection(lang_diff); + const cxxMacros = machine1_cxx.intersection(lang_diff); + + const machineMacros = new Map>(); + machineMacros.set(first_machine, first_machine_macros); + if (first_machine !== second_machine) { + machineMacros.set(second_machine, second_machine_macros); + } + + return { + commonMacros, + machineMacros, + cMacros, + cxxMacros, + }; +} + +function emitMacros({ + macros, + common, machine, os, compiler, + emit, }: { - config: Config; + macros: Set; + common?: boolean; machine?: Machine; os?: OS; compiler?: Compiler; -}): boolean { - const [configMachine, configOS, configCompiler] = config; - return ( - (machine ? configMachine === machine : true) && - (os ? configOS === os : true) && - (compiler ? configCompiler === compiler : true) - ); + emit: (text?: string) => void; +}) { + let func = "void Toolchain::add"; + if (common) func += "Common"; + if (os != undefined) func += `${osToString(os)}`; + if (machine != undefined) func += `${machineToString(machine)}`; + if (compiler != undefined) func += `${compilerToString(compiler)}`; + func += "Macros() {"; + emit(); + emit(func); + macros.forEach((macro) => { + let { name, value } = parseMacro(macro); + if (name === "__VERSION__") { + value = '\\"cxx-frontend\\"'; + } + emit(` defineMacro("${name}", "${value}");`); + }); + emit("}"); +} + +async function getConfigPredefinedMacros() { + const predefinedMacrosByConfig = new Map>(); + + for (const config of configs) { + const configKey = config.join("-"); + const predefinedMacros = await getPredefinedMacros({ config }); + predefinedMacrosByConfig.set(configKey, predefinedMacros); + } + + return { + predefinedMacrosByConfig, + }; } async function getPredefinedMacros({ @@ -57,13 +341,14 @@ async function getPredefinedMacros({ return new Promise((resolve, reject) => { execFile( - "clang", + "/opt/homebrew/opt/llvm/bin/clang", [ `--target=${target}`, "-E", "-dM", `-x${lang}`, `-std=${compiler}`, + "-fno-blocks", "/dev/null", ], (err, stdout) => { @@ -83,38 +368,67 @@ async function getPredefinedMacros({ }); } -async function main() { - const predefinedMacrosByConfig: Record> = {}; - for (const config of configs) { - const predefinedMacros = await getPredefinedMacros({ config }); - predefinedMacrosByConfig[config.join("-")] = predefinedMacros; - console.log( - `Config: ${config.join("-")} has ${predefinedMacros.size} predefined macros.` - ); +function osToString(os: OS): string { + switch (os) { + case "linux": + return "Linux"; + case "macosx": + return "MacOS"; + case "windows": + return "Windows"; + case "wasi": + return "WASI"; + default: + throw new Error(`Unknown OS: ${os}`); } +} - machines.forEach((machine) => { - const machineConfigs = configs.filter((config) => - configMatches({ config, machine }) - ); - const predefinedMacrosForMachine = machineConfigs.map((config) => { - return predefinedMacrosByConfig[config.join("-")]; - }); - return intersection(...predefinedMacrosForMachine); - }); +function compilerToString(compiler: Compiler): string { + switch (compiler) { + case "c23": + return "C23"; + case "c++26": + return "Cxx26"; + default: + throw new Error(`Unknown compiler: ${compiler}`); + } } -function intersection(...sets: Set[]): Set { - if (sets.length === 0) return new Set(); - return sets.reduce((acc, set) => { - const intersection = new Set(); - for (const item of set) { - if (acc.has(item)) { - intersection.add(item); - } - } - return intersection; - }, sets[0]); +function machineToString(machine: Machine): string { + switch (machine) { + case "aarch64": + return "AArch64"; + case "x86_64": + return "X86_64"; + case "wasm32": + return "Wasm32"; + default: + throw new Error(`Unknown machine: ${machine}`); + } +} + +function parseMacro(macro: string) { + const rx = /^#define\s+([^\s]+)\s*(.*)$/; + const match = macro.match(rx); + + if (!match) { + throw new Error(`Invalid macro format: ${macro}`); + } + + function escaped(value: string) { + return value.replaceAll("\\", "\\\\").replaceAll('"', '\\"'); + } + + const [, name, value] = match; + + if (!name) { + throw new Error(`Macro name is empty in: ${macro}`); + } + + return { + name, + value: escaped(value!), + }; } await main(); diff --git a/src/parser/cxx/gcc_linux_toolchain.cc b/src/parser/cxx/gcc_linux_toolchain.cc index c5140270..c7cd9b6a 100644 --- a/src/parser/cxx/gcc_linux_toolchain.cc +++ b/src/parser/cxx/gcc_linux_toolchain.cc @@ -76,576 +76,24 @@ void GCCLinuxToolchain::addPredefinedMacros() { defineMacro("_Nullable", ""); defineMacro("_Pragma(x)", ""); - // std=c++26 - defineMacro("__cplusplus", "202400L"); - addCommonMacros(); + addCommonLinuxMacros(); + + if (language() == LanguageKind::kCXX) { + addCommonCxx26Macros(); + addLinuxCxx26Macros(); + } else { + addCommonC23Macros(); + addLinuxC23Macros(); + } if (arch_ == "aarch64") { - addArm64Macros(); + addLinuxAArch64Macros(); } else if (arch_ == "x86_64") { - addAmd64Macros(); + addLinuxX86_64Macros(); + } else { + cxx_runtime_error(std::format("Unsupported architecture: {}", arch_)); } } -void GCCLinuxToolchain::addCommonMacros() { - // clang-format off - defineMacro("_GNU_SOURCE", "1"); - defineMacro("_LP64", "1"); - defineMacro("_STDC_PREDEF_H", "1"); - defineMacro("__ATOMIC_ACQUIRE", "2"); - defineMacro("__ATOMIC_ACQ_REL", "4"); - defineMacro("__ATOMIC_CONSUME", "1"); - defineMacro("__ATOMIC_RELAXED", "0"); - defineMacro("__ATOMIC_RELEASE", "3"); - defineMacro("__ATOMIC_SEQ_CST", "5"); - defineMacro("__BFLT16_DECIMAL_DIG__", "4"); - defineMacro("__BFLT16_DENORM_MIN__", "9.18354961579912115600575419704879436e-41BF16"); - defineMacro("__BFLT16_DIG__", "2"); - defineMacro("__BFLT16_EPSILON__", "7.81250000000000000000000000000000000e-3BF16"); - defineMacro("__BFLT16_HAS_DENORM__", "1"); - defineMacro("__BFLT16_HAS_INFINITY__", "1"); - defineMacro("__BFLT16_HAS_QUIET_NAN__", "1"); - defineMacro("__BFLT16_IS_IEC_60559__", "0"); - defineMacro("__BFLT16_MANT_DIG__", "8"); - defineMacro("__BFLT16_MAX_10_EXP__", "38"); - defineMacro("__BFLT16_MAX_EXP__", "128"); - defineMacro("__BFLT16_MAX__", "3.38953138925153547590470800371487867e+38BF16"); - defineMacro("__BFLT16_MIN_10_EXP__", "(-37)"); - defineMacro("__BFLT16_MIN_EXP__", "(-125)"); - defineMacro("__BFLT16_MIN__", "1.17549435082228750796873653722224568e-38BF16"); - defineMacro("__BFLT16_NORM_MAX__", "3.38953138925153547590470800371487867e+38BF16"); - defineMacro("__BIGGEST_ALIGNMENT__", "16"); - defineMacro("__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__"); - defineMacro("__CHAR16_TYPE__", "short unsigned int"); - defineMacro("__CHAR32_TYPE__", "unsigned int"); - defineMacro("__CHAR8_TYPE__", "unsigned char"); - defineMacro("__CHAR_BIT__", "8"); - defineMacro("__DBL_DECIMAL_DIG__", "17"); - defineMacro("__DBL_DENORM_MIN__", "double(4.94065645841246544176568792868221372e-324L)"); - defineMacro("__DBL_DIG__", "15"); - defineMacro("__DBL_EPSILON__", "double(2.22044604925031308084726333618164062e-16L)"); - defineMacro("__DBL_HAS_DENORM__", "1"); - defineMacro("__DBL_HAS_INFINITY__", "1"); - defineMacro("__DBL_HAS_QUIET_NAN__", "1"); - defineMacro("__DBL_IS_IEC_60559__", "1"); - defineMacro("__DBL_MANT_DIG__", "53"); - defineMacro("__DBL_MAX_10_EXP__", "308"); - defineMacro("__DBL_MAX_EXP__", "1024"); - defineMacro("__DBL_MAX__", "double(1.79769313486231570814527423731704357e+308L)"); - defineMacro("__DBL_MIN_10_EXP__", "(-307)"); - defineMacro("__DBL_MIN_EXP__", "(-1021)"); - defineMacro("__DBL_MIN__", "double(2.22507385850720138309023271733240406e-308L)"); - defineMacro("__DBL_NORM_MAX__", "double(1.79769313486231570814527423731704357e+308L)"); - defineMacro("__DEC128_EPSILON__", "1E-33DL"); - defineMacro("__DEC128_MANT_DIG__", "34"); - defineMacro("__DEC128_MAX_EXP__", "6145"); - defineMacro("__DEC128_MAX__", "9.999999999999999999999999999999999E6144DL"); - defineMacro("__DEC128_MIN_EXP__", "(-6142)"); - defineMacro("__DEC128_MIN__", "1E-6143DL"); - defineMacro("__DEC128_SUBNORMAL_MIN__", "0.000000000000000000000000000000001E-6143DL"); - defineMacro("__DEC32_EPSILON__", "1E-6DF"); - defineMacro("__DEC32_MANT_DIG__", "7"); - defineMacro("__DEC32_MAX_EXP__", "97"); - defineMacro("__DEC32_MAX__", "9.999999E96DF"); - defineMacro("__DEC32_MIN_EXP__", "(-94)"); - defineMacro("__DEC32_MIN__", "1E-95DF"); - defineMacro("__DEC32_SUBNORMAL_MIN__", "0.000001E-95DF"); - defineMacro("__DEC64_EPSILON__", "1E-15DD"); - defineMacro("__DEC64_MANT_DIG__", "16"); - defineMacro("__DEC64_MAX_EXP__", "385"); - defineMacro("__DEC64_MAX__", "9.999999999999999E384DD"); - defineMacro("__DEC64_MIN_EXP__", "(-382)"); - defineMacro("__DEC64_MIN__", "1E-383DD"); - defineMacro("__DEC64_SUBNORMAL_MIN__", "0.000000000000001E-383DD"); - defineMacro("__DECIMAL_BID_FORMAT__", "1"); - defineMacro("__DEC_EVAL_METHOD__", "2"); - defineMacro("__DEPRECATED", "1"); - defineMacro("__ELF__", "1"); - defineMacro("__EXCEPTIONS", "1"); - defineMacro("__FINITE_MATH_ONLY__", "0"); - defineMacro("__FLOAT_WORD_ORDER__", "__ORDER_LITTLE_ENDIAN__"); - defineMacro("__FLT128_DECIMAL_DIG__", "36"); - defineMacro("__FLT128_DENORM_MIN__", "6.47517511943802511092443895822764655e-4966F128"); - defineMacro("__FLT128_DIG__", "33"); - defineMacro("__FLT128_EPSILON__", "1.92592994438723585305597794258492732e-34F128"); - defineMacro("__FLT128_HAS_DENORM__", "1"); - defineMacro("__FLT128_HAS_INFINITY__", "1"); - defineMacro("__FLT128_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT128_IS_IEC_60559__", "1"); - defineMacro("__FLT128_MANT_DIG__", "113"); - defineMacro("__FLT128_MAX_10_EXP__", "4932"); - defineMacro("__FLT128_MAX_EXP__", "16384"); - defineMacro("__FLT128_MAX__", "1.18973149535723176508575932662800702e+4932F128"); - defineMacro("__FLT128_MIN_10_EXP__", "(-4931)"); - defineMacro("__FLT128_MIN_EXP__", "(-16381)"); - defineMacro("__FLT128_MIN__", "3.36210314311209350626267781732175260e-4932F128"); - defineMacro("__FLT128_NORM_MAX__", "1.18973149535723176508575932662800702e+4932F128"); - defineMacro("__FLT16_DECIMAL_DIG__", "5"); - defineMacro("__FLT16_DENORM_MIN__", "5.96046447753906250000000000000000000e-8F16"); - defineMacro("__FLT16_DIG__", "3"); - defineMacro("__FLT16_EPSILON__", "9.76562500000000000000000000000000000e-4F16"); - defineMacro("__FLT16_HAS_DENORM__", "1"); - defineMacro("__FLT16_HAS_INFINITY__", "1"); - defineMacro("__FLT16_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT16_IS_IEC_60559__", "1"); - defineMacro("__FLT16_MANT_DIG__", "11"); - defineMacro("__FLT16_MAX_10_EXP__", "4"); - defineMacro("__FLT16_MAX_EXP__", "16"); - defineMacro("__FLT16_MAX__", "6.55040000000000000000000000000000000e+4F16"); - defineMacro("__FLT16_MIN_10_EXP__", "(-4)"); - defineMacro("__FLT16_MIN_EXP__", "(-13)"); - defineMacro("__FLT16_MIN__", "6.10351562500000000000000000000000000e-5F16"); - defineMacro("__FLT16_NORM_MAX__", "6.55040000000000000000000000000000000e+4F16"); - defineMacro("__FLT32X_DECIMAL_DIG__", "17"); - defineMacro("__FLT32X_DENORM_MIN__", "4.94065645841246544176568792868221372e-324F32x"); - defineMacro("__FLT32X_DIG__", "15"); - defineMacro("__FLT32X_EPSILON__", "2.22044604925031308084726333618164062e-16F32x"); - defineMacro("__FLT32X_HAS_DENORM__", "1"); - defineMacro("__FLT32X_HAS_INFINITY__", "1"); - defineMacro("__FLT32X_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT32X_IS_IEC_60559__", "1"); - defineMacro("__FLT32X_MANT_DIG__", "53"); - defineMacro("__FLT32X_MAX_10_EXP__", "308"); - defineMacro("__FLT32X_MAX_EXP__", "1024"); - defineMacro("__FLT32X_MAX__", "1.79769313486231570814527423731704357e+308F32x"); - defineMacro("__FLT32X_MIN_10_EXP__", "(-307)"); - defineMacro("__FLT32X_MIN_EXP__", "(-1021)"); - defineMacro("__FLT32X_MIN__", "2.22507385850720138309023271733240406e-308F32x"); - defineMacro("__FLT32X_NORM_MAX__", "1.79769313486231570814527423731704357e+308F32x"); - defineMacro("__FLT32_DECIMAL_DIG__", "9"); - defineMacro("__FLT32_DENORM_MIN__", "1.40129846432481707092372958328991613e-45F32"); - defineMacro("__FLT32_DIG__", "6"); - defineMacro("__FLT32_EPSILON__", "1.19209289550781250000000000000000000e-7F32"); - defineMacro("__FLT32_HAS_DENORM__", "1"); - defineMacro("__FLT32_HAS_INFINITY__", "1"); - defineMacro("__FLT32_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT32_IS_IEC_60559__", "1"); - defineMacro("__FLT32_MANT_DIG__", "24"); - defineMacro("__FLT32_MAX_10_EXP__", "38"); - defineMacro("__FLT32_MAX_EXP__", "128"); - defineMacro("__FLT32_MAX__", "3.40282346638528859811704183484516925e+38F32"); - defineMacro("__FLT32_MIN_10_EXP__", "(-37)"); - defineMacro("__FLT32_MIN_EXP__", "(-125)"); - defineMacro("__FLT32_MIN__", "1.17549435082228750796873653722224568e-38F32"); - defineMacro("__FLT32_NORM_MAX__", "3.40282346638528859811704183484516925e+38F32"); - defineMacro("__FLT64X_HAS_DENORM__", "1"); - defineMacro("__FLT64X_HAS_INFINITY__", "1"); - defineMacro("__FLT64X_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT64X_IS_IEC_60559__", "1"); - defineMacro("__FLT64X_MAX_10_EXP__", "4932"); - defineMacro("__FLT64X_MAX_EXP__", "16384"); - defineMacro("__FLT64X_MIN_10_EXP__", "(-4931)"); - defineMacro("__FLT64X_MIN_EXP__", "(-16381)"); - defineMacro("__FLT64X_MIN__", "3.36210314311209350626267781732175260e-4932F64x"); - defineMacro("__FLT64_DECIMAL_DIG__", "17"); - defineMacro("__FLT64_DENORM_MIN__", "4.94065645841246544176568792868221372e-324F64"); - defineMacro("__FLT64_DIG__", "15"); - defineMacro("__FLT64_EPSILON__", "2.22044604925031308084726333618164062e-16F64"); - defineMacro("__FLT64_HAS_DENORM__", "1"); - defineMacro("__FLT64_HAS_INFINITY__", "1"); - defineMacro("__FLT64_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT64_IS_IEC_60559__", "1"); - defineMacro("__FLT64_MANT_DIG__", "53"); - defineMacro("__FLT64_MAX_10_EXP__", "308"); - defineMacro("__FLT64_MAX_EXP__", "1024"); - defineMacro("__FLT64_MAX__", "1.79769313486231570814527423731704357e+308F64"); - defineMacro("__FLT64_MIN_10_EXP__", "(-307)"); - defineMacro("__FLT64_MIN_EXP__", "(-1021)"); - defineMacro("__FLT64_MIN__", "2.22507385850720138309023271733240406e-308F64"); - defineMacro("__FLT64_NORM_MAX__", "1.79769313486231570814527423731704357e+308F64"); - defineMacro("__FLT_DECIMAL_DIG__", "9"); - defineMacro("__FLT_DENORM_MIN__", "1.40129846432481707092372958328991613e-45F"); - defineMacro("__FLT_DIG__", "6"); - defineMacro("__FLT_EPSILON__", "1.19209289550781250000000000000000000e-7F"); - defineMacro("__FLT_EVAL_METHOD_TS_18661_3__", "0"); - defineMacro("__FLT_EVAL_METHOD__", "0"); - defineMacro("__FLT_HAS_DENORM__", "1"); - defineMacro("__FLT_HAS_INFINITY__", "1"); - defineMacro("__FLT_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT_IS_IEC_60559__", "1"); - defineMacro("__FLT_MANT_DIG__", "24"); - defineMacro("__FLT_MAX_10_EXP__", "38"); - defineMacro("__FLT_MAX_EXP__", "128"); - defineMacro("__FLT_MAX__", "3.40282346638528859811704183484516925e+38F"); - defineMacro("__FLT_MIN_10_EXP__", "(-37)"); - defineMacro("__FLT_MIN_EXP__", "(-125)"); - defineMacro("__FLT_MIN__", "1.17549435082228750796873653722224568e-38F"); - defineMacro("__FLT_NORM_MAX__", "3.40282346638528859811704183484516925e+38F"); - defineMacro("__FLT_RADIX__", "2"); - defineMacro("__GCC_ASM_FLAG_OUTPUTS__", "1"); - defineMacro("__GCC_ATOMIC_BOOL_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR16_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR32_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR8_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_INT_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_LLONG_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_LONG_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_SHORT_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1"); - defineMacro("__GCC_ATOMIC_WCHAR_T_LOCK_FREE", "2"); - defineMacro("__GCC_CONSTRUCTIVE_SIZE", "64"); - defineMacro("__GCC_HAVE_DWARF2_CFI_ASM", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8", "1"); - defineMacro("__GCC_IEC_559", "2"); - defineMacro("__GCC_IEC_559_COMPLEX", "2"); - defineMacro("__GNUC_EXECUTION_CHARSET_NAME", "\"UTF-8\""); - defineMacro("__GNUC_MINOR__", "2"); - defineMacro("__GNUC_PATCHLEVEL__", "0"); - defineMacro("__GNUC_STDC_INLINE__", "1"); - defineMacro("__GNUC_WIDE_EXECUTION_CHARSET_NAME", "\"UTF-32LE\""); - defineMacro("__GNUC__", "14"); - defineMacro("__GNUG__", "14"); - defineMacro("__GXX_ABI_VERSION", "1019"); - defineMacro("__GXX_EXPERIMENTAL_CXX0X__", "1"); - defineMacro("__GXX_RTTI", "1"); - defineMacro("__GXX_WEAK__", "1"); - defineMacro("__HAVE_SPECULATION_SAFE_VALUE", "1"); - defineMacro("__INT16_C(c)", "c"); - defineMacro("__INT16_MAX__", "0x7fff"); - defineMacro("__INT16_TYPE__", "short int"); - defineMacro("__INT32_C(c)", "c"); - defineMacro("__INT32_MAX__", "0x7fffffff"); - defineMacro("__INT32_TYPE__", "int"); - defineMacro("__INT64_C(c)", "c ## L"); - defineMacro("__INT64_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INT64_TYPE__", "long int"); - defineMacro("__INT8_C(c)", "c"); - defineMacro("__INT8_MAX__", "0x7f"); - defineMacro("__INT8_TYPE__", "signed char"); - defineMacro("__INTMAX_C(c)", "c ## L"); - defineMacro("__INTMAX_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INTMAX_TYPE__", "long int"); - defineMacro("__INTMAX_WIDTH__", "64"); - defineMacro("__INTPTR_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INTPTR_TYPE__", "long int"); - defineMacro("__INTPTR_WIDTH__", "64"); - defineMacro("__INT_FAST16_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INT_FAST16_TYPE__", "long int"); - defineMacro("__INT_FAST16_WIDTH__", "64"); - defineMacro("__INT_FAST32_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INT_FAST32_TYPE__", "long int"); - defineMacro("__INT_FAST32_WIDTH__", "64"); - defineMacro("__INT_FAST64_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INT_FAST64_TYPE__", "long int"); - defineMacro("__INT_FAST64_WIDTH__", "64"); - defineMacro("__INT_FAST8_MAX__", "0x7f"); - defineMacro("__INT_FAST8_TYPE__", "signed char"); - defineMacro("__INT_FAST8_WIDTH__", "8"); - defineMacro("__INT_LEAST16_MAX__", "0x7fff"); - defineMacro("__INT_LEAST16_TYPE__", "short int"); - defineMacro("__INT_LEAST16_WIDTH__", "16"); - defineMacro("__INT_LEAST32_MAX__", "0x7fffffff"); - defineMacro("__INT_LEAST32_TYPE__", "int"); - defineMacro("__INT_LEAST32_WIDTH__", "32"); - defineMacro("__INT_LEAST64_MAX__", "0x7fffffffffffffffL"); - defineMacro("__INT_LEAST64_TYPE__", "long int"); - defineMacro("__INT_LEAST64_WIDTH__", "64"); - defineMacro("__INT_LEAST8_MAX__", "0x7f"); - defineMacro("__INT_LEAST8_TYPE__", "signed char"); - defineMacro("__INT_LEAST8_WIDTH__", "8"); - defineMacro("__INT_MAX__", "0x7fffffff"); - defineMacro("__INT_WIDTH__", "32"); - defineMacro("__LDBL_HAS_DENORM__", "1"); - defineMacro("__LDBL_HAS_INFINITY__", "1"); - defineMacro("__LDBL_HAS_QUIET_NAN__", "1"); - defineMacro("__LDBL_IS_IEC_60559__", "1"); - defineMacro("__LDBL_MAX_10_EXP__", "4932"); - defineMacro("__LDBL_MAX_EXP__", "16384"); - defineMacro("__LDBL_MIN_10_EXP__", "(-4931)"); - defineMacro("__LDBL_MIN_EXP__", "(-16381)"); - defineMacro("__LDBL_MIN__", "3.36210314311209350626267781732175260e-4932L"); - defineMacro("__LONG_LONG_MAX__", "0x7fffffffffffffffLL"); - defineMacro("__LONG_LONG_WIDTH__", "64"); - defineMacro("__LONG_MAX__", "0x7fffffffffffffffL"); - defineMacro("__LONG_WIDTH__", "64"); - defineMacro("__LP64__", "1"); - defineMacro("__NO_INLINE__", "1"); - defineMacro("__ORDER_BIG_ENDIAN__", "4321"); - defineMacro("__ORDER_LITTLE_ENDIAN__", "1234"); - defineMacro("__ORDER_PDP_ENDIAN__", "3412"); - defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1"); - defineMacro("__PTRDIFF_MAX__", "0x7fffffffffffffffL"); - defineMacro("__PTRDIFF_TYPE__", "long int"); - defineMacro("__PTRDIFF_WIDTH__", "64"); - defineMacro("__REGISTER_PREFIX__", ""); - defineMacro("__SCHAR_MAX__", "0x7f"); - defineMacro("__SCHAR_WIDTH__", "8"); - defineMacro("__SHRT_MAX__", "0x7fff"); - defineMacro("__SHRT_WIDTH__", "16"); - defineMacro("__SIG_ATOMIC_MAX__", "0x7fffffff"); - defineMacro("__SIG_ATOMIC_MIN__", "(-__SIG_ATOMIC_MAX__ - 1)"); - defineMacro("__SIG_ATOMIC_TYPE__", "int"); - defineMacro("__SIG_ATOMIC_WIDTH__", "32"); - defineMacro("__SIZEOF_DOUBLE__", "8"); - defineMacro("__SIZEOF_FLOAT__", "4"); - defineMacro("__SIZEOF_INT128__", "16"); - defineMacro("__SIZEOF_INT__", "4"); - defineMacro("__SIZEOF_LONG_DOUBLE__", "16"); - defineMacro("__SIZEOF_LONG_LONG__", "8"); - defineMacro("__SIZEOF_LONG__", "8"); - defineMacro("__SIZEOF_POINTER__", "8"); - defineMacro("__SIZEOF_PTRDIFF_T__", "8"); - defineMacro("__SIZEOF_SHORT__", "2"); - defineMacro("__SIZEOF_SIZE_T__", "8"); - defineMacro("__SIZEOF_WCHAR_T__", "4"); - defineMacro("__SIZEOF_WINT_T__", "4"); - defineMacro("__SIZE_MAX__", "0xffffffffffffffffUL"); - defineMacro("__SIZE_TYPE__", "long unsigned int"); - defineMacro("__SIZE_WIDTH__", "64"); - defineMacro("__STDCPP_BFLOAT16_T__", "1"); - defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16"); - defineMacro("__STDCPP_FLOAT128_T__", "1"); - defineMacro("__STDCPP_FLOAT16_T__", "1"); - defineMacro("__STDCPP_FLOAT32_T__", "1"); - defineMacro("__STDCPP_FLOAT64_T__", "1"); - defineMacro("__STDCPP_THREADS__", "1"); - defineMacro("__STDC_HOSTED__", "1"); - defineMacro("__STDC_IEC_559_COMPLEX__", "1"); - defineMacro("__STDC_IEC_559__", "1"); - defineMacro("__STDC_IEC_60559_BFP__", "201404L"); - defineMacro("__STDC_IEC_60559_COMPLEX__", "201404L"); - defineMacro("__STDC_ISO_10646__", "201706L"); - defineMacro("__STDC_UTF_16__", "1"); - defineMacro("__STDC_UTF_32__", "1"); - defineMacro("__STDC__", "1"); - defineMacro("__STRICT_ANSI__", "1"); - defineMacro("__UINT16_C(c)", "c"); - defineMacro("__UINT16_MAX__", "0xffff"); - defineMacro("__UINT16_TYPE__", "short unsigned int"); - defineMacro("__UINT32_C(c)", "c ## U"); - defineMacro("__UINT32_MAX__", "0xffffffffU"); - defineMacro("__UINT32_TYPE__", "unsigned int"); - defineMacro("__UINT64_C(c)", "c ## UL"); - defineMacro("__UINT64_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINT64_TYPE__", "long unsigned int"); - defineMacro("__UINT8_C(c)", "c"); - defineMacro("__UINT8_MAX__", "0xff"); - defineMacro("__UINT8_TYPE__", "unsigned char"); - defineMacro("__UINTMAX_C(c)", "c ## UL"); - defineMacro("__UINTMAX_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINTMAX_TYPE__", "long unsigned int"); - defineMacro("__UINTPTR_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINTPTR_TYPE__", "long unsigned int"); - defineMacro("__UINT_FAST16_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINT_FAST16_TYPE__", "long unsigned int"); - defineMacro("__UINT_FAST32_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINT_FAST32_TYPE__", "long unsigned int"); - defineMacro("__UINT_FAST64_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINT_FAST64_TYPE__", "long unsigned int"); - defineMacro("__UINT_FAST8_MAX__", "0xff"); - defineMacro("__UINT_FAST8_TYPE__", "unsigned char"); - defineMacro("__UINT_LEAST16_MAX__", "0xffff"); - defineMacro("__UINT_LEAST16_TYPE__", "short unsigned int"); - defineMacro("__UINT_LEAST32_MAX__", "0xffffffffU"); - defineMacro("__UINT_LEAST32_TYPE__", "unsigned int"); - defineMacro("__UINT_LEAST64_MAX__", "0xffffffffffffffffUL"); - defineMacro("__UINT_LEAST64_TYPE__", "long unsigned int"); - defineMacro("__UINT_LEAST8_MAX__", "0xff"); - defineMacro("__UINT_LEAST8_TYPE__", "unsigned char"); - defineMacro("__USER_LABEL_PREFIX__", ""); - defineMacro("__VERSION__", "\"14.2.0\""); - defineMacro("__WCHAR_WIDTH__", "32"); - defineMacro("__WINT_MAX__", "0xffffffffU"); - defineMacro("__WINT_MIN__", "0U"); - defineMacro("__WINT_TYPE__", "unsigned int"); - defineMacro("__WINT_WIDTH__", "32"); - defineMacro("__cplusplus", "202400L"); - defineMacro("__cpp_aggregate_bases", "201603L"); - defineMacro("__cpp_aggregate_nsdmi", "201304L"); - defineMacro("__cpp_aggregate_paren_init", "201902L"); - defineMacro("__cpp_alias_templates", "200704L"); - defineMacro("__cpp_aligned_new", "201606L"); - defineMacro("__cpp_attributes", "200809L"); - defineMacro("__cpp_auto_cast", "202110L"); - defineMacro("__cpp_binary_literals", "201304L"); - defineMacro("__cpp_capture_star_this", "201603L"); - defineMacro("__cpp_char8_t", "202207L"); - defineMacro("__cpp_concepts", "202002L"); - defineMacro("__cpp_conditional_explicit", "201806L"); - defineMacro("__cpp_consteval", "202211L"); - defineMacro("__cpp_constexpr", "202306L"); - defineMacro("__cpp_constexpr_dynamic_alloc", "201907L"); - defineMacro("__cpp_constexpr_in_decltype", "201711L"); - defineMacro("__cpp_constinit", "201907L"); - defineMacro("__cpp_decltype", "200707L"); - defineMacro("__cpp_decltype_auto", "201304L"); - defineMacro("__cpp_deduction_guides", "201907L"); - defineMacro("__cpp_delegating_constructors", "200604L"); - defineMacro("__cpp_designated_initializers", "201707L"); - defineMacro("__cpp_digit_separators", "201309L"); - defineMacro("__cpp_enumerator_attributes", "201411L"); - defineMacro("__cpp_exceptions", "199711L"); - defineMacro("__cpp_explicit_this_parameter", "202110L"); - defineMacro("__cpp_fold_expressions", "201603L"); - defineMacro("__cpp_generic_lambdas", "201707L"); - defineMacro("__cpp_guaranteed_copy_elision", "201606L"); - defineMacro("__cpp_hex_float", "201603L"); - defineMacro("__cpp_if_consteval", "202106L"); - defineMacro("__cpp_if_constexpr", "201606L"); - defineMacro("__cpp_impl_coroutine", "201902L"); - defineMacro("__cpp_impl_destroying_delete", "201806L"); - defineMacro("__cpp_impl_three_way_comparison", "201907L"); - defineMacro("__cpp_implicit_move", "202207L"); - defineMacro("__cpp_inheriting_constructors", "201511L"); - defineMacro("__cpp_init_captures", "201803L"); - defineMacro("__cpp_initializer_lists", "200806L"); - defineMacro("__cpp_inline_variables", "201606L"); - defineMacro("__cpp_lambdas", "200907L"); - defineMacro("__cpp_multidimensional_subscript", "202211L"); - defineMacro("__cpp_named_character_escapes", "202207L"); - defineMacro("__cpp_namespace_attributes", "201411L"); - defineMacro("__cpp_nested_namespace_definitions", "201411L"); - defineMacro("__cpp_noexcept_function_type", "201510L"); - defineMacro("__cpp_nontype_template_args", "201911L"); - defineMacro("__cpp_nontype_template_parameter_auto", "201606L"); - defineMacro("__cpp_nontype_template_parameter_class", "201806L"); - defineMacro("__cpp_nsdmi", "200809L"); - defineMacro("__cpp_placeholder_variables", "202306L"); - defineMacro("__cpp_range_based_for", "201603L"); - defineMacro("__cpp_raw_strings", "200710L"); - defineMacro("__cpp_ref_qualifiers", "200710L"); - defineMacro("__cpp_return_type_deduction", "201304L"); - defineMacro("__cpp_rtti", "199711L"); - defineMacro("__cpp_runtime_arrays", "198712L"); - defineMacro("__cpp_rvalue_reference", "200610L"); - defineMacro("__cpp_rvalue_references", "200610L"); - defineMacro("__cpp_size_t_suffix", "202011L"); - defineMacro("__cpp_sized_deallocation", "201309L"); - defineMacro("__cpp_static_assert", "202306L"); - defineMacro("__cpp_static_call_operator", "202207L"); - defineMacro("__cpp_structured_bindings", "201606L"); - defineMacro("__cpp_template_auto", "201606L"); - defineMacro("__cpp_template_template_args", "201611L"); - defineMacro("__cpp_threadsafe_static_init", "200806L"); - defineMacro("__cpp_unicode_characters", "201411L"); - defineMacro("__cpp_unicode_literals", "200710L"); - defineMacro("__cpp_user_defined_literals", "200809L"); - defineMacro("__cpp_using_enum", "201907L"); - defineMacro("__cpp_variable_templates", "201304L"); - defineMacro("__cpp_variadic_templates", "200704L"); - defineMacro("__cpp_variadic_using", "201611L"); - defineMacro("__gnu_linux__", "1"); - defineMacro("__linux", "1"); - defineMacro("__linux__", "1"); - defineMacro("__unix", "1"); - defineMacro("__unix__", "1"); - // clang-format on -} - -void GCCLinuxToolchain::addAmd64Macros() { - // clang-format off - defineMacro("__ATOMIC_HLE_ACQUIRE", "65536"); - defineMacro("__ATOMIC_HLE_RELEASE", "131072"); - defineMacro("__FXSR__", "1"); - defineMacro("__MMX_WITH_SSE__", "1"); - defineMacro("__MMX__", "1"); - defineMacro("__SEG_FS", "1"); - defineMacro("__SEG_GS", "1"); - defineMacro("__SIZEOF_FLOAT128__", "16"); - defineMacro("__SIZEOF_FLOAT80__", "16"); - defineMacro("__SSE2_MATH__", "1"); - defineMacro("__SSE2__", "1"); - defineMacro("__SSE_MATH__", "1"); - defineMacro("__SSE__", "1"); - defineMacro("__amd64", "1"); - defineMacro("__amd64__", "1"); - defineMacro("__code_model_small__", "1"); - defineMacro("__k8", "1"); - defineMacro("__k8__", "1"); - defineMacro("__x86_64", "1"); - defineMacro("__x86_64__", "1"); - defineMacro("__DECIMAL_DIG__", "21"); - defineMacro("__FLT64X_DECIMAL_DIG__", "21"); - defineMacro("__FLT64X_DENORM_MIN__", "3.64519953188247460252840593361941982e-4951F64x"); - defineMacro("__FLT64X_DIG__", "18"); - defineMacro("__FLT64X_EPSILON__", "1.08420217248550443400745280086994171e-19F64x"); - defineMacro("__FLT64X_MANT_DIG__", "64"); - defineMacro("__FLT64X_MAX__", "1.18973149535723176502126385303097021e+4932F64x"); - defineMacro("__FLT64X_NORM_MAX__", "1.18973149535723176502126385303097021e+4932F64x"); - defineMacro("__GCC_DESTRUCTIVE_SIZE", "64"); - defineMacro("__LDBL_DECIMAL_DIG__", "21"); - defineMacro("__LDBL_DENORM_MIN__", "3.64519953188247460252840593361941982e-4951L"); - defineMacro("__LDBL_DIG__", "18"); - defineMacro("__LDBL_EPSILON__", "1.08420217248550443400745280086994171e-19L"); - defineMacro("__LDBL_MANT_DIG__", "64"); - defineMacro("__LDBL_MAX__", "1.18973149535723176502126385303097021e+4932L"); - defineMacro("__LDBL_NORM_MAX__", "1.18973149535723176502126385303097021e+4932L"); - defineMacro("__WCHAR_MAX__", "0x7fffffff"); - defineMacro("__WCHAR_MIN__", "(-__WCHAR_MAX__ - 1)"); - defineMacro("__WCHAR_TYPE__", "int"); - // clang-format on -} - -void GCCLinuxToolchain::addArm64Macros() { - // clang-format off - defineMacro("__AARCH64EL__", "1"); - defineMacro("__AARCH64_CMODEL_SMALL__", "1"); - defineMacro("__ARM_64BIT_STATE", "1"); - defineMacro("__ARM_ALIGN_MAX_PWR", "28"); - defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "16"); - defineMacro("__ARM_ARCH", "8"); - defineMacro("__ARM_ARCH_8A", "1"); - defineMacro("__ARM_ARCH_ISA_A64", "1"); - defineMacro("__ARM_ARCH_PROFILE", "65"); - defineMacro("__ARM_FEATURE_CLZ", "1"); - defineMacro("__ARM_FEATURE_FMA", "1"); - defineMacro("__ARM_FEATURE_IDIV", "1"); - defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1"); - defineMacro("__ARM_FEATURE_UNALIGNED", "1"); - defineMacro("__ARM_FP", "14"); - defineMacro("__ARM_FP16_ARGS", "1"); - defineMacro("__ARM_FP16_FORMAT_IEEE", "1"); - defineMacro("__ARM_NEON", "1"); - defineMacro("__ARM_NEON_SVE_BRIDGE", "1"); - defineMacro("__ARM_PCS_AAPCS64", "1"); - defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", "4"); - defineMacro("__ARM_SIZEOF_WCHAR_T", "4"); - defineMacro("__ARM_STATE_ZA", "1"); - defineMacro("__ARM_STATE_ZT0", "1"); - defineMacro("__CHAR_UNSIGNED__", "1"); - defineMacro("__FLT_EVAL_METHOD_C99__", "0"); - defineMacro("__FP_FAST_FMA", "1"); - defineMacro("__FP_FAST_FMAF", "1"); - defineMacro("__FP_FAST_FMAF32", "1"); - defineMacro("__FP_FAST_FMAF32x", "1"); - defineMacro("__FP_FAST_FMAF64", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16", "1"); - defineMacro("__WCHAR_UNSIGNED__", "1"); - defineMacro("__aarch64__", "1"); - defineMacro("__arm_in(...)", "[[arm::in(__VA_ARGS__)]]"); - defineMacro("__arm_inout(...)", "[[arm::inout(__VA_ARGS__)]]"); - defineMacro("__arm_locally_streaming", "[[arm::locally_streaming]]"); - defineMacro("__arm_new(...)", "[[arm::new(__VA_ARGS__)]]"); - defineMacro("__arm_out(...)", "[[arm::out(__VA_ARGS__)]]"); - defineMacro("__arm_preserves(...)", "[[arm::preserves(__VA_ARGS__)]]"); - defineMacro("__arm_streaming", "[[arm::streaming]]"); - defineMacro("__arm_streaming_compatible", "[[arm::streaming_compatible]]"); - defineMacro("__DECIMAL_DIG__", "36"); - defineMacro("__FLT64X_DECIMAL_DIG__", "36"); - defineMacro("__FLT64X_DENORM_MIN__", "6.47517511943802511092443895822764655e-4966F64x"); - defineMacro("__FLT64X_DIG__", "33"); - defineMacro("__FLT64X_EPSILON__", "1.92592994438723585305597794258492732e-34F64x"); - defineMacro("__FLT64X_MANT_DIG__", "113"); - defineMacro("__FLT64X_MAX__", "1.18973149535723176508575932662800702e+4932F64x"); - defineMacro("__FLT64X_NORM_MAX__", "1.18973149535723176508575932662800702e+4932F64x"); - defineMacro("__GCC_DESTRUCTIVE_SIZE", "256"); - defineMacro("__LDBL_DECIMAL_DIG__", "36"); - defineMacro("__LDBL_DENORM_MIN__", "6.47517511943802511092443895822764655e-4966L"); - defineMacro("__LDBL_DIG__", "33"); - defineMacro("__LDBL_EPSILON__", "1.92592994438723585305597794258492732e-34L"); - defineMacro("__LDBL_MANT_DIG__", "113"); - defineMacro("__LDBL_MAX__", "1.18973149535723176508575932662800702e+4932L"); - defineMacro("__LDBL_NORM_MAX__", "1.18973149535723176508575932662800702e+4932L"); - defineMacro("__WCHAR_MAX__", "0xffffffffU"); - defineMacro("__WCHAR_MIN__", "0U"); - defineMacro("__WCHAR_TYPE__", "unsigned int"); - // clang-format on -} - } // namespace cxx diff --git a/src/parser/cxx/gcc_linux_toolchain.h b/src/parser/cxx/gcc_linux_toolchain.h index 5e7ed75a..5c54454f 100644 --- a/src/parser/cxx/gcc_linux_toolchain.h +++ b/src/parser/cxx/gcc_linux_toolchain.h @@ -38,10 +38,6 @@ class GCCLinuxToolchain final : public Toolchain { void addSystemCppIncludePaths() override; void addPredefinedMacros() override; - void addCommonMacros(); - void addAmd64Macros(); - void addArm64Macros(); - private: std::optional version_; std::string arch_; diff --git a/src/parser/cxx/macos_toolchain.cc b/src/parser/cxx/macos_toolchain.cc index 4d1f2394..dfffb184 100644 --- a/src/parser/cxx/macos_toolchain.cc +++ b/src/parser/cxx/macos_toolchain.cc @@ -79,607 +79,23 @@ void MacOSToolchain::addPredefinedMacros() { defineMacro("_Pragma(x)", ""); addCommonMacros(); - addCxx26Macros(); + addCommonMacOSMacros(); + + if (language() == LanguageKind::kCXX) { + addCommonCxx26Macros(); + addMacOSCxx26Macros(); + } else { + addCommonC23Macros(); + addMacOSC23Macros(); + } if (arch_ == "aarch64") { - addArm64Macros(); + addMacOSAArch64Macros(); } else if (arch_ == "x86_64") { - addAmd64Macros(); + addMacOSX86_64Macros(); + } else { + cxx_runtime_error(std::format("Unsupported architecture: {}", arch_)); } } -void MacOSToolchain::addCxx20Macros() { - // clang-format off - defineMacro("__cplusplus", "202002L"); - defineMacro("__cpp_constexpr", "201907L"); - defineMacro("__cpp_range_based_for", "201603L"); - defineMacro("__cpp_static_assert", "201411L"); - // clang-format on -} - -void MacOSToolchain::addCxx23Macros() { - // clang-format off - defineMacro("__cplusplus", "202302L"); - defineMacro("__cpp_auto_cast", "202110L"); - defineMacro("__cpp_constexpr", "202211L"); - defineMacro("__cpp_if_consteval", "202106L"); - defineMacro("__cpp_implicit_move", "202207L"); - defineMacro("__cpp_multidimensional_subscript", "202211L"); - defineMacro("__cpp_range_based_for", "202211L"); - defineMacro("__cpp_size_t_suffix", "202011L"); - defineMacro("__cpp_static_assert", "201411L"); - // clang-format on -} - -void MacOSToolchain::addCxx26Macros() { - // clang-format off - defineMacro("__cplusplus", "202400L"); - defineMacro("__cpp_auto_cast", "202110L"); - defineMacro("__cpp_constexpr", "202306L"); - defineMacro("__cpp_if_consteval", "202106L"); - defineMacro("__cpp_implicit_move", "202207L"); - defineMacro("__cpp_multidimensional_subscript", "202211L"); - defineMacro("__cpp_range_based_for", "202211L"); - defineMacro("__cpp_size_t_suffix", "202011L"); - defineMacro("__cpp_static_assert", "202306L"); - // clang-format on -} - -void MacOSToolchain::addCommonMacros() { - // clang-format off - defineMacro("TARGET_IPHONE_SIMULATOR", "0"); - defineMacro("TARGET_OS_DRIVERKIT", "0"); - defineMacro("TARGET_OS_EMBEDDED", "0"); - defineMacro("TARGET_OS_IOS", "0"); - defineMacro("TARGET_OS_IPHONE", "0"); - defineMacro("TARGET_OS_LINUX", "0"); - defineMacro("TARGET_OS_MAC", "1"); - defineMacro("TARGET_OS_MACCATALYST", "0"); - defineMacro("TARGET_OS_NANO", "0"); - defineMacro("TARGET_OS_OSX", "1"); - defineMacro("TARGET_OS_SIMULATOR", "0"); - defineMacro("TARGET_OS_TV", "0"); - defineMacro("TARGET_OS_UIKITFORMAC", "0"); - defineMacro("TARGET_OS_UNIX", "0"); - defineMacro("TARGET_OS_VISION", "0"); - defineMacro("TARGET_OS_WATCH", "0"); - defineMacro("TARGET_OS_WIN32", "0"); - defineMacro("TARGET_OS_WINDOWS", "0"); - defineMacro("_LP64", "1"); - defineMacro("__APPLE_CC__", "6000"); - defineMacro("__APPLE__", "1"); - defineMacro("__ATOMIC_ACQUIRE", "2"); - defineMacro("__ATOMIC_ACQ_REL", "4"); - defineMacro("__ATOMIC_CONSUME", "1"); - defineMacro("__ATOMIC_RELAXED", "0"); - defineMacro("__ATOMIC_RELEASE", "3"); - defineMacro("__ATOMIC_SEQ_CST", "5"); - defineMacro("__BIGGEST_ALIGNMENT__", "16"); - defineMacro("__BITINT_MAXWIDTH__", "8388608"); - defineMacro("__BOOL_WIDTH__", "8"); - defineMacro("__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__"); - defineMacro("__CHAR16_TYPE__", "unsigned short"); - defineMacro("__CHAR32_TYPE__", "unsigned int"); - defineMacro("__CHAR_BIT__", "8"); - defineMacro("__CLANG_ATOMIC_BOOL_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR16_T_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR32_T_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR8_T_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_INT_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_LLONG_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_LONG_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_POINTER_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_SHORT_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_WCHAR_T_LOCK_FREE", "2"); - defineMacro("__CONSTANT_CFSTRINGS__", "1"); - defineMacro("__DBL_DECIMAL_DIG__", "17"); - defineMacro("__DBL_DENORM_MIN__", "4.9406564584124654e-324"); - defineMacro("__DBL_DIG__", "15"); - defineMacro("__DBL_EPSILON__", "2.2204460492503131e-16"); - defineMacro("__DBL_HAS_DENORM__", "1"); - defineMacro("__DBL_HAS_INFINITY__", "1"); - defineMacro("__DBL_HAS_QUIET_NAN__", "1"); - defineMacro("__DBL_MANT_DIG__", "53"); - defineMacro("__DBL_MAX_10_EXP__", "308"); - defineMacro("__DBL_MAX_EXP__", "1024"); - defineMacro("__DBL_MAX__", "1.7976931348623157e+308"); - defineMacro("__DBL_MIN_10_EXP__", "(-307)"); - defineMacro("__DBL_MIN_EXP__", "(-1021)"); - defineMacro("__DBL_MIN__", "2.2250738585072014e-308"); - defineMacro("__DBL_NORM_MAX__", "1.7976931348623157e+308"); - defineMacro("__DECIMAL_DIG__", "__LDBL_DECIMAL_DIG__"); - defineMacro("__DEPRECATED", "1"); - defineMacro("__DYNAMIC__", "1"); - defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", "150000"); - defineMacro("__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__", "150000"); - defineMacro("__EXCEPTIONS", "1"); - defineMacro("__FINITE_MATH_ONLY__", "0"); - defineMacro("__FLT16_DECIMAL_DIG__", "5"); - defineMacro("__FLT16_DENORM_MIN__", "5.9604644775390625e-8F16"); - defineMacro("__FLT16_DIG__", "3"); - defineMacro("__FLT16_EPSILON__", "9.765625e-4F16"); - defineMacro("__FLT16_HAS_DENORM__", "1"); - defineMacro("__FLT16_HAS_INFINITY__", "1"); - defineMacro("__FLT16_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT16_MANT_DIG__", "11"); - defineMacro("__FLT16_MAX_10_EXP__", "4"); - defineMacro("__FLT16_MAX_EXP__", "16"); - defineMacro("__FLT16_MAX__", "6.5504e+4F16"); - defineMacro("__FLT16_MIN_10_EXP__", "(-4)"); - defineMacro("__FLT16_MIN_EXP__", "(-13)"); - defineMacro("__FLT16_MIN__", "6.103515625e-5F16"); - defineMacro("__FLT16_NORM_MAX__", "6.5504e+4F16"); - defineMacro("__FLT_DECIMAL_DIG__", "9"); - defineMacro("__FLT_DENORM_MIN__", "1.40129846e-45F"); - defineMacro("__FLT_DIG__", "6"); - defineMacro("__FLT_EPSILON__", "1.19209290e-7F"); - defineMacro("__FLT_HAS_DENORM__", "1"); - defineMacro("__FLT_HAS_INFINITY__", "1"); - defineMacro("__FLT_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT_MANT_DIG__", "24"); - defineMacro("__FLT_MAX_10_EXP__", "38"); - defineMacro("__FLT_MAX_EXP__", "128"); - defineMacro("__FLT_MAX__", "3.40282347e+38F"); - defineMacro("__FLT_MIN_10_EXP__", "(-37)"); - defineMacro("__FLT_MIN_EXP__", "(-125)"); - defineMacro("__FLT_MIN__", "1.17549435e-38F"); - defineMacro("__FLT_NORM_MAX__", "3.40282347e+38F"); - defineMacro("__FLT_RADIX__", "2"); - defineMacro("__FPCLASS_NEGINF", "0x0004"); - defineMacro("__FPCLASS_NEGNORMAL", "0x0008"); - defineMacro("__FPCLASS_NEGSUBNORMAL", "0x0010"); - defineMacro("__FPCLASS_NEGZERO", "0x0020"); - defineMacro("__FPCLASS_POSINF", "0x0200"); - defineMacro("__FPCLASS_POSNORMAL", "0x0100"); - defineMacro("__FPCLASS_POSSUBNORMAL", "0x0080"); - defineMacro("__FPCLASS_POSZERO", "0x0040"); - defineMacro("__FPCLASS_QNAN", "0x0002"); - defineMacro("__FPCLASS_SNAN", "0x0001"); - defineMacro("__GCC_ASM_FLAG_OUTPUTS__", "1"); - defineMacro("__GCC_ATOMIC_BOOL_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR16_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR32_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR8_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_INT_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_LLONG_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_LONG_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_SHORT_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1"); - defineMacro("__GCC_ATOMIC_WCHAR_T_LOCK_FREE", "2"); - defineMacro("__GCC_CONSTRUCTIVE_SIZE", "64"); - defineMacro("__GCC_DESTRUCTIVE_SIZE", "64"); - defineMacro("__GCC_HAVE_DWARF2_CFI_ASM", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8", "1"); - defineMacro("__GNUC_GNU_INLINE__", "1"); - defineMacro("__GNUC_MINOR__", "2"); - defineMacro("__GNUC_PATCHLEVEL__", "1"); - defineMacro("__GNUC__", "4"); - defineMacro("__GNUG__", "4"); - defineMacro("__GXX_ABI_VERSION", "1002"); - defineMacro("__GXX_EXPERIMENTAL_CXX0X__", "1"); - defineMacro("__GXX_RTTI", "1"); - defineMacro("__GXX_WEAK__", "1"); - defineMacro("__INT16_FMTd__", "\"hd\""); - defineMacro("__INT16_FMTi__", "\"hi\""); - defineMacro("__INT16_MAX__", "32767"); - defineMacro("__INT16_TYPE__", "short"); - defineMacro("__INT32_FMTd__", "\"d\""); - defineMacro("__INT32_FMTi__", "\"i\""); - defineMacro("__INT32_MAX__", "2147483647"); - defineMacro("__INT32_TYPE__", "int"); - defineMacro("__INT64_C_SUFFIX__", "LL"); - defineMacro("__INT64_FMTd__", "\"lld\""); - defineMacro("__INT64_FMTi__", "\"lli\""); - defineMacro("__INT64_MAX__", "9223372036854775807LL"); - defineMacro("__INT64_TYPE__", "long long int"); - defineMacro("__INT8_FMTd__", "\"hhd\""); - defineMacro("__INT8_FMTi__", "\"hhi\""); - defineMacro("__INT8_MAX__", "127"); - defineMacro("__INT8_TYPE__", "signed char"); - defineMacro("__INTMAX_C_SUFFIX__", "L"); - defineMacro("__INTMAX_FMTd__", "\"ld\""); - defineMacro("__INTMAX_FMTi__", "\"li\""); - defineMacro("__INTMAX_MAX__", "9223372036854775807L"); - defineMacro("__INTMAX_TYPE__", "long int"); - defineMacro("__INTMAX_WIDTH__", "64"); - defineMacro("__INTPTR_FMTd__", "\"ld\""); - defineMacro("__INTPTR_FMTi__", "\"li\""); - defineMacro("__INTPTR_MAX__", "9223372036854775807L"); - defineMacro("__INTPTR_TYPE__", "long int"); - defineMacro("__INTPTR_WIDTH__", "64"); - defineMacro("__INT_FAST16_FMTd__", "\"hd\""); - defineMacro("__INT_FAST16_FMTi__", "\"hi\""); - defineMacro("__INT_FAST16_MAX__", "32767"); - defineMacro("__INT_FAST16_TYPE__", "short"); - defineMacro("__INT_FAST16_WIDTH__", "16"); - defineMacro("__INT_FAST32_FMTd__", "\"d\""); - defineMacro("__INT_FAST32_FMTi__", "\"i\""); - defineMacro("__INT_FAST32_MAX__", "2147483647"); - defineMacro("__INT_FAST32_TYPE__", "int"); - defineMacro("__INT_FAST32_WIDTH__", "32"); - defineMacro("__INT_FAST64_FMTd__", "\"lld\""); - defineMacro("__INT_FAST64_FMTi__", "\"lli\""); - defineMacro("__INT_FAST64_MAX__", "9223372036854775807LL"); - defineMacro("__INT_FAST64_TYPE__", "long long int"); - defineMacro("__INT_FAST64_WIDTH__", "64"); - defineMacro("__INT_FAST8_FMTd__", "\"hhd\""); - defineMacro("__INT_FAST8_FMTi__", "\"hhi\""); - defineMacro("__INT_FAST8_MAX__", "127"); - defineMacro("__INT_FAST8_TYPE__", "signed char"); - defineMacro("__INT_FAST8_WIDTH__", "8"); - defineMacro("__INT_LEAST16_FMTd__", "\"hd\""); - defineMacro("__INT_LEAST16_FMTi__", "\"hi\""); - defineMacro("__INT_LEAST16_MAX__", "32767"); - defineMacro("__INT_LEAST16_TYPE__", "short"); - defineMacro("__INT_LEAST16_WIDTH__", "16"); - defineMacro("__INT_LEAST32_FMTd__", "\"d\""); - defineMacro("__INT_LEAST32_FMTi__", "\"i\""); - defineMacro("__INT_LEAST32_MAX__", "2147483647"); - defineMacro("__INT_LEAST32_TYPE__", "int"); - defineMacro("__INT_LEAST32_WIDTH__", "32"); - defineMacro("__INT_LEAST64_FMTd__", "\"lld\""); - defineMacro("__INT_LEAST64_FMTi__", "\"lli\""); - defineMacro("__INT_LEAST64_MAX__", "9223372036854775807LL"); - defineMacro("__INT_LEAST64_TYPE__", "long long int"); - defineMacro("__INT_LEAST64_WIDTH__", "64"); - defineMacro("__INT_LEAST8_FMTd__", "\"hhd\""); - defineMacro("__INT_LEAST8_FMTi__", "\"hhi\""); - defineMacro("__INT_LEAST8_MAX__", "127"); - defineMacro("__INT_LEAST8_TYPE__", "signed char"); - defineMacro("__INT_LEAST8_WIDTH__", "8"); - defineMacro("__INT_MAX__", "2147483647"); - defineMacro("__INT_WIDTH__", "32"); - defineMacro("__LDBL_DECIMAL_DIG__", "21"); - defineMacro("__LDBL_DENORM_MIN__", "3.64519953188247460253e-4951L"); - defineMacro("__LDBL_DIG__", "18"); - defineMacro("__LDBL_EPSILON__", "1.08420217248550443401e-19L"); - defineMacro("__LDBL_HAS_DENORM__", "1"); - defineMacro("__LDBL_HAS_INFINITY__", "1"); - defineMacro("__LDBL_HAS_QUIET_NAN__", "1"); - defineMacro("__LDBL_MANT_DIG__", "64"); - defineMacro("__LDBL_MAX_10_EXP__", "4932"); - defineMacro("__LDBL_MAX_EXP__", "16384"); - defineMacro("__LDBL_MAX__", "1.18973149535723176502e+4932L"); - defineMacro("__LDBL_MIN_10_EXP__", "(-4931)"); - defineMacro("__LDBL_MIN_EXP__", "(-16381)"); - defineMacro("__LDBL_MIN__", "3.36210314311209350626e-4932L"); - defineMacro("__LDBL_NORM_MAX__", "1.18973149535723176502e+4932L"); - defineMacro("__LITTLE_ENDIAN__", "1"); - defineMacro("__LLONG_WIDTH__", "64"); - defineMacro("__LONG_LONG_MAX__", "9223372036854775807LL"); - defineMacro("__LONG_MAX__", "9223372036854775807L"); - defineMacro("__LONG_WIDTH__", "64"); - defineMacro("__LP64__", "1"); - defineMacro("__MACH__", "1"); - defineMacro("__MEMORY_SCOPE_DEVICE", "1"); - defineMacro("__MEMORY_SCOPE_SINGLE", "4"); - defineMacro("__MEMORY_SCOPE_SYSTEM", "0"); - defineMacro("__MEMORY_SCOPE_WRKGRP", "2"); - defineMacro("__MEMORY_SCOPE_WVFRNT", "3"); - defineMacro("__NO_INLINE__", "1"); - defineMacro("__NO_MATH_ERRNO__", "1"); - defineMacro("__OBJC_BOOL_IS_BOOL", "0"); - defineMacro("__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES", "3"); - defineMacro("__OPENCL_MEMORY_SCOPE_DEVICE", "2"); - defineMacro("__OPENCL_MEMORY_SCOPE_SUB_GROUP", "4"); - defineMacro("__OPENCL_MEMORY_SCOPE_WORK_GROUP", "1"); - defineMacro("__OPENCL_MEMORY_SCOPE_WORK_ITEM", "0"); - defineMacro("__ORDER_BIG_ENDIAN__", "4321"); - defineMacro("__ORDER_LITTLE_ENDIAN__", "1234"); - defineMacro("__ORDER_PDP_ENDIAN__", "3412"); - defineMacro("__PIC__", "2"); - defineMacro("__POINTER_WIDTH__", "64"); - defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1"); - defineMacro("__PTRDIFF_FMTd__", "\"ld\""); - defineMacro("__PTRDIFF_FMTi__", "\"li\""); - defineMacro("__PTRDIFF_MAX__", "9223372036854775807L"); - defineMacro("__PTRDIFF_TYPE__", "long int"); - defineMacro("__PTRDIFF_WIDTH__", "64"); - defineMacro("__SCHAR_MAX__", "127"); - defineMacro("__SHRT_MAX__", "32767"); - defineMacro("__SHRT_WIDTH__", "16"); - defineMacro("__SIG_ATOMIC_MAX__", "2147483647"); - defineMacro("__SIG_ATOMIC_WIDTH__", "32"); - defineMacro("__SIZEOF_DOUBLE__", "8"); - defineMacro("__SIZEOF_FLOAT__", "4"); - defineMacro("__SIZEOF_INT128__", "16"); - defineMacro("__SIZEOF_INT__", "4"); - defineMacro("__SIZEOF_LONG_DOUBLE__", "16"); - defineMacro("__SIZEOF_LONG_LONG__", "8"); - defineMacro("__SIZEOF_LONG__", "8"); - defineMacro("__SIZEOF_POINTER__", "8"); - defineMacro("__SIZEOF_PTRDIFF_T__", "8"); - defineMacro("__SIZEOF_SHORT__", "2"); - defineMacro("__SIZEOF_SIZE_T__", "8"); - defineMacro("__SIZEOF_WCHAR_T__", "4"); - defineMacro("__SIZEOF_WINT_T__", "4"); - defineMacro("__SIZE_FMTX__", "\"lX\""); - defineMacro("__SIZE_FMTo__", "\"lo\""); - defineMacro("__SIZE_FMTu__", "\"lu\""); - defineMacro("__SIZE_FMTx__", "\"lx\""); - defineMacro("__SIZE_MAX__", "18446744073709551615UL"); - defineMacro("__SIZE_TYPE__", "long unsigned int"); - defineMacro("__SIZE_WIDTH__", "64"); - defineMacro("__SSP__", "1"); - defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16UL"); - defineMacro("__STDCPP_THREADS__", "1"); - defineMacro("__STDC_EMBED_EMPTY__", "2"); - defineMacro("__STDC_EMBED_FOUND__", "1"); - defineMacro("__STDC_EMBED_NOT_FOUND__", "0"); - defineMacro("__STDC_HOSTED__", "1"); - defineMacro("__STDC_NO_THREADS__", "1"); - defineMacro("__STDC_UTF_16__", "1"); - defineMacro("__STDC_UTF_32__", "1"); - defineMacro("__STDC__", "1"); - defineMacro("__STRICT_ANSI__", "1"); - defineMacro("__UINT16_FMTX__", "\"hX\""); - defineMacro("__UINT16_FMTo__", "\"ho\""); - defineMacro("__UINT16_FMTu__", "\"hu\""); - defineMacro("__UINT16_FMTx__", "\"hx\""); - defineMacro("__UINT16_MAX__", "65535"); - defineMacro("__UINT16_TYPE__", "unsigned short"); - defineMacro("__UINT32_C_SUFFIX__", "U"); - defineMacro("__UINT32_FMTX__", "\"X\""); - defineMacro("__UINT32_FMTo__", "\"o\""); - defineMacro("__UINT32_FMTu__", "\"u\""); - defineMacro("__UINT32_FMTx__", "\"x\""); - defineMacro("__UINT32_MAX__", "4294967295U"); - defineMacro("__UINT32_TYPE__", "unsigned int"); - defineMacro("__UINT64_C_SUFFIX__", "ULL"); - defineMacro("__UINT64_FMTX__", "\"llX\""); - defineMacro("__UINT64_FMTo__", "\"llo\""); - defineMacro("__UINT64_FMTu__", "\"llu\""); - defineMacro("__UINT64_FMTx__", "\"llx\""); - defineMacro("__UINT64_MAX__", "18446744073709551615ULL"); - defineMacro("__UINT64_TYPE__", "long long unsigned int"); - defineMacro("__UINT8_FMTX__", "\"hhX\""); - defineMacro("__UINT8_FMTo__", "\"hho\""); - defineMacro("__UINT8_FMTu__", "\"hhu\""); - defineMacro("__UINT8_FMTx__", "\"hhx\""); - defineMacro("__UINT8_MAX__", "255"); - defineMacro("__UINT8_TYPE__", "unsigned char"); - defineMacro("__UINTMAX_C_SUFFIX__", "UL"); - defineMacro("__UINTMAX_FMTX__", "\"lX\""); - defineMacro("__UINTMAX_FMTo__", "\"lo\""); - defineMacro("__UINTMAX_FMTu__", "\"lu\""); - defineMacro("__UINTMAX_FMTx__", "\"lx\""); - defineMacro("__UINTMAX_MAX__", "18446744073709551615UL"); - defineMacro("__UINTMAX_TYPE__", "long unsigned int"); - defineMacro("__UINTMAX_WIDTH__", "64"); - defineMacro("__UINTPTR_FMTX__", "\"lX\""); - defineMacro("__UINTPTR_FMTo__", "\"lo\""); - defineMacro("__UINTPTR_FMTu__", "\"lu\""); - defineMacro("__UINTPTR_FMTx__", "\"lx\""); - defineMacro("__UINTPTR_MAX__", "18446744073709551615UL"); - defineMacro("__UINTPTR_TYPE__", "long unsigned int"); - defineMacro("__UINTPTR_WIDTH__", "64"); - defineMacro("__UINT_FAST16_FMTX__", "\"hX\""); - defineMacro("__UINT_FAST16_FMTo__", "\"ho\""); - defineMacro("__UINT_FAST16_FMTu__", "\"hu\""); - defineMacro("__UINT_FAST16_FMTx__", "\"hx\""); - defineMacro("__UINT_FAST16_MAX__", "65535"); - defineMacro("__UINT_FAST16_TYPE__", "unsigned short"); - defineMacro("__UINT_FAST32_FMTX__", "\"X\""); - defineMacro("__UINT_FAST32_FMTo__", "\"o\""); - defineMacro("__UINT_FAST32_FMTu__", "\"u\""); - defineMacro("__UINT_FAST32_FMTx__", "\"x\""); - defineMacro("__UINT_FAST32_MAX__", "4294967295U"); - defineMacro("__UINT_FAST32_TYPE__", "unsigned int"); - defineMacro("__UINT_FAST64_FMTX__", "\"llX\""); - defineMacro("__UINT_FAST64_FMTo__", "\"llo\""); - defineMacro("__UINT_FAST64_FMTu__", "\"llu\""); - defineMacro("__UINT_FAST64_FMTx__", "\"llx\""); - defineMacro("__UINT_FAST64_MAX__", "18446744073709551615ULL"); - defineMacro("__UINT_FAST64_TYPE__", "long long unsigned int"); - defineMacro("__UINT_FAST8_FMTX__", "\"hhX\""); - defineMacro("__UINT_FAST8_FMTo__", "\"hho\""); - defineMacro("__UINT_FAST8_FMTu__", "\"hhu\""); - defineMacro("__UINT_FAST8_FMTx__", "\"hhx\""); - defineMacro("__UINT_FAST8_MAX__", "255"); - defineMacro("__UINT_FAST8_TYPE__", "unsigned char"); - defineMacro("__UINT_LEAST16_FMTX__", "\"hX\""); - defineMacro("__UINT_LEAST16_FMTo__", "\"ho\""); - defineMacro("__UINT_LEAST16_FMTu__", "\"hu\""); - defineMacro("__UINT_LEAST16_FMTx__", "\"hx\""); - defineMacro("__UINT_LEAST16_MAX__", "65535"); - defineMacro("__UINT_LEAST16_TYPE__", "unsigned short"); - defineMacro("__UINT_LEAST32_FMTX__", "\"X\""); - defineMacro("__UINT_LEAST32_FMTo__", "\"o\""); - defineMacro("__UINT_LEAST32_FMTu__", "\"u\""); - defineMacro("__UINT_LEAST32_FMTx__", "\"x\""); - defineMacro("__UINT_LEAST32_MAX__", "4294967295U"); - defineMacro("__UINT_LEAST32_TYPE__", "unsigned int"); - defineMacro("__UINT_LEAST64_FMTX__", "\"llX\""); - defineMacro("__UINT_LEAST64_FMTo__", "\"llo\""); - defineMacro("__UINT_LEAST64_FMTu__", "\"llu\""); - defineMacro("__UINT_LEAST64_FMTx__", "\"llx\""); - defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615ULL"); - defineMacro("__UINT_LEAST64_TYPE__", "long long unsigned int"); - defineMacro("__UINT_LEAST8_FMTX__", "\"hhX\""); - defineMacro("__UINT_LEAST8_FMTo__", "\"hho\""); - defineMacro("__UINT_LEAST8_FMTu__", "\"hhu\""); - defineMacro("__UINT_LEAST8_FMTx__", "\"hhx\""); - defineMacro("__UINT_LEAST8_MAX__", "255"); - defineMacro("__UINT_LEAST8_TYPE__", "unsigned char"); - defineMacro("__USER_LABEL_PREFIX__", "_"); - defineMacro("__VERSION__", "\"Homebrew Clang 19.1.3\""); - defineMacro("__WCHAR_MAX__", "2147483647"); - defineMacro("__WCHAR_TYPE__", "int"); - defineMacro("__WCHAR_WIDTH__", "32"); - defineMacro("__WINT_MAX__", "2147483647"); - defineMacro("__WINT_TYPE__", "int"); - defineMacro("__WINT_WIDTH__", "32"); - defineMacro("__block", "__attribute__((__blocks__(byref)))"); - defineMacro("__clang__", "1"); - defineMacro("__clang_literal_encoding__", "\"UTF-8\""); - defineMacro("__clang_major__", "19"); - defineMacro("__clang_minor__", "1"); - defineMacro("__clang_patchlevel__", "3"); - defineMacro("__clang_version__", "\"19.1.3 \""); - defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\""); - defineMacro("__cpp_aggregate_bases", "201603L"); - defineMacro("__cpp_aggregate_nsdmi", "201304L"); - defineMacro("__cpp_aggregate_paren_init", "201902L"); - defineMacro("__cpp_alias_templates", "200704L"); - defineMacro("__cpp_aligned_new", "201606L"); - defineMacro("__cpp_attributes", "200809L"); - defineMacro("__cpp_binary_literals", "201304L"); - defineMacro("__cpp_capture_star_this", "201603L"); - defineMacro("__cpp_char8_t", "202207L"); - defineMacro("__cpp_concepts", "202002"); - defineMacro("__cpp_conditional_explicit", "201806L"); - defineMacro("__cpp_consteval", "202211L"); - defineMacro("__cpp_constexpr_dynamic_alloc", "201907L"); - defineMacro("__cpp_constexpr_in_decltype", "201711L"); - defineMacro("__cpp_constinit", "201907L"); - defineMacro("__cpp_decltype", "200707L"); - defineMacro("__cpp_decltype_auto", "201304L"); - defineMacro("__cpp_deduction_guides", "201703L"); - defineMacro("__cpp_delegating_constructors", "200604L"); - defineMacro("__cpp_deleted_function", "202403L"); - defineMacro("__cpp_designated_initializers", "201707L"); - defineMacro("__cpp_digit_separators", "201309L"); - defineMacro("__cpp_enumerator_attributes", "201411L"); - defineMacro("__cpp_exceptions", "199711L"); - defineMacro("__cpp_fold_expressions", "201603L"); - defineMacro("__cpp_generic_lambdas", "201707L"); - defineMacro("__cpp_guaranteed_copy_elision", "201606L"); - defineMacro("__cpp_hex_float", "201603L"); - defineMacro("__cpp_if_constexpr", "201606L"); - defineMacro("__cpp_impl_coroutine", "201902L"); - defineMacro("__cpp_impl_destroying_delete", "201806L"); - defineMacro("__cpp_impl_three_way_comparison", "201907L"); - defineMacro("__cpp_inheriting_constructors", "201511L"); - defineMacro("__cpp_init_captures", "201803L"); - defineMacro("__cpp_initializer_lists", "200806L"); - defineMacro("__cpp_inline_variables", "201606L"); - defineMacro("__cpp_lambdas", "200907L"); - defineMacro("__cpp_named_character_escapes", "202207L"); - defineMacro("__cpp_namespace_attributes", "201411L"); - defineMacro("__cpp_nested_namespace_definitions", "201411L"); - defineMacro("__cpp_noexcept_function_type", "201510L"); - defineMacro("__cpp_nontype_template_args", "201411L"); - defineMacro("__cpp_nontype_template_parameter_auto", "201606L"); - defineMacro("__cpp_nsdmi", "200809L"); - defineMacro("__cpp_pack_indexing", "202311L"); - defineMacro("__cpp_placeholder_variables", "202306L"); - defineMacro("__cpp_raw_strings", "200710L"); - defineMacro("__cpp_ref_qualifiers", "200710L"); - defineMacro("__cpp_return_type_deduction", "201304L"); - defineMacro("__cpp_rtti", "199711L"); - defineMacro("__cpp_rvalue_references", "200610L"); - defineMacro("__cpp_sized_deallocation", "201309L"); - defineMacro("__cpp_static_call_operator", "202207L"); - defineMacro("__cpp_structured_bindings", "202403L"); - defineMacro("__cpp_template_auto", "201606L"); - defineMacro("__cpp_template_template_args", "201611L"); - defineMacro("__cpp_threadsafe_static_init", "200806L"); - defineMacro("__cpp_unicode_characters", "200704L"); - defineMacro("__cpp_unicode_literals", "200710L"); - defineMacro("__cpp_user_defined_literals", "200809L"); - defineMacro("__cpp_using_enum", "201907L"); - defineMacro("__cpp_variable_templates", "201304L"); - defineMacro("__cpp_variadic_templates", "200704L"); - defineMacro("__cpp_variadic_using", "201611L"); - defineMacro("__llvm__", "1"); - defineMacro("__nonnull", "_Nonnull"); - defineMacro("__null_unspecified", "_Null_unspecified"); - defineMacro("__nullable", "_Nullable"); - defineMacro("__pic__", "2"); - defineMacro("__private_extern__", "extern"); - defineMacro("__weak", "__attribute__((objc_gc(weak)))"); - // clang-format on -} - -void MacOSToolchain::addAmd64Macros() { - // clang-format off - defineMacro("__FXSR__", "1"); - defineMacro("__LAHF_SAHF__", "1"); - defineMacro("__MMX__", "1"); - defineMacro("__NO_MATH_INLINES", "1"); - defineMacro("__SEG_FS", "1"); - defineMacro("__SEG_GS", "1"); - defineMacro("__SSE2_MATH__", "1"); - defineMacro("__SSE2__", "1"); - defineMacro("__SSE3__", "1"); - defineMacro("__SSE4_1__", "1"); - defineMacro("__SSE_MATH__", "1"); - defineMacro("__SSE__", "1"); - defineMacro("__SSSE3__", "1"); - defineMacro("__amd64", "1"); - defineMacro("__amd64__", "1"); - defineMacro("__code_model_small__", "1"); - defineMacro("__core2", "1"); - defineMacro("__core2__", "1"); - defineMacro("__seg_fs", "__attribute__((address_space(257)))"); - defineMacro("__seg_gs", "__attribute__((address_space(256)))"); - defineMacro("__tune_core2__", "1"); - defineMacro("__x86_64", "1"); - defineMacro("__x86_64__", "1"); - // clang-format on -} - -void MacOSToolchain::addArm64Macros() { - // clang-format off - defineMacro("__AARCH64EL__", "1"); - defineMacro("__AARCH64_CMODEL_SMALL__", "1"); - defineMacro("__AARCH64_SIMD__", "1"); - defineMacro("__ARM64_ARCH_8__", "1"); - defineMacro("__ARM_64BIT_STATE", "1"); - defineMacro("__ARM_ACLE", "200"); - defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4"); - defineMacro("__ARM_ARCH", "8"); - defineMacro("__ARM_ARCH_ISA_A64", "1"); - defineMacro("__ARM_ARCH_PROFILE", "'A'"); - defineMacro("__ARM_FEATURE_AES", "1"); - defineMacro("__ARM_FEATURE_ATOMICS", "1"); - defineMacro("__ARM_FEATURE_CLZ", "1"); - defineMacro("__ARM_FEATURE_COMPLEX", "1"); - defineMacro("__ARM_FEATURE_CRC32", "1"); - defineMacro("__ARM_FEATURE_CRYPTO", "1"); - defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING", "1"); - defineMacro("__ARM_FEATURE_DIV", "1"); - defineMacro("__ARM_FEATURE_DOTPROD", "1"); - defineMacro("__ARM_FEATURE_FMA", "1"); - defineMacro("__ARM_FEATURE_FP16_FML", "1"); - defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1"); - defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1"); - defineMacro("__ARM_FEATURE_IDIV", "1"); - defineMacro("__ARM_FEATURE_JCVT", "1"); - defineMacro("__ARM_FEATURE_LDREX", "0xF"); - defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1"); - defineMacro("__ARM_FEATURE_PAUTH", "1"); - defineMacro("__ARM_FEATURE_QRDMX", "1"); - defineMacro("__ARM_FEATURE_RCPC", "1"); - defineMacro("__ARM_FEATURE_SHA2", "1"); - defineMacro("__ARM_FEATURE_SHA3", "1"); - defineMacro("__ARM_FEATURE_SHA512", "1"); - defineMacro("__ARM_FEATURE_UNALIGNED", "1"); - defineMacro("__ARM_FP", "0xE"); - defineMacro("__ARM_FP16_ARGS", "1"); - defineMacro("__ARM_FP16_FORMAT_IEEE", "1"); - defineMacro("__ARM_NEON", "1"); - defineMacro("__ARM_NEON_FP", "0xE"); - defineMacro("__ARM_NEON__", "1"); - defineMacro("__ARM_PCS_AAPCS64", "1"); - defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", "4"); - defineMacro("__ARM_SIZEOF_WCHAR_T", "4"); - defineMacro("__ARM_STATE_ZA", "1"); - defineMacro("__ARM_STATE_ZT0", "1"); - defineMacro("__FP_FAST_FMA", "1"); - defineMacro("__FP_FAST_FMAF", "1"); - defineMacro("__HAVE_FUNCTION_MULTI_VERSIONING", "1"); - defineMacro("__aarch64__", "1"); - defineMacro("__arm64", "1"); - defineMacro("__arm64__", "1"); - // clang-format on -} - } // namespace cxx diff --git a/src/parser/cxx/macos_toolchain.h b/src/parser/cxx/macos_toolchain.h index e53fe5e3..16e17973 100644 --- a/src/parser/cxx/macos_toolchain.h +++ b/src/parser/cxx/macos_toolchain.h @@ -39,13 +39,6 @@ class MacOSToolchain final : public Toolchain { void addSystemCppIncludePaths() override; void addPredefinedMacros() override; - void addCommonMacros(); - void addCxx20Macros(); - void addCxx23Macros(); - void addCxx26Macros(); - void addArm64Macros(); - void addAmd64Macros(); - private: std::string platformPath_; std::string toolchainPath_; diff --git a/src/parser/cxx/toolchain.cc b/src/parser/cxx/toolchain.cc index 87ba1f56..84587f33 100644 --- a/src/parser/cxx/toolchain.cc +++ b/src/parser/cxx/toolchain.cc @@ -49,4 +49,1327 @@ void Toolchain::addSystemIncludePath(std::string path) { preprocessor_->addSystemIncludePath(std::move(path)); } +void Toolchain::addCommonMacros() { + defineMacro("__ATOMIC_ACQUIRE", "2"); + defineMacro("__ATOMIC_ACQ_REL", "4"); + defineMacro("__ATOMIC_CONSUME", "1"); + defineMacro("__ATOMIC_RELAXED", "0"); + defineMacro("__ATOMIC_RELEASE", "3"); + defineMacro("__ATOMIC_SEQ_CST", "5"); + defineMacro("__BOOL_WIDTH__", "1"); + defineMacro("__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__"); + defineMacro("__CHAR16_TYPE__", "unsigned short"); + defineMacro("__CHAR32_TYPE__", "unsigned int"); + defineMacro("__CHAR_BIT__", "8"); + defineMacro("__CLANG_ATOMIC_BOOL_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_CHAR16_T_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_CHAR32_T_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_CHAR8_T_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_CHAR_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_INT_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_LLONG_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_LONG_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_POINTER_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_SHORT_LOCK_FREE", "2"); + defineMacro("__CLANG_ATOMIC_WCHAR_T_LOCK_FREE", "2"); + defineMacro("__CONSTANT_CFSTRINGS__", "1"); + defineMacro("__DBL_DECIMAL_DIG__", "17"); + defineMacro("__DBL_DENORM_MIN__", "4.9406564584124654e-324"); + defineMacro("__DBL_DIG__", "15"); + defineMacro("__DBL_EPSILON__", "2.2204460492503131e-16"); + defineMacro("__DBL_HAS_DENORM__", "1"); + defineMacro("__DBL_HAS_INFINITY__", "1"); + defineMacro("__DBL_HAS_QUIET_NAN__", "1"); + defineMacro("__DBL_MANT_DIG__", "53"); + defineMacro("__DBL_MAX_10_EXP__", "308"); + defineMacro("__DBL_MAX_EXP__", "1024"); + defineMacro("__DBL_MAX__", "1.7976931348623157e+308"); + defineMacro("__DBL_MIN_10_EXP__", "(-307)"); + defineMacro("__DBL_MIN_EXP__", "(-1021)"); + defineMacro("__DBL_MIN__", "2.2250738585072014e-308"); + defineMacro("__DBL_NORM_MAX__", "1.7976931348623157e+308"); + defineMacro("__DECIMAL_DIG__", "__LDBL_DECIMAL_DIG__"); + defineMacro("__FINITE_MATH_ONLY__", "0"); + defineMacro("__FLT_DECIMAL_DIG__", "9"); + defineMacro("__FLT_DENORM_MIN__", "1.40129846e-45F"); + defineMacro("__FLT_DIG__", "6"); + defineMacro("__FLT_EPSILON__", "1.19209290e-7F"); + defineMacro("__FLT_HAS_DENORM__", "1"); + defineMacro("__FLT_HAS_INFINITY__", "1"); + defineMacro("__FLT_HAS_QUIET_NAN__", "1"); + defineMacro("__FLT_MANT_DIG__", "24"); + defineMacro("__FLT_MAX_10_EXP__", "38"); + defineMacro("__FLT_MAX_EXP__", "128"); + defineMacro("__FLT_MAX__", "3.40282347e+38F"); + defineMacro("__FLT_MIN_10_EXP__", "(-37)"); + defineMacro("__FLT_MIN_EXP__", "(-125)"); + defineMacro("__FLT_MIN__", "1.17549435e-38F"); + defineMacro("__FLT_NORM_MAX__", "3.40282347e+38F"); + defineMacro("__FLT_RADIX__", "2"); + defineMacro("__FPCLASS_NEGINF", "0x0004"); + defineMacro("__FPCLASS_NEGNORMAL", "0x0008"); + defineMacro("__FPCLASS_NEGSUBNORMAL", "0x0010"); + defineMacro("__FPCLASS_NEGZERO", "0x0020"); + defineMacro("__FPCLASS_POSINF", "0x0200"); + defineMacro("__FPCLASS_POSNORMAL", "0x0100"); + defineMacro("__FPCLASS_POSSUBNORMAL", "0x0080"); + defineMacro("__FPCLASS_POSZERO", "0x0040"); + defineMacro("__FPCLASS_QNAN", "0x0002"); + defineMacro("__FPCLASS_SNAN", "0x0001"); + defineMacro("__GCC_CONSTRUCTIVE_SIZE", "64"); + defineMacro("__GCC_DESTRUCTIVE_SIZE", "64"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1", "1"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2", "1"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4", "1"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8", "1"); + defineMacro("__INT16_C(c)", "c"); + defineMacro("__INT16_C_SUFFIX__", ""); + defineMacro("__INT16_FMTd__", "\"hd\""); + defineMacro("__INT16_FMTi__", "\"hi\""); + defineMacro("__INT16_MAX__", "32767"); + defineMacro("__INT16_TYPE__", "short"); + defineMacro("__INT32_C(c)", "c"); + defineMacro("__INT32_C_SUFFIX__", ""); + defineMacro("__INT32_FMTd__", "\"d\""); + defineMacro("__INT32_FMTi__", "\"i\""); + defineMacro("__INT32_MAX__", "2147483647"); + defineMacro("__INT32_TYPE__", "int"); + defineMacro("__INT8_C(c)", "c"); + defineMacro("__INT8_C_SUFFIX__", ""); + defineMacro("__INT8_FMTd__", "\"hhd\""); + defineMacro("__INT8_FMTi__", "\"hhi\""); + defineMacro("__INT8_MAX__", "127"); + defineMacro("__INT8_TYPE__", "signed char"); + defineMacro("__INTMAX_WIDTH__", "64"); + defineMacro("__INT_FAST16_FMTd__", "\"hd\""); + defineMacro("__INT_FAST16_FMTi__", "\"hi\""); + defineMacro("__INT_FAST16_MAX__", "32767"); + defineMacro("__INT_FAST16_TYPE__", "short"); + defineMacro("__INT_FAST16_WIDTH__", "16"); + defineMacro("__INT_FAST32_FMTd__", "\"d\""); + defineMacro("__INT_FAST32_FMTi__", "\"i\""); + defineMacro("__INT_FAST32_MAX__", "2147483647"); + defineMacro("__INT_FAST32_TYPE__", "int"); + defineMacro("__INT_FAST32_WIDTH__", "32"); + defineMacro("__INT_FAST64_WIDTH__", "64"); + defineMacro("__INT_FAST8_FMTd__", "\"hhd\""); + defineMacro("__INT_FAST8_FMTi__", "\"hhi\""); + defineMacro("__INT_FAST8_MAX__", "127"); + defineMacro("__INT_FAST8_TYPE__", "signed char"); + defineMacro("__INT_FAST8_WIDTH__", "8"); + defineMacro("__INT_LEAST16_FMTd__", "\"hd\""); + defineMacro("__INT_LEAST16_FMTi__", "\"hi\""); + defineMacro("__INT_LEAST16_MAX__", "32767"); + defineMacro("__INT_LEAST16_TYPE__", "short"); + defineMacro("__INT_LEAST16_WIDTH__", "16"); + defineMacro("__INT_LEAST32_FMTd__", "\"d\""); + defineMacro("__INT_LEAST32_FMTi__", "\"i\""); + defineMacro("__INT_LEAST32_MAX__", "2147483647"); + defineMacro("__INT_LEAST32_TYPE__", "int"); + defineMacro("__INT_LEAST32_WIDTH__", "32"); + defineMacro("__INT_LEAST64_WIDTH__", "64"); + defineMacro("__INT_LEAST8_FMTd__", "\"hhd\""); + defineMacro("__INT_LEAST8_FMTi__", "\"hhi\""); + defineMacro("__INT_LEAST8_MAX__", "127"); + defineMacro("__INT_LEAST8_TYPE__", "signed char"); + defineMacro("__INT_LEAST8_WIDTH__", "8"); + defineMacro("__INT_MAX__", "2147483647"); + defineMacro("__INT_WIDTH__", "32"); + defineMacro("__LDBL_HAS_DENORM__", "1"); + defineMacro("__LDBL_HAS_INFINITY__", "1"); + defineMacro("__LDBL_HAS_QUIET_NAN__", "1"); + defineMacro("__LITTLE_ENDIAN__", "1"); + defineMacro("__LLONG_WIDTH__", "64"); + defineMacro("__LONG_LONG_MAX__", "9223372036854775807LL"); + defineMacro("__MEMORY_SCOPE_DEVICE", "1"); + defineMacro("__MEMORY_SCOPE_SINGLE", "4"); + defineMacro("__MEMORY_SCOPE_SYSTEM", "0"); + defineMacro("__MEMORY_SCOPE_WRKGRP", "2"); + defineMacro("__MEMORY_SCOPE_WVFRNT", "3"); + defineMacro("__NO_INLINE__", "1"); + defineMacro("__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES", "3"); + defineMacro("__OPENCL_MEMORY_SCOPE_DEVICE", "2"); + defineMacro("__OPENCL_MEMORY_SCOPE_SUB_GROUP", "4"); + defineMacro("__OPENCL_MEMORY_SCOPE_WORK_GROUP", "1"); + defineMacro("__OPENCL_MEMORY_SCOPE_WORK_ITEM", "0"); + defineMacro("__ORDER_BIG_ENDIAN__", "4321"); + defineMacro("__ORDER_LITTLE_ENDIAN__", "1234"); + defineMacro("__ORDER_PDP_ENDIAN__", "3412"); + defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1"); + defineMacro("__SCHAR_MAX__", "127"); + defineMacro("__SHRT_MAX__", "32767"); + defineMacro("__SHRT_WIDTH__", "16"); + defineMacro("__SIG_ATOMIC_WIDTH__", "32"); + defineMacro("__SIZEOF_DOUBLE__", "8"); + defineMacro("__SIZEOF_FLOAT__", "4"); + defineMacro("__SIZEOF_INT128__", "16"); + defineMacro("__SIZEOF_INT__", "4"); + defineMacro("__SIZEOF_LONG_LONG__", "8"); + defineMacro("__SIZEOF_SHORT__", "2"); + defineMacro("__STDC_EMBED_EMPTY__", "2"); + defineMacro("__STDC_EMBED_FOUND__", "1"); + defineMacro("__STDC_EMBED_NOT_FOUND__", "0"); + defineMacro("__STDC_HOSTED__", "1"); + defineMacro("__STDC_UTF_16__", "1"); + defineMacro("__STDC_UTF_32__", "1"); + defineMacro("__UINT16_C(c)", "c"); + defineMacro("__UINT16_C_SUFFIX__", ""); + defineMacro("__UINT16_FMTX__", "\"hX\""); + defineMacro("__UINT16_FMTo__", "\"ho\""); + defineMacro("__UINT16_FMTu__", "\"hu\""); + defineMacro("__UINT16_FMTx__", "\"hx\""); + defineMacro("__UINT16_MAX__", "65535"); + defineMacro("__UINT16_TYPE__", "unsigned short"); + defineMacro("__UINT32_C(c)", "c##U"); + defineMacro("__UINT32_C_SUFFIX__", "U"); + defineMacro("__UINT32_FMTX__", "\"X\""); + defineMacro("__UINT32_FMTo__", "\"o\""); + defineMacro("__UINT32_FMTu__", "\"u\""); + defineMacro("__UINT32_FMTx__", "\"x\""); + defineMacro("__UINT32_MAX__", "4294967295U"); + defineMacro("__UINT32_TYPE__", "unsigned int"); + defineMacro("__UINT8_C(c)", "c"); + defineMacro("__UINT8_C_SUFFIX__", ""); + defineMacro("__UINT8_FMTX__", "\"hhX\""); + defineMacro("__UINT8_FMTo__", "\"hho\""); + defineMacro("__UINT8_FMTu__", "\"hhu\""); + defineMacro("__UINT8_FMTx__", "\"hhx\""); + defineMacro("__UINT8_MAX__", "255"); + defineMacro("__UINT8_TYPE__", "unsigned char"); + defineMacro("__UINTMAX_WIDTH__", "64"); + defineMacro("__UINT_FAST16_FMTX__", "\"hX\""); + defineMacro("__UINT_FAST16_FMTo__", "\"ho\""); + defineMacro("__UINT_FAST16_FMTu__", "\"hu\""); + defineMacro("__UINT_FAST16_FMTx__", "\"hx\""); + defineMacro("__UINT_FAST16_MAX__", "65535"); + defineMacro("__UINT_FAST16_TYPE__", "unsigned short"); + defineMacro("__UINT_FAST32_FMTX__", "\"X\""); + defineMacro("__UINT_FAST32_FMTo__", "\"o\""); + defineMacro("__UINT_FAST32_FMTu__", "\"u\""); + defineMacro("__UINT_FAST32_FMTx__", "\"x\""); + defineMacro("__UINT_FAST32_MAX__", "4294967295U"); + defineMacro("__UINT_FAST32_TYPE__", "unsigned int"); + defineMacro("__UINT_FAST8_FMTX__", "\"hhX\""); + defineMacro("__UINT_FAST8_FMTo__", "\"hho\""); + defineMacro("__UINT_FAST8_FMTu__", "\"hhu\""); + defineMacro("__UINT_FAST8_FMTx__", "\"hhx\""); + defineMacro("__UINT_FAST8_MAX__", "255"); + defineMacro("__UINT_FAST8_TYPE__", "unsigned char"); + defineMacro("__UINT_LEAST16_FMTX__", "\"hX\""); + defineMacro("__UINT_LEAST16_FMTo__", "\"ho\""); + defineMacro("__UINT_LEAST16_FMTu__", "\"hu\""); + defineMacro("__UINT_LEAST16_FMTx__", "\"hx\""); + defineMacro("__UINT_LEAST16_MAX__", "65535"); + defineMacro("__UINT_LEAST16_TYPE__", "unsigned short"); + defineMacro("__UINT_LEAST32_FMTX__", "\"X\""); + defineMacro("__UINT_LEAST32_FMTo__", "\"o\""); + defineMacro("__UINT_LEAST32_FMTu__", "\"u\""); + defineMacro("__UINT_LEAST32_FMTx__", "\"x\""); + defineMacro("__UINT_LEAST32_MAX__", "4294967295U"); + defineMacro("__UINT_LEAST32_TYPE__", "unsigned int"); + defineMacro("__UINT_LEAST8_FMTX__", "\"hhX\""); + defineMacro("__UINT_LEAST8_FMTo__", "\"hho\""); + defineMacro("__UINT_LEAST8_FMTu__", "\"hhu\""); + defineMacro("__UINT_LEAST8_FMTx__", "\"hhx\""); + defineMacro("__UINT_LEAST8_MAX__", "255"); + defineMacro("__UINT_LEAST8_TYPE__", "unsigned char"); + defineMacro("__VERSION__", "\"cxx-frontend\""); + defineMacro("__clang__", "1"); + defineMacro("__clang_literal_encoding__", "\"UTF-8\""); + defineMacro("__clang_major__", "20"); + defineMacro("__clang_minor__", "1"); + defineMacro("__clang_patchlevel__", "8"); + defineMacro("__clang_version__", "\"20.1.8 \""); + defineMacro("__llvm__", "1"); +} + +void Toolchain::addCommonC23Macros() { + defineMacro("__CHAR8_TYPE__", "unsigned char"); + defineMacro("__STDC_VERSION__", "202311L"); + defineMacro("__UINT16_FMTB__", "\"hB\""); + defineMacro("__UINT16_FMTb__", "\"hb\""); + defineMacro("__UINT32_FMTB__", "\"B\""); + defineMacro("__UINT32_FMTb__", "\"b\""); + defineMacro("__UINT8_FMTB__", "\"hhB\""); + defineMacro("__UINT8_FMTb__", "\"hhb\""); + defineMacro("__UINT_FAST16_FMTB__", "\"hB\""); + defineMacro("__UINT_FAST16_FMTb__", "\"hb\""); + defineMacro("__UINT_FAST32_FMTB__", "\"B\""); + defineMacro("__UINT_FAST32_FMTb__", "\"b\""); + defineMacro("__UINT_FAST8_FMTB__", "\"hhB\""); + defineMacro("__UINT_FAST8_FMTb__", "\"hhb\""); + defineMacro("__UINT_LEAST16_FMTB__", "\"hB\""); + defineMacro("__UINT_LEAST16_FMTb__", "\"hb\""); + defineMacro("__UINT_LEAST32_FMTB__", "\"B\""); + defineMacro("__UINT_LEAST32_FMTb__", "\"b\""); + defineMacro("__UINT_LEAST8_FMTB__", "\"hhB\""); + defineMacro("__UINT_LEAST8_FMTb__", "\"hhb\""); +} + +void Toolchain::addCommonCxx26Macros() { + defineMacro("__DEPRECATED", "1"); + defineMacro("__cplusplus", "202400L"); + defineMacro("__cpp_aggregate_bases", "201603L"); + defineMacro("__cpp_aggregate_nsdmi", "201304L"); + defineMacro("__cpp_aggregate_paren_init", "201902L"); + defineMacro("__cpp_alias_templates", "200704L"); + defineMacro("__cpp_aligned_new", "201606L"); + defineMacro("__cpp_attributes", "200809L"); + defineMacro("__cpp_auto_cast", "202110L"); + defineMacro("__cpp_binary_literals", "201304L"); + defineMacro("__cpp_capture_star_this", "201603L"); + defineMacro("__cpp_char8_t", "202207L"); + defineMacro("__cpp_concepts", "202002"); + defineMacro("__cpp_conditional_explicit", "201806L"); + defineMacro("__cpp_consteval", "202211L"); + defineMacro("__cpp_constexpr", "202406L"); + defineMacro("__cpp_constexpr_dynamic_alloc", "201907L"); + defineMacro("__cpp_constexpr_in_decltype", "201711L"); + defineMacro("__cpp_constinit", "201907L"); + defineMacro("__cpp_decltype", "200707L"); + defineMacro("__cpp_decltype_auto", "201304L"); + defineMacro("__cpp_deduction_guides", "201703L"); + defineMacro("__cpp_delegating_constructors", "200604L"); + defineMacro("__cpp_deleted_function", "202403L"); + defineMacro("__cpp_designated_initializers", "201707L"); + defineMacro("__cpp_digit_separators", "201309L"); + defineMacro("__cpp_enumerator_attributes", "201411L"); + defineMacro("__cpp_exceptions", "199711L"); + defineMacro("__cpp_explicit_this_parameter", "202110L"); + defineMacro("__cpp_fold_expressions", "201603L"); + defineMacro("__cpp_generic_lambdas", "201707L"); + defineMacro("__cpp_guaranteed_copy_elision", "201606L"); + defineMacro("__cpp_hex_float", "201603L"); + defineMacro("__cpp_if_consteval", "202106L"); + defineMacro("__cpp_if_constexpr", "201606L"); + defineMacro("__cpp_impl_coroutine", "201902L"); + defineMacro("__cpp_impl_destroying_delete", "201806L"); + defineMacro("__cpp_impl_three_way_comparison", "201907L"); + defineMacro("__cpp_implicit_move", "202207L"); + defineMacro("__cpp_inheriting_constructors", "201511L"); + defineMacro("__cpp_init_captures", "201803L"); + defineMacro("__cpp_initializer_lists", "200806L"); + defineMacro("__cpp_inline_variables", "201606L"); + defineMacro("__cpp_lambdas", "200907L"); + defineMacro("__cpp_multidimensional_subscript", "202211L"); + defineMacro("__cpp_named_character_escapes", "202207L"); + defineMacro("__cpp_namespace_attributes", "201411L"); + defineMacro("__cpp_nested_namespace_definitions", "201411L"); + defineMacro("__cpp_noexcept_function_type", "201510L"); + defineMacro("__cpp_nontype_template_args", "201411L"); + defineMacro("__cpp_nontype_template_parameter_auto", "201606L"); + defineMacro("__cpp_nsdmi", "200809L"); + defineMacro("__cpp_pack_indexing", "202311L"); + defineMacro("__cpp_placeholder_variables", "202306L"); + defineMacro("__cpp_range_based_for", "202211L"); + defineMacro("__cpp_raw_strings", "200710L"); + defineMacro("__cpp_ref_qualifiers", "200710L"); + defineMacro("__cpp_return_type_deduction", "201304L"); + defineMacro("__cpp_rtti", "199711L"); + defineMacro("__cpp_rvalue_references", "200610L"); + defineMacro("__cpp_size_t_suffix", "202011L"); + defineMacro("__cpp_sized_deallocation", "201309L"); + defineMacro("__cpp_static_assert", "202306L"); + defineMacro("__cpp_static_call_operator", "202207L"); + defineMacro("__cpp_structured_bindings", "202403L"); + defineMacro("__cpp_template_auto", "201606L"); + defineMacro("__cpp_template_template_args", "201611L"); + defineMacro("__cpp_unicode_characters", "200704L"); + defineMacro("__cpp_unicode_literals", "200710L"); + defineMacro("__cpp_user_defined_literals", "200809L"); + defineMacro("__cpp_using_enum", "201907L"); + defineMacro("__cpp_variable_templates", "201304L"); + defineMacro("__cpp_variadic_friend", "202403L"); + defineMacro("__cpp_variadic_templates", "200704L"); + defineMacro("__cpp_variadic_using", "201611L"); +} + +void Toolchain::addCommonLinuxMacros() { + defineMacro("_LP64", "1"); + defineMacro("__BIGGEST_ALIGNMENT__", "16"); + defineMacro("__ELF__", "1"); + defineMacro("__FLT16_DECIMAL_DIG__", "5"); + defineMacro("__FLT16_DENORM_MIN__", "5.9604644775390625e-8F16"); + defineMacro("__FLT16_DIG__", "3"); + defineMacro("__FLT16_EPSILON__", "9.765625e-4F16"); + defineMacro("__FLT16_HAS_DENORM__", "1"); + defineMacro("__FLT16_HAS_INFINITY__", "1"); + defineMacro("__FLT16_HAS_QUIET_NAN__", "1"); + defineMacro("__FLT16_MANT_DIG__", "11"); + defineMacro("__FLT16_MAX_10_EXP__", "4"); + defineMacro("__FLT16_MAX_EXP__", "16"); + defineMacro("__FLT16_MAX__", "6.5504e+4F16"); + defineMacro("__FLT16_MIN_10_EXP__", "(-4)"); + defineMacro("__FLT16_MIN_EXP__", "(-13)"); + defineMacro("__FLT16_MIN__", "6.103515625e-5F16"); + defineMacro("__FLT16_NORM_MAX__", "6.5504e+4F16"); + defineMacro("__GCC_ASM_FLAG_OUTPUTS__", "1"); + defineMacro("__GCC_ATOMIC_BOOL_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR16_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR32_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR8_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_INT_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_LLONG_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_LONG_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_SHORT_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1"); + defineMacro("__GCC_ATOMIC_WCHAR_T_LOCK_FREE", "2"); + defineMacro("__GCC_HAVE_DWARF2_CFI_ASM", "1"); + defineMacro("__GNUC_MINOR__", "2"); + defineMacro("__GNUC_PATCHLEVEL__", "1"); + defineMacro("__GNUC__", "4"); + defineMacro("__GXX_ABI_VERSION", "1002"); + defineMacro("__INT64_C(c)", "c##L"); + defineMacro("__INT64_C_SUFFIX__", "L"); + defineMacro("__INT64_FMTd__", "\"ld\""); + defineMacro("__INT64_FMTi__", "\"li\""); + defineMacro("__INT64_MAX__", "9223372036854775807L"); + defineMacro("__INT64_TYPE__", "long int"); + defineMacro("__INTMAX_C(c)", "c##L"); + defineMacro("__INTMAX_C_SUFFIX__", "L"); + defineMacro("__INTMAX_FMTd__", "\"ld\""); + defineMacro("__INTMAX_FMTi__", "\"li\""); + defineMacro("__INTMAX_MAX__", "9223372036854775807L"); + defineMacro("__INTMAX_TYPE__", "long int"); + defineMacro("__INTPTR_FMTd__", "\"ld\""); + defineMacro("__INTPTR_FMTi__", "\"li\""); + defineMacro("__INTPTR_MAX__", "9223372036854775807L"); + defineMacro("__INTPTR_TYPE__", "long int"); + defineMacro("__INTPTR_WIDTH__", "64"); + defineMacro("__INT_FAST64_FMTd__", "\"ld\""); + defineMacro("__INT_FAST64_FMTi__", "\"li\""); + defineMacro("__INT_FAST64_MAX__", "9223372036854775807L"); + defineMacro("__INT_FAST64_TYPE__", "long int"); + defineMacro("__INT_LEAST64_FMTd__", "\"ld\""); + defineMacro("__INT_LEAST64_FMTi__", "\"li\""); + defineMacro("__INT_LEAST64_MAX__", "9223372036854775807L"); + defineMacro("__INT_LEAST64_TYPE__", "long int"); + defineMacro("__LDBL_MAX_10_EXP__", "4932"); + defineMacro("__LDBL_MAX_EXP__", "16384"); + defineMacro("__LDBL_MIN_10_EXP__", "(-4931)"); + defineMacro("__LDBL_MIN_EXP__", "(-16381)"); + defineMacro("__LONG_MAX__", "9223372036854775807L"); + defineMacro("__LONG_WIDTH__", "64"); + defineMacro("__LP64__", "1"); + defineMacro("__OBJC_BOOL_IS_BOOL", "0"); + defineMacro("__PIC__", "2"); + defineMacro("__PIE__", "2"); + defineMacro("__POINTER_WIDTH__", "64"); + defineMacro("__PTRDIFF_FMTd__", "\"ld\""); + defineMacro("__PTRDIFF_FMTi__", "\"li\""); + defineMacro("__PTRDIFF_MAX__", "9223372036854775807L"); + defineMacro("__PTRDIFF_TYPE__", "long int"); + defineMacro("__PTRDIFF_WIDTH__", "64"); + defineMacro("__SIG_ATOMIC_MAX__", "2147483647"); + defineMacro("__SIZEOF_LONG_DOUBLE__", "16"); + defineMacro("__SIZEOF_LONG__", "8"); + defineMacro("__SIZEOF_POINTER__", "8"); + defineMacro("__SIZEOF_PTRDIFF_T__", "8"); + defineMacro("__SIZEOF_SIZE_T__", "8"); + defineMacro("__SIZEOF_WCHAR_T__", "4"); + defineMacro("__SIZEOF_WINT_T__", "4"); + defineMacro("__SIZE_FMTX__", "\"lX\""); + defineMacro("__SIZE_FMTo__", "\"lo\""); + defineMacro("__SIZE_FMTu__", "\"lu\""); + defineMacro("__SIZE_FMTx__", "\"lx\""); + defineMacro("__SIZE_MAX__", "18446744073709551615UL"); + defineMacro("__SIZE_TYPE__", "long unsigned int"); + defineMacro("__SIZE_WIDTH__", "64"); + defineMacro("__STDC__", "1"); + defineMacro("__STRICT_ANSI__", "1"); + defineMacro("__UINT64_C(c)", "c##UL"); + defineMacro("__UINT64_C_SUFFIX__", "UL"); + defineMacro("__UINT64_FMTX__", "\"lX\""); + defineMacro("__UINT64_FMTo__", "\"lo\""); + defineMacro("__UINT64_FMTu__", "\"lu\""); + defineMacro("__UINT64_FMTx__", "\"lx\""); + defineMacro("__UINT64_MAX__", "18446744073709551615UL"); + defineMacro("__UINT64_TYPE__", "long unsigned int"); + defineMacro("__UINTMAX_C(c)", "c##UL"); + defineMacro("__UINTMAX_C_SUFFIX__", "UL"); + defineMacro("__UINTMAX_FMTX__", "\"lX\""); + defineMacro("__UINTMAX_FMTo__", "\"lo\""); + defineMacro("__UINTMAX_FMTu__", "\"lu\""); + defineMacro("__UINTMAX_FMTx__", "\"lx\""); + defineMacro("__UINTMAX_MAX__", "18446744073709551615UL"); + defineMacro("__UINTMAX_TYPE__", "long unsigned int"); + defineMacro("__UINTPTR_FMTX__", "\"lX\""); + defineMacro("__UINTPTR_FMTo__", "\"lo\""); + defineMacro("__UINTPTR_FMTu__", "\"lu\""); + defineMacro("__UINTPTR_FMTx__", "\"lx\""); + defineMacro("__UINTPTR_MAX__", "18446744073709551615UL"); + defineMacro("__UINTPTR_TYPE__", "long unsigned int"); + defineMacro("__UINTPTR_WIDTH__", "64"); + defineMacro("__UINT_FAST64_FMTX__", "\"lX\""); + defineMacro("__UINT_FAST64_FMTo__", "\"lo\""); + defineMacro("__UINT_FAST64_FMTu__", "\"lu\""); + defineMacro("__UINT_FAST64_FMTx__", "\"lx\""); + defineMacro("__UINT_FAST64_MAX__", "18446744073709551615UL"); + defineMacro("__UINT_FAST64_TYPE__", "long unsigned int"); + defineMacro("__UINT_LEAST64_FMTX__", "\"lX\""); + defineMacro("__UINT_LEAST64_FMTo__", "\"lo\""); + defineMacro("__UINT_LEAST64_FMTu__", "\"lu\""); + defineMacro("__UINT_LEAST64_FMTx__", "\"lx\""); + defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615UL"); + defineMacro("__UINT_LEAST64_TYPE__", "long unsigned int"); + defineMacro("__USER_LABEL_PREFIX__", ""); + defineMacro("__WCHAR_WIDTH__", "32"); + defineMacro("__WINT_MAX__", "4294967295U"); + defineMacro("__WINT_TYPE__", "unsigned int"); + defineMacro("__WINT_UNSIGNED__", "1"); + defineMacro("__WINT_WIDTH__", "32"); + defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\""); + defineMacro("__gnu_linux__", "1"); + defineMacro("__linux", "1"); + defineMacro("__linux__", "1"); + defineMacro("__pic__", "2"); + defineMacro("__pie__", "2"); + defineMacro("__unix", "1"); + defineMacro("__unix__", "1"); +} + +void Toolchain::addCommonMacOSMacros() { + defineMacro("TARGET_IPHONE_SIMULATOR", "0"); + defineMacro("TARGET_OS_DRIVERKIT", "0"); + defineMacro("TARGET_OS_EMBEDDED", "0"); + defineMacro("TARGET_OS_IOS", "0"); + defineMacro("TARGET_OS_IPHONE", "0"); + defineMacro("TARGET_OS_LINUX", "0"); + defineMacro("TARGET_OS_MAC", "1"); + defineMacro("TARGET_OS_MACCATALYST", "0"); + defineMacro("TARGET_OS_NANO", "0"); + defineMacro("TARGET_OS_OSX", "1"); + defineMacro("TARGET_OS_SIMULATOR", "0"); + defineMacro("TARGET_OS_TV", "0"); + defineMacro("TARGET_OS_UIKITFORMAC", "0"); + defineMacro("TARGET_OS_UNIX", "0"); + defineMacro("TARGET_OS_VISION", "0"); + defineMacro("TARGET_OS_WATCH", "0"); + defineMacro("TARGET_OS_WIN32", "0"); + defineMacro("TARGET_OS_WINDOWS", "0"); + defineMacro("_LP64", "1"); + defineMacro("__APPLE_CC__", "6000"); + defineMacro("__APPLE__", "1"); + defineMacro("__DYNAMIC__", "1"); + defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", "150000"); + defineMacro("__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__", "150000"); + defineMacro("__FLT16_DECIMAL_DIG__", "5"); + defineMacro("__FLT16_DENORM_MIN__", "5.9604644775390625e-8F16"); + defineMacro("__FLT16_DIG__", "3"); + defineMacro("__FLT16_EPSILON__", "9.765625e-4F16"); + defineMacro("__FLT16_HAS_DENORM__", "1"); + defineMacro("__FLT16_HAS_INFINITY__", "1"); + defineMacro("__FLT16_HAS_QUIET_NAN__", "1"); + defineMacro("__FLT16_MANT_DIG__", "11"); + defineMacro("__FLT16_MAX_10_EXP__", "4"); + defineMacro("__FLT16_MAX_EXP__", "16"); + defineMacro("__FLT16_MAX__", "6.5504e+4F16"); + defineMacro("__FLT16_MIN_10_EXP__", "(-4)"); + defineMacro("__FLT16_MIN_EXP__", "(-13)"); + defineMacro("__FLT16_MIN__", "6.103515625e-5F16"); + defineMacro("__FLT16_NORM_MAX__", "6.5504e+4F16"); + defineMacro("__GCC_ASM_FLAG_OUTPUTS__", "1"); + defineMacro("__GCC_ATOMIC_BOOL_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR16_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR32_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR8_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_INT_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_LLONG_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_LONG_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_SHORT_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1"); + defineMacro("__GCC_ATOMIC_WCHAR_T_LOCK_FREE", "2"); + defineMacro("__GCC_HAVE_DWARF2_CFI_ASM", "1"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16", "1"); + defineMacro("__GNUC_MINOR__", "2"); + defineMacro("__GNUC_PATCHLEVEL__", "1"); + defineMacro("__GNUC__", "4"); + defineMacro("__GXX_ABI_VERSION", "1002"); + defineMacro("__INT64_C(c)", "c##LL"); + defineMacro("__INT64_C_SUFFIX__", "LL"); + defineMacro("__INT64_FMTd__", "\"lld\""); + defineMacro("__INT64_FMTi__", "\"lli\""); + defineMacro("__INT64_MAX__", "9223372036854775807LL"); + defineMacro("__INT64_TYPE__", "long long int"); + defineMacro("__INTMAX_C(c)", "c##L"); + defineMacro("__INTMAX_C_SUFFIX__", "L"); + defineMacro("__INTMAX_FMTd__", "\"ld\""); + defineMacro("__INTMAX_FMTi__", "\"li\""); + defineMacro("__INTMAX_MAX__", "9223372036854775807L"); + defineMacro("__INTMAX_TYPE__", "long int"); + defineMacro("__INTPTR_FMTd__", "\"ld\""); + defineMacro("__INTPTR_FMTi__", "\"li\""); + defineMacro("__INTPTR_MAX__", "9223372036854775807L"); + defineMacro("__INTPTR_TYPE__", "long int"); + defineMacro("__INTPTR_WIDTH__", "64"); + defineMacro("__INT_FAST64_FMTd__", "\"lld\""); + defineMacro("__INT_FAST64_FMTi__", "\"lli\""); + defineMacro("__INT_FAST64_MAX__", "9223372036854775807LL"); + defineMacro("__INT_FAST64_TYPE__", "long long int"); + defineMacro("__INT_LEAST64_FMTd__", "\"lld\""); + defineMacro("__INT_LEAST64_FMTi__", "\"lli\""); + defineMacro("__INT_LEAST64_MAX__", "9223372036854775807LL"); + defineMacro("__INT_LEAST64_TYPE__", "long long int"); + defineMacro("__LONG_MAX__", "9223372036854775807L"); + defineMacro("__LONG_WIDTH__", "64"); + defineMacro("__LP64__", "1"); + defineMacro("__MACH__", "1"); + defineMacro("__NO_MATH_ERRNO__", "1"); + defineMacro("__PIC__", "2"); + defineMacro("__POINTER_WIDTH__", "64"); + defineMacro("__PTRDIFF_FMTd__", "\"ld\""); + defineMacro("__PTRDIFF_FMTi__", "\"li\""); + defineMacro("__PTRDIFF_MAX__", "9223372036854775807L"); + defineMacro("__PTRDIFF_TYPE__", "long int"); + defineMacro("__PTRDIFF_WIDTH__", "64"); + defineMacro("__REGISTER_PREFIX__", ""); + defineMacro("__SIG_ATOMIC_MAX__", "2147483647"); + defineMacro("__SIZEOF_LONG__", "8"); + defineMacro("__SIZEOF_POINTER__", "8"); + defineMacro("__SIZEOF_PTRDIFF_T__", "8"); + defineMacro("__SIZEOF_SIZE_T__", "8"); + defineMacro("__SIZEOF_WCHAR_T__", "4"); + defineMacro("__SIZEOF_WINT_T__", "4"); + defineMacro("__SIZE_FMTX__", "\"lX\""); + defineMacro("__SIZE_FMTo__", "\"lo\""); + defineMacro("__SIZE_FMTu__", "\"lu\""); + defineMacro("__SIZE_FMTx__", "\"lx\""); + defineMacro("__SIZE_MAX__", "18446744073709551615UL"); + defineMacro("__SIZE_TYPE__", "long unsigned int"); + defineMacro("__SIZE_WIDTH__", "64"); + defineMacro("__SSP__", "1"); + defineMacro("__STDC_NO_THREADS__", "1"); + defineMacro("__STDC__", "1"); + defineMacro("__STRICT_ANSI__", "1"); + defineMacro("__UINT64_C(c)", "c##ULL"); + defineMacro("__UINT64_C_SUFFIX__", "ULL"); + defineMacro("__UINT64_FMTX__", "\"llX\""); + defineMacro("__UINT64_FMTo__", "\"llo\""); + defineMacro("__UINT64_FMTu__", "\"llu\""); + defineMacro("__UINT64_FMTx__", "\"llx\""); + defineMacro("__UINT64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT64_TYPE__", "long long unsigned int"); + defineMacro("__UINTMAX_C(c)", "c##UL"); + defineMacro("__UINTMAX_C_SUFFIX__", "UL"); + defineMacro("__UINTMAX_FMTX__", "\"lX\""); + defineMacro("__UINTMAX_FMTo__", "\"lo\""); + defineMacro("__UINTMAX_FMTu__", "\"lu\""); + defineMacro("__UINTMAX_FMTx__", "\"lx\""); + defineMacro("__UINTMAX_MAX__", "18446744073709551615UL"); + defineMacro("__UINTMAX_TYPE__", "long unsigned int"); + defineMacro("__UINTPTR_FMTX__", "\"lX\""); + defineMacro("__UINTPTR_FMTo__", "\"lo\""); + defineMacro("__UINTPTR_FMTu__", "\"lu\""); + defineMacro("__UINTPTR_FMTx__", "\"lx\""); + defineMacro("__UINTPTR_MAX__", "18446744073709551615UL"); + defineMacro("__UINTPTR_TYPE__", "long unsigned int"); + defineMacro("__UINTPTR_WIDTH__", "64"); + defineMacro("__UINT_FAST64_FMTX__", "\"llX\""); + defineMacro("__UINT_FAST64_FMTo__", "\"llo\""); + defineMacro("__UINT_FAST64_FMTu__", "\"llu\""); + defineMacro("__UINT_FAST64_FMTx__", "\"llx\""); + defineMacro("__UINT_FAST64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT_FAST64_TYPE__", "long long unsigned int"); + defineMacro("__UINT_LEAST64_FMTX__", "\"llX\""); + defineMacro("__UINT_LEAST64_FMTo__", "\"llo\""); + defineMacro("__UINT_LEAST64_FMTu__", "\"llu\""); + defineMacro("__UINT_LEAST64_FMTx__", "\"llx\""); + defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT_LEAST64_TYPE__", "long long unsigned int"); + defineMacro("__USER_LABEL_PREFIX__", "_"); + defineMacro("__WCHAR_MAX__", "2147483647"); + defineMacro("__WCHAR_TYPE__", "int"); + defineMacro("__WCHAR_WIDTH__", "32"); + defineMacro("__WINT_MAX__", "2147483647"); + defineMacro("__WINT_TYPE__", "int"); + defineMacro("__WINT_WIDTH__", "32"); + defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\""); + defineMacro("__nonnull", "_Nonnull"); + defineMacro("__null_unspecified", "_Null_unspecified"); + defineMacro("__nullable", "_Nullable"); + defineMacro("__pic__", "2"); + defineMacro("__strong", ""); + defineMacro("__unsafe_unretained", ""); + defineMacro("__weak", "__attribute__((objc_gc(weak)))"); +} + +void Toolchain::addCommonWindowsMacros() { + defineMacro("_INTEGRAL_MAX_BITS", "64"); + defineMacro("_MSC_BUILD", "1"); + defineMacro("_MSC_EXTENSIONS", "1"); + defineMacro("_MSC_FULL_VER", "193300000"); + defineMacro("_MSC_VER", "1933"); + defineMacro("_MSVC_CONSTEXPR_ATTRIBUTE", "1"); + defineMacro("_MSVC_EXECUTION_CHARACTER_SET", "65001"); + defineMacro("_M_FP_CONTRACT", "1"); + defineMacro("_M_FP_PRECISE", "1"); + defineMacro("_WIN32", "1"); + defineMacro("_WIN64", "1"); + defineMacro("__BIGGEST_ALIGNMENT__", "16"); + defineMacro("__BOOL_DEFINED", "1"); + defineMacro("__FLT16_DECIMAL_DIG__", "5"); + defineMacro("__FLT16_DENORM_MIN__", "5.9604644775390625e-8F16"); + defineMacro("__FLT16_DIG__", "3"); + defineMacro("__FLT16_EPSILON__", "9.765625e-4F16"); + defineMacro("__FLT16_HAS_DENORM__", "1"); + defineMacro("__FLT16_HAS_INFINITY__", "1"); + defineMacro("__FLT16_HAS_QUIET_NAN__", "1"); + defineMacro("__FLT16_MANT_DIG__", "11"); + defineMacro("__FLT16_MAX_10_EXP__", "4"); + defineMacro("__FLT16_MAX_EXP__", "16"); + defineMacro("__FLT16_MAX__", "6.5504e+4F16"); + defineMacro("__FLT16_MIN_10_EXP__", "(-4)"); + defineMacro("__FLT16_MIN_EXP__", "(-13)"); + defineMacro("__FLT16_MIN__", "6.103515625e-5F16"); + defineMacro("__FLT16_NORM_MAX__", "6.5504e+4F16"); + defineMacro("__GCC_ASM_FLAG_OUTPUTS__", "1"); + defineMacro("__INT64_C(c)", "c##LL"); + defineMacro("__INT64_C_SUFFIX__", "LL"); + defineMacro("__INT64_FMTd__", "\"lld\""); + defineMacro("__INT64_FMTi__", "\"lli\""); + defineMacro("__INT64_MAX__", "9223372036854775807LL"); + defineMacro("__INT64_TYPE__", "long long int"); + defineMacro("__INTMAX_C(c)", "c##LL"); + defineMacro("__INTMAX_C_SUFFIX__", "LL"); + defineMacro("__INTMAX_FMTd__", "\"lld\""); + defineMacro("__INTMAX_FMTi__", "\"lli\""); + defineMacro("__INTMAX_MAX__", "9223372036854775807LL"); + defineMacro("__INTMAX_TYPE__", "long long int"); + defineMacro("__INTPTR_FMTd__", "\"lld\""); + defineMacro("__INTPTR_FMTi__", "\"lli\""); + defineMacro("__INTPTR_MAX__", "9223372036854775807LL"); + defineMacro("__INTPTR_TYPE__", "long long int"); + defineMacro("__INTPTR_WIDTH__", "64"); + defineMacro("__INT_FAST64_FMTd__", "\"lld\""); + defineMacro("__INT_FAST64_FMTi__", "\"lli\""); + defineMacro("__INT_FAST64_MAX__", "9223372036854775807LL"); + defineMacro("__INT_FAST64_TYPE__", "long long int"); + defineMacro("__INT_LEAST64_FMTd__", "\"lld\""); + defineMacro("__INT_LEAST64_FMTi__", "\"lli\""); + defineMacro("__INT_LEAST64_MAX__", "9223372036854775807LL"); + defineMacro("__INT_LEAST64_TYPE__", "long long int"); + defineMacro("__LDBL_DECIMAL_DIG__", "17"); + defineMacro("__LDBL_DENORM_MIN__", "4.9406564584124654e-324L"); + defineMacro("__LDBL_DIG__", "15"); + defineMacro("__LDBL_EPSILON__", "2.2204460492503131e-16L"); + defineMacro("__LDBL_MANT_DIG__", "53"); + defineMacro("__LDBL_MAX_10_EXP__", "308"); + defineMacro("__LDBL_MAX_EXP__", "1024"); + defineMacro("__LDBL_MAX__", "1.7976931348623157e+308L"); + defineMacro("__LDBL_MIN_10_EXP__", "(-307)"); + defineMacro("__LDBL_MIN_EXP__", "(-1021)"); + defineMacro("__LDBL_MIN__", "2.2250738585072014e-308L"); + defineMacro("__LDBL_NORM_MAX__", "1.7976931348623157e+308L"); + defineMacro("__LONG_MAX__", "2147483647L"); + defineMacro("__LONG_WIDTH__", "32"); + defineMacro("__OBJC_BOOL_IS_BOOL", "0"); + defineMacro("__PIC__", "2"); + defineMacro("__POINTER_WIDTH__", "64"); + defineMacro("__PTRDIFF_FMTd__", "\"lld\""); + defineMacro("__PTRDIFF_FMTi__", "\"lli\""); + defineMacro("__PTRDIFF_MAX__", "9223372036854775807LL"); + defineMacro("__PTRDIFF_TYPE__", "long long int"); + defineMacro("__PTRDIFF_WIDTH__", "64"); + defineMacro("__SIG_ATOMIC_MAX__", "2147483647"); + defineMacro("__SIZEOF_LONG_DOUBLE__", "8"); + defineMacro("__SIZEOF_LONG__", "4"); + defineMacro("__SIZEOF_POINTER__", "8"); + defineMacro("__SIZEOF_PTRDIFF_T__", "8"); + defineMacro("__SIZEOF_SIZE_T__", "8"); + defineMacro("__SIZEOF_WCHAR_T__", "2"); + defineMacro("__SIZEOF_WINT_T__", "2"); + defineMacro("__SIZE_FMTX__", "\"llX\""); + defineMacro("__SIZE_FMTo__", "\"llo\""); + defineMacro("__SIZE_FMTu__", "\"llu\""); + defineMacro("__SIZE_FMTx__", "\"llx\""); + defineMacro("__SIZE_MAX__", "18446744073709551615ULL"); + defineMacro("__SIZE_TYPE__", "long long unsigned int"); + defineMacro("__SIZE_WIDTH__", "64"); + defineMacro("__STDC_NO_THREADS__", "1"); + defineMacro("__UINT64_C(c)", "c##ULL"); + defineMacro("__UINT64_C_SUFFIX__", "ULL"); + defineMacro("__UINT64_FMTX__", "\"llX\""); + defineMacro("__UINT64_FMTo__", "\"llo\""); + defineMacro("__UINT64_FMTu__", "\"llu\""); + defineMacro("__UINT64_FMTx__", "\"llx\""); + defineMacro("__UINT64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT64_TYPE__", "long long unsigned int"); + defineMacro("__UINTMAX_C(c)", "c##ULL"); + defineMacro("__UINTMAX_C_SUFFIX__", "ULL"); + defineMacro("__UINTMAX_FMTX__", "\"llX\""); + defineMacro("__UINTMAX_FMTo__", "\"llo\""); + defineMacro("__UINTMAX_FMTu__", "\"llu\""); + defineMacro("__UINTMAX_FMTx__", "\"llx\""); + defineMacro("__UINTMAX_MAX__", "18446744073709551615ULL"); + defineMacro("__UINTMAX_TYPE__", "long long unsigned int"); + defineMacro("__UINTPTR_FMTX__", "\"llX\""); + defineMacro("__UINTPTR_FMTo__", "\"llo\""); + defineMacro("__UINTPTR_FMTu__", "\"llu\""); + defineMacro("__UINTPTR_FMTx__", "\"llx\""); + defineMacro("__UINTPTR_MAX__", "18446744073709551615ULL"); + defineMacro("__UINTPTR_TYPE__", "long long unsigned int"); + defineMacro("__UINTPTR_WIDTH__", "64"); + defineMacro("__UINT_FAST64_FMTX__", "\"llX\""); + defineMacro("__UINT_FAST64_FMTo__", "\"llo\""); + defineMacro("__UINT_FAST64_FMTu__", "\"llu\""); + defineMacro("__UINT_FAST64_FMTx__", "\"llx\""); + defineMacro("__UINT_FAST64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT_FAST64_TYPE__", "long long unsigned int"); + defineMacro("__UINT_LEAST64_FMTX__", "\"llX\""); + defineMacro("__UINT_LEAST64_FMTo__", "\"llo\""); + defineMacro("__UINT_LEAST64_FMTu__", "\"llu\""); + defineMacro("__UINT_LEAST64_FMTx__", "\"llx\""); + defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT_LEAST64_TYPE__", "long long unsigned int"); + defineMacro("__USER_LABEL_PREFIX__", ""); + defineMacro("__WCHAR_MAX__", "65535"); + defineMacro("__WCHAR_TYPE__", "unsigned short"); + defineMacro("__WCHAR_UNSIGNED__", "1"); + defineMacro("__WCHAR_WIDTH__", "16"); + defineMacro("__WINT_MAX__", "65535"); + defineMacro("__WINT_TYPE__", "unsigned short"); + defineMacro("__WINT_UNSIGNED__", "1"); + defineMacro("__WINT_WIDTH__", "16"); + defineMacro("__clang_wide_literal_encoding__", "\"UTF-16\""); + defineMacro("__pic__", "2"); +} + +void Toolchain::addCommonWASIMacros() { + defineMacro("_ILP32", "1"); + defineMacro("__BIGGEST_ALIGNMENT__", "16"); + defineMacro("__BITINT_MAXWIDTH__", "128"); + defineMacro("__FLOAT128__", "1"); + defineMacro("__GCC_ATOMIC_BOOL_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR16_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR32_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR8_T_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_CHAR_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_INT_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_LLONG_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_LONG_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_SHORT_LOCK_FREE", "2"); + defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1"); + defineMacro("__GCC_ATOMIC_WCHAR_T_LOCK_FREE", "2"); + defineMacro("__GNUC_MINOR__", "2"); + defineMacro("__GNUC_PATCHLEVEL__", "1"); + defineMacro("__GNUC__", "4"); + defineMacro("__GXX_ABI_VERSION", "1002"); + defineMacro("__ILP32__", "1"); + defineMacro("__INT64_C(c)", "c##LL"); + defineMacro("__INT64_C_SUFFIX__", "LL"); + defineMacro("__INT64_FMTd__", "\"lld\""); + defineMacro("__INT64_FMTi__", "\"lli\""); + defineMacro("__INT64_MAX__", "9223372036854775807LL"); + defineMacro("__INT64_TYPE__", "long long int"); + defineMacro("__INTMAX_C(c)", "c##LL"); + defineMacro("__INTMAX_C_SUFFIX__", "LL"); + defineMacro("__INTMAX_FMTd__", "\"lld\""); + defineMacro("__INTMAX_FMTi__", "\"lli\""); + defineMacro("__INTMAX_MAX__", "9223372036854775807LL"); + defineMacro("__INTMAX_TYPE__", "long long int"); + defineMacro("__INTPTR_FMTd__", "\"ld\""); + defineMacro("__INTPTR_FMTi__", "\"li\""); + defineMacro("__INTPTR_MAX__", "2147483647L"); + defineMacro("__INTPTR_TYPE__", "long int"); + defineMacro("__INTPTR_WIDTH__", "32"); + defineMacro("__INT_FAST64_FMTd__", "\"lld\""); + defineMacro("__INT_FAST64_FMTi__", "\"lli\""); + defineMacro("__INT_FAST64_MAX__", "9223372036854775807LL"); + defineMacro("__INT_FAST64_TYPE__", "long long int"); + defineMacro("__INT_LEAST64_FMTd__", "\"lld\""); + defineMacro("__INT_LEAST64_FMTi__", "\"lli\""); + defineMacro("__INT_LEAST64_MAX__", "9223372036854775807LL"); + defineMacro("__INT_LEAST64_TYPE__", "long long int"); + defineMacro("__LDBL_DECIMAL_DIG__", "36"); + defineMacro("__LDBL_DENORM_MIN__", + "6.47517511943802511092443895822764655e-4966L"); + defineMacro("__LDBL_DIG__", "33"); + defineMacro("__LDBL_EPSILON__", "1.92592994438723585305597794258492732e-34L"); + defineMacro("__LDBL_MANT_DIG__", "113"); + defineMacro("__LDBL_MAX_10_EXP__", "4932"); + defineMacro("__LDBL_MAX_EXP__", "16384"); + defineMacro("__LDBL_MAX__", "1.18973149535723176508575932662800702e+4932L"); + defineMacro("__LDBL_MIN_10_EXP__", "(-4931)"); + defineMacro("__LDBL_MIN_EXP__", "(-16381)"); + defineMacro("__LDBL_MIN__", "3.36210314311209350626267781732175260e-4932L"); + defineMacro("__LDBL_NORM_MAX__", + "1.18973149535723176508575932662800702e+4932L"); + defineMacro("__LONG_MAX__", "2147483647L"); + defineMacro("__LONG_WIDTH__", "32"); + defineMacro("__NO_MATH_ERRNO__", "1"); + defineMacro("__OBJC_BOOL_IS_BOOL", "0"); + defineMacro("__POINTER_WIDTH__", "32"); + defineMacro("__PTRDIFF_FMTd__", "\"ld\""); + defineMacro("__PTRDIFF_FMTi__", "\"li\""); + defineMacro("__PTRDIFF_MAX__", "2147483647L"); + defineMacro("__PTRDIFF_TYPE__", "long int"); + defineMacro("__PTRDIFF_WIDTH__", "32"); + defineMacro("__SIG_ATOMIC_MAX__", "2147483647L"); + defineMacro("__SIZEOF_LONG_DOUBLE__", "16"); + defineMacro("__SIZEOF_LONG__", "4"); + defineMacro("__SIZEOF_POINTER__", "4"); + defineMacro("__SIZEOF_PTRDIFF_T__", "4"); + defineMacro("__SIZEOF_SIZE_T__", "4"); + defineMacro("__SIZEOF_WCHAR_T__", "4"); + defineMacro("__SIZEOF_WINT_T__", "4"); + defineMacro("__SIZE_FMTX__", "\"lX\""); + defineMacro("__SIZE_FMTo__", "\"lo\""); + defineMacro("__SIZE_FMTu__", "\"lu\""); + defineMacro("__SIZE_FMTx__", "\"lx\""); + defineMacro("__SIZE_MAX__", "4294967295UL"); + defineMacro("__SIZE_TYPE__", "long unsigned int"); + defineMacro("__SIZE_WIDTH__", "32"); + defineMacro("__STDC__", "1"); + defineMacro("__STRICT_ANSI__", "1"); + defineMacro("__UINT64_C(c)", "c##ULL"); + defineMacro("__UINT64_C_SUFFIX__", "ULL"); + defineMacro("__UINT64_FMTX__", "\"llX\""); + defineMacro("__UINT64_FMTo__", "\"llo\""); + defineMacro("__UINT64_FMTu__", "\"llu\""); + defineMacro("__UINT64_FMTx__", "\"llx\""); + defineMacro("__UINT64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT64_TYPE__", "long long unsigned int"); + defineMacro("__UINTMAX_C(c)", "c##ULL"); + defineMacro("__UINTMAX_C_SUFFIX__", "ULL"); + defineMacro("__UINTMAX_FMTX__", "\"llX\""); + defineMacro("__UINTMAX_FMTo__", "\"llo\""); + defineMacro("__UINTMAX_FMTu__", "\"llu\""); + defineMacro("__UINTMAX_FMTx__", "\"llx\""); + defineMacro("__UINTMAX_MAX__", "18446744073709551615ULL"); + defineMacro("__UINTMAX_TYPE__", "long long unsigned int"); + defineMacro("__UINTPTR_FMTX__", "\"lX\""); + defineMacro("__UINTPTR_FMTo__", "\"lo\""); + defineMacro("__UINTPTR_FMTu__", "\"lu\""); + defineMacro("__UINTPTR_FMTx__", "\"lx\""); + defineMacro("__UINTPTR_MAX__", "4294967295UL"); + defineMacro("__UINTPTR_TYPE__", "long unsigned int"); + defineMacro("__UINTPTR_WIDTH__", "32"); + defineMacro("__UINT_FAST64_FMTX__", "\"llX\""); + defineMacro("__UINT_FAST64_FMTo__", "\"llo\""); + defineMacro("__UINT_FAST64_FMTu__", "\"llu\""); + defineMacro("__UINT_FAST64_FMTx__", "\"llx\""); + defineMacro("__UINT_FAST64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT_FAST64_TYPE__", "long long unsigned int"); + defineMacro("__UINT_LEAST64_FMTX__", "\"llX\""); + defineMacro("__UINT_LEAST64_FMTo__", "\"llo\""); + defineMacro("__UINT_LEAST64_FMTu__", "\"llu\""); + defineMacro("__UINT_LEAST64_FMTx__", "\"llx\""); + defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615ULL"); + defineMacro("__UINT_LEAST64_TYPE__", "long long unsigned int"); + defineMacro("__USER_LABEL_PREFIX__", ""); + defineMacro("__WCHAR_MAX__", "2147483647"); + defineMacro("__WCHAR_TYPE__", "int"); + defineMacro("__WCHAR_WIDTH__", "32"); + defineMacro("__WINT_MAX__", "2147483647"); + defineMacro("__WINT_TYPE__", "int"); + defineMacro("__WINT_WIDTH__", "32"); + defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\""); + defineMacro("__wasi__", "1"); + defineMacro("__wasm", "1"); + defineMacro("__wasm32", "1"); + defineMacro("__wasm32__", "1"); + defineMacro("__wasm__", "1"); + defineMacro("__wasm_bulk_memory__", "1"); + defineMacro("__wasm_bulk_memory_opt__", "1"); + defineMacro("__wasm_multivalue__", "1"); + defineMacro("__wasm_mutable_globals__", "1"); + defineMacro("__wasm_nontrapping_fptoint__", "1"); + defineMacro("__wasm_reference_types__", "1"); + defineMacro("__wasm_sign_ext__", "1"); +} + +void Toolchain::addLinuxAArch64Macros() { + defineMacro("__AARCH64EL__", "1"); + defineMacro("__AARCH64_CMODEL_SMALL__", "1"); + defineMacro("__ARM_64BIT_STATE", "1"); + defineMacro("__ARM_ACLE", "202420"); + defineMacro("__ARM_ACLE_VERSION(year,quarter,patch)", + "(100 * (year) + 10 * (quarter) + (patch))"); + defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4"); + defineMacro("__ARM_ARCH", "8"); + defineMacro("__ARM_ARCH_ISA_A64", "1"); + defineMacro("__ARM_ARCH_PROFILE", "'A'"); + defineMacro("__ARM_FEATURE_CLZ", "1"); + defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING", "1"); + defineMacro("__ARM_FEATURE_DIV", "1"); + defineMacro("__ARM_FEATURE_FMA", "1"); + defineMacro("__ARM_FEATURE_IDIV", "1"); + defineMacro("__ARM_FEATURE_LDREX", "0xF"); + defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1"); + defineMacro("__ARM_FEATURE_UNALIGNED", "1"); + defineMacro("__ARM_FP", "0xE"); + defineMacro("__ARM_FP16_ARGS", "1"); + defineMacro("__ARM_FP16_FORMAT_IEEE", "1"); + defineMacro("__ARM_NEON", "1"); + defineMacro("__ARM_NEON_FP", "0xE"); + defineMacro("__ARM_NEON_SVE_BRIDGE", "1"); + defineMacro("__ARM_PCS_AAPCS64", "1"); + defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", "4"); + defineMacro("__ARM_SIZEOF_WCHAR_T", "4"); + defineMacro("__ARM_STATE_ZA", "1"); + defineMacro("__ARM_STATE_ZT0", "1"); + defineMacro("__BITINT_MAXWIDTH__", "128"); + defineMacro("__CHAR_UNSIGNED__", "1"); + defineMacro("__FP_FAST_FMA", "1"); + defineMacro("__FP_FAST_FMAF", "1"); + defineMacro("__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL", "202430"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16", "1"); + defineMacro("__LDBL_DECIMAL_DIG__", "36"); + defineMacro("__LDBL_DENORM_MIN__", + "6.47517511943802511092443895822764655e-4966L"); + defineMacro("__LDBL_DIG__", "33"); + defineMacro("__LDBL_EPSILON__", "1.92592994438723585305597794258492732e-34L"); + defineMacro("__LDBL_MANT_DIG__", "113"); + defineMacro("__LDBL_MAX__", "1.18973149535723176508575932662800702e+4932L"); + defineMacro("__LDBL_MIN__", "3.36210314311209350626267781732175260e-4932L"); + defineMacro("__LDBL_NORM_MAX__", + "1.18973149535723176508575932662800702e+4932L"); + defineMacro("__WCHAR_MAX__", "4294967295U"); + defineMacro("__WCHAR_TYPE__", "unsigned int"); + defineMacro("__WCHAR_UNSIGNED__", "1"); + defineMacro("__aarch64__", "1"); +} + +void Toolchain::addLinuxX86_64Macros() { + defineMacro("__BITINT_MAXWIDTH__", "8388608"); + defineMacro("__FLOAT128__", "1"); + defineMacro("__FXSR__", "1"); + defineMacro("__LDBL_DECIMAL_DIG__", "21"); + defineMacro("__LDBL_DENORM_MIN__", "3.64519953188247460253e-4951L"); + defineMacro("__LDBL_DIG__", "18"); + defineMacro("__LDBL_EPSILON__", "1.08420217248550443401e-19L"); + defineMacro("__LDBL_MANT_DIG__", "64"); + defineMacro("__LDBL_MAX__", "1.18973149535723176502e+4932L"); + defineMacro("__LDBL_MIN__", "3.36210314311209350626e-4932L"); + defineMacro("__LDBL_NORM_MAX__", "1.18973149535723176502e+4932L"); + defineMacro("__MMX__", "1"); + defineMacro("__NO_MATH_INLINES", "1"); + defineMacro("__REGISTER_PREFIX__", ""); + defineMacro("__SEG_FS", "1"); + defineMacro("__SEG_GS", "1"); + defineMacro("__SIZEOF_FLOAT128__", "16"); + defineMacro("__SSE2_MATH__", "1"); + defineMacro("__SSE2__", "1"); + defineMacro("__SSE_MATH__", "1"); + defineMacro("__SSE__", "1"); + defineMacro("__WCHAR_MAX__", "2147483647"); + defineMacro("__WCHAR_TYPE__", "int"); + defineMacro("__amd64", "1"); + defineMacro("__amd64__", "1"); + defineMacro("__code_model_small__", "1"); + defineMacro("__k8", "1"); + defineMacro("__k8__", "1"); + defineMacro("__seg_fs", "__attribute__((address_space(257)))"); + defineMacro("__seg_gs", "__attribute__((address_space(256)))"); + defineMacro("__tune_k8__", "1"); + defineMacro("__x86_64", "1"); + defineMacro("__x86_64__", "1"); +} + +void Toolchain::addMacOSAArch64Macros() { + defineMacro("__AARCH64EL__", "1"); + defineMacro("__AARCH64_CMODEL_SMALL__", "1"); + defineMacro("__AARCH64_SIMD__", "1"); + defineMacro("__ARM64_ARCH_8__", "1"); + defineMacro("__ARM_64BIT_STATE", "1"); + defineMacro("__ARM_ACLE", "202420"); + defineMacro("__ARM_ACLE_VERSION(year,quarter,patch)", + "(100 * (year) + 10 * (quarter) + (patch))"); + defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4"); + defineMacro("__ARM_ARCH", "8"); + defineMacro("__ARM_ARCH_ISA_A64", "1"); + defineMacro("__ARM_ARCH_PROFILE", "'A'"); + defineMacro("__ARM_FEATURE_AES", "1"); + defineMacro("__ARM_FEATURE_ATOMICS", "1"); + defineMacro("__ARM_FEATURE_CLZ", "1"); + defineMacro("__ARM_FEATURE_COMPLEX", "1"); + defineMacro("__ARM_FEATURE_CRC32", "1"); + defineMacro("__ARM_FEATURE_CRYPTO", "1"); + defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING", "1"); + defineMacro("__ARM_FEATURE_DIV", "1"); + defineMacro("__ARM_FEATURE_DOTPROD", "1"); + defineMacro("__ARM_FEATURE_FMA", "1"); + defineMacro("__ARM_FEATURE_FP16_FML", "1"); + defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1"); + defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1"); + defineMacro("__ARM_FEATURE_IDIV", "1"); + defineMacro("__ARM_FEATURE_JCVT", "1"); + defineMacro("__ARM_FEATURE_LDREX", "0xF"); + defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1"); + defineMacro("__ARM_FEATURE_PAUTH", "1"); + defineMacro("__ARM_FEATURE_QRDMX", "1"); + defineMacro("__ARM_FEATURE_RCPC", "1"); + defineMacro("__ARM_FEATURE_SHA2", "1"); + defineMacro("__ARM_FEATURE_SHA3", "1"); + defineMacro("__ARM_FEATURE_SHA512", "1"); + defineMacro("__ARM_FEATURE_UNALIGNED", "1"); + defineMacro("__ARM_FP", "0xE"); + defineMacro("__ARM_FP16_ARGS", "1"); + defineMacro("__ARM_FP16_FORMAT_IEEE", "1"); + defineMacro("__ARM_NEON", "1"); + defineMacro("__ARM_NEON_FP", "0xE"); + defineMacro("__ARM_NEON_SVE_BRIDGE", "1"); + defineMacro("__ARM_NEON__", "1"); + defineMacro("__ARM_PCS_AAPCS64", "1"); + defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", "4"); + defineMacro("__ARM_SIZEOF_WCHAR_T", "4"); + defineMacro("__ARM_STATE_ZA", "1"); + defineMacro("__ARM_STATE_ZT0", "1"); + defineMacro("__BIGGEST_ALIGNMENT__", "8"); + defineMacro("__BITINT_MAXWIDTH__", "128"); + defineMacro("__FP_FAST_FMA", "1"); + defineMacro("__FP_FAST_FMAF", "1"); + defineMacro("__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL", "202430"); + defineMacro("__HAVE_FUNCTION_MULTI_VERSIONING", "1"); + defineMacro("__LDBL_DECIMAL_DIG__", "17"); + defineMacro("__LDBL_DENORM_MIN__", "4.9406564584124654e-324L"); + defineMacro("__LDBL_DIG__", "15"); + defineMacro("__LDBL_EPSILON__", "2.2204460492503131e-16L"); + defineMacro("__LDBL_MANT_DIG__", "53"); + defineMacro("__LDBL_MAX_10_EXP__", "308"); + defineMacro("__LDBL_MAX_EXP__", "1024"); + defineMacro("__LDBL_MAX__", "1.7976931348623157e+308L"); + defineMacro("__LDBL_MIN_10_EXP__", "(-307)"); + defineMacro("__LDBL_MIN_EXP__", "(-1021)"); + defineMacro("__LDBL_MIN__", "2.2250738585072014e-308L"); + defineMacro("__LDBL_NORM_MAX__", "1.7976931348623157e+308L"); + defineMacro("__OBJC_BOOL_IS_BOOL", "1"); + defineMacro("__SIZEOF_LONG_DOUBLE__", "8"); + defineMacro("__aarch64__", "1"); + defineMacro("__arm64", "1"); + defineMacro("__arm64__", "1"); +} + +void Toolchain::addMacOSX86_64Macros() { + defineMacro("__BIGGEST_ALIGNMENT__", "16"); + defineMacro("__BITINT_MAXWIDTH__", "8388608"); + defineMacro("__FXSR__", "1"); + defineMacro("__LAHF_SAHF__", "1"); + defineMacro("__LDBL_DECIMAL_DIG__", "21"); + defineMacro("__LDBL_DENORM_MIN__", "3.64519953188247460253e-4951L"); + defineMacro("__LDBL_DIG__", "18"); + defineMacro("__LDBL_EPSILON__", "1.08420217248550443401e-19L"); + defineMacro("__LDBL_MANT_DIG__", "64"); + defineMacro("__LDBL_MAX_10_EXP__", "4932"); + defineMacro("__LDBL_MAX_EXP__", "16384"); + defineMacro("__LDBL_MAX__", "1.18973149535723176502e+4932L"); + defineMacro("__LDBL_MIN_10_EXP__", "(-4931)"); + defineMacro("__LDBL_MIN_EXP__", "(-16381)"); + defineMacro("__LDBL_MIN__", "3.36210314311209350626e-4932L"); + defineMacro("__LDBL_NORM_MAX__", "1.18973149535723176502e+4932L"); + defineMacro("__MMX__", "1"); + defineMacro("__NO_MATH_INLINES", "1"); + defineMacro("__OBJC_BOOL_IS_BOOL", "0"); + defineMacro("__SEG_FS", "1"); + defineMacro("__SEG_GS", "1"); + defineMacro("__SIZEOF_LONG_DOUBLE__", "16"); + defineMacro("__SSE2_MATH__", "1"); + defineMacro("__SSE2__", "1"); + defineMacro("__SSE3__", "1"); + defineMacro("__SSE4_1__", "1"); + defineMacro("__SSE_MATH__", "1"); + defineMacro("__SSE__", "1"); + defineMacro("__SSSE3__", "1"); + defineMacro("__amd64", "1"); + defineMacro("__amd64__", "1"); + defineMacro("__code_model_small__", "1"); + defineMacro("__core2", "1"); + defineMacro("__core2__", "1"); + defineMacro("__seg_fs", "__attribute__((address_space(257)))"); + defineMacro("__seg_gs", "__attribute__((address_space(256)))"); + defineMacro("__tune_core2__", "1"); + defineMacro("__x86_64", "1"); + defineMacro("__x86_64__", "1"); +} + +void Toolchain::addWindowsAArch64Macros() { + defineMacro("_ISO_VOLATILE", "1"); + defineMacro("_M_ARM64", "1"); + defineMacro("__AARCH64EL__", "1"); + defineMacro("__AARCH64_CMODEL_SMALL__", "1"); + defineMacro("__ARM_64BIT_STATE", "1"); + defineMacro("__ARM_ACLE", "202420"); + defineMacro("__ARM_ACLE_VERSION(year,quarter,patch)", + "(100 * (year) + 10 * (quarter) + (patch))"); + defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4"); + defineMacro("__ARM_ARCH", "8"); + defineMacro("__ARM_ARCH_ISA_A64", "1"); + defineMacro("__ARM_ARCH_PROFILE", "'A'"); + defineMacro("__ARM_FEATURE_CLZ", "1"); + defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING", "1"); + defineMacro("__ARM_FEATURE_DIV", "1"); + defineMacro("__ARM_FEATURE_FMA", "1"); + defineMacro("__ARM_FEATURE_IDIV", "1"); + defineMacro("__ARM_FEATURE_LDREX", "0xF"); + defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1"); + defineMacro("__ARM_FEATURE_UNALIGNED", "1"); + defineMacro("__ARM_FP", "0xE"); + defineMacro("__ARM_FP16_ARGS", "1"); + defineMacro("__ARM_FP16_FORMAT_IEEE", "1"); + defineMacro("__ARM_NEON", "1"); + defineMacro("__ARM_NEON_FP", "0xE"); + defineMacro("__ARM_NEON_SVE_BRIDGE", "1"); + defineMacro("__ARM_PCS_AAPCS64", "1"); + defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", "4"); + defineMacro("__ARM_SIZEOF_WCHAR_T", "4"); + defineMacro("__ARM_STATE_ZA", "1"); + defineMacro("__ARM_STATE_ZT0", "1"); + defineMacro("__BITINT_MAXWIDTH__", "128"); + defineMacro("__FP_FAST_FMA", "1"); + defineMacro("__FP_FAST_FMAF", "1"); + defineMacro("__FUNCTION_MULTI_VERSIONING_SUPPORT_LEVEL", "202430"); + defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16", "1"); + defineMacro("__aarch64__", "1"); +} + +void Toolchain::addWindowsX86_64Macros() { + defineMacro("_M_AMD64", "100"); + defineMacro("_M_X64", "100"); + defineMacro("__BITINT_MAXWIDTH__", "8388608"); + defineMacro("__FXSR__", "1"); + defineMacro("__MMX__", "1"); + defineMacro("__NO_MATH_INLINES", "1"); + defineMacro("__REGISTER_PREFIX__", ""); + defineMacro("__SEG_FS", "1"); + defineMacro("__SEG_GS", "1"); + defineMacro("__SSE2_MATH__", "1"); + defineMacro("__SSE2__", "1"); + defineMacro("__SSE_MATH__", "1"); + defineMacro("__SSE__", "1"); + defineMacro("__amd64", "1"); + defineMacro("__amd64__", "1"); + defineMacro("__code_model_small__", "1"); + defineMacro("__k8", "1"); + defineMacro("__k8__", "1"); + defineMacro("__seg_fs", "__attribute__((address_space(257)))"); + defineMacro("__seg_gs", "__attribute__((address_space(256)))"); + defineMacro("__tune_k8__", "1"); + defineMacro("__x86_64", "1"); + defineMacro("__x86_64__", "1"); +} + +void Toolchain::addWASIWasm32Macros() {} + +void Toolchain::addLinuxC23Macros() { + defineMacro("__GNUC_STDC_INLINE__", "1"); + defineMacro("__SIZE_FMTB__", "\"lB\""); + defineMacro("__SIZE_FMTb__", "\"lb\""); + defineMacro("__UINT64_FMTB__", "\"lB\""); + defineMacro("__UINT64_FMTb__", "\"lb\""); + defineMacro("__UINTMAX_FMTB__", "\"lB\""); + defineMacro("__UINTMAX_FMTb__", "\"lb\""); + defineMacro("__UINTPTR_FMTB__", "\"lB\""); + defineMacro("__UINTPTR_FMTb__", "\"lb\""); + defineMacro("__UINT_FAST64_FMTB__", "\"lB\""); + defineMacro("__UINT_FAST64_FMTb__", "\"lb\""); + defineMacro("__UINT_LEAST64_FMTB__", "\"lB\""); + defineMacro("__UINT_LEAST64_FMTb__", "\"lb\""); +} + +void Toolchain::addMacOSC23Macros() { + defineMacro("__GNUC_STDC_INLINE__", "1"); + defineMacro("__SIZE_FMTB__", "\"lB\""); + defineMacro("__SIZE_FMTb__", "\"lb\""); + defineMacro("__UINT64_FMTB__", "\"llB\""); + defineMacro("__UINT64_FMTb__", "\"llb\""); + defineMacro("__UINTMAX_FMTB__", "\"lB\""); + defineMacro("__UINTMAX_FMTb__", "\"lb\""); + defineMacro("__UINTPTR_FMTB__", "\"lB\""); + defineMacro("__UINTPTR_FMTb__", "\"lb\""); + defineMacro("__UINT_FAST64_FMTB__", "\"llB\""); + defineMacro("__UINT_FAST64_FMTb__", "\"llb\""); + defineMacro("__UINT_LEAST64_FMTB__", "\"llB\""); + defineMacro("__UINT_LEAST64_FMTb__", "\"llb\""); +} + +void Toolchain::addWindowsC23Macros() { + defineMacro("__SIZE_FMTB__", "\"llB\""); + defineMacro("__SIZE_FMTb__", "\"llb\""); + defineMacro("__UINT64_FMTB__", "\"llB\""); + defineMacro("__UINT64_FMTb__", "\"llb\""); + defineMacro("__UINTMAX_FMTB__", "\"llB\""); + defineMacro("__UINTMAX_FMTb__", "\"llb\""); + defineMacro("__UINTPTR_FMTB__", "\"llB\""); + defineMacro("__UINTPTR_FMTb__", "\"llb\""); + defineMacro("__UINT_FAST64_FMTB__", "\"llB\""); + defineMacro("__UINT_FAST64_FMTb__", "\"llb\""); + defineMacro("__UINT_LEAST64_FMTB__", "\"llB\""); + defineMacro("__UINT_LEAST64_FMTb__", "\"llb\""); +} + +void Toolchain::addWASIC23Macros() { + defineMacro("__GNUC_STDC_INLINE__", "1"); + defineMacro("__SIZE_FMTB__", "\"lB\""); + defineMacro("__SIZE_FMTb__", "\"lb\""); + defineMacro("__UINT64_FMTB__", "\"llB\""); + defineMacro("__UINT64_FMTb__", "\"llb\""); + defineMacro("__UINTMAX_FMTB__", "\"llB\""); + defineMacro("__UINTMAX_FMTb__", "\"llb\""); + defineMacro("__UINTPTR_FMTB__", "\"lB\""); + defineMacro("__UINTPTR_FMTb__", "\"lb\""); + defineMacro("__UINT_FAST64_FMTB__", "\"llB\""); + defineMacro("__UINT_FAST64_FMTb__", "\"llb\""); + defineMacro("__UINT_LEAST64_FMTB__", "\"llB\""); + defineMacro("__UINT_LEAST64_FMTb__", "\"llb\""); +} + +void Toolchain::addLinuxCxx26Macros() { + defineMacro("_GNU_SOURCE", "1"); + defineMacro("__EXCEPTIONS", "1"); + defineMacro("__GNUC_GNU_INLINE__", "1"); + defineMacro("__GNUG__", "4"); + defineMacro("__GXX_EXPERIMENTAL_CXX0X__", "1"); + defineMacro("__GXX_RTTI", "1"); + defineMacro("__GXX_WEAK__", "1"); + defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16UL"); + defineMacro("__STDCPP_THREADS__", "1"); + defineMacro("__cpp_threadsafe_static_init", "200806L"); + defineMacro("__private_extern__", "extern"); +} + +void Toolchain::addMacOSCxx26Macros() { + defineMacro("__EXCEPTIONS", "1"); + defineMacro("__GNUC_GNU_INLINE__", "1"); + defineMacro("__GNUG__", "4"); + defineMacro("__GXX_EXPERIMENTAL_CXX0X__", "1"); + defineMacro("__GXX_RTTI", "1"); + defineMacro("__GXX_WEAK__", "1"); + defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16UL"); + defineMacro("__STDCPP_THREADS__", "1"); + defineMacro("__cpp_threadsafe_static_init", "200806L"); + defineMacro("__private_extern__", "extern"); +} + +void Toolchain::addWindowsCxx26Macros() { + defineMacro("_CPPRTTI", "1"); + defineMacro("_CPPUNWIND", "1"); + defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", "1"); + defineMacro("_MSVC_LANG", "202400L"); + defineMacro("_NATIVE_NULLPTR_SUPPORTED", "1"); + defineMacro("_NATIVE_WCHAR_T_DEFINED", "1"); + defineMacro("_RVALUE_REFERENCES_SUPPORTED", "1"); + defineMacro("_RVALUE_REFERENCES_V2_SUPPORTED", "1"); + defineMacro("_WCHAR_T_DEFINED", "1"); + defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16ULL"); + defineMacro("__STDCPP_THREADS__", "1"); + defineMacro("__cpp_threadsafe_static_init", "200806L"); +} + +void Toolchain::addWASICxx26Macros() { + defineMacro("_GNU_SOURCE", "1"); + defineMacro("__EXCEPTIONS", "1"); + defineMacro("__GNUC_GNU_INLINE__", "1"); + defineMacro("__GNUG__", "4"); + defineMacro("__GXX_EXPERIMENTAL_CXX0X__", "1"); + defineMacro("__GXX_RTTI", "1"); + defineMacro("__GXX_WEAK__", "1"); + defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16UL"); + defineMacro("__private_extern__", "extern"); +} + } // namespace cxx diff --git a/src/parser/cxx/toolchain.h b/src/parser/cxx/toolchain.h index a0cf47fe..a951e6e1 100644 --- a/src/parser/cxx/toolchain.h +++ b/src/parser/cxx/toolchain.h @@ -58,6 +58,29 @@ class Toolchain { void addSystemIncludePath(std::string path); + void addCommonMacros(); + void addCommonC23Macros(); + void addCommonCxx26Macros(); + void addCommonLinuxMacros(); + void addCommonMacOSMacros(); + void addCommonWindowsMacros(); + void addCommonWASIMacros(); + void addLinuxAArch64Macros(); + void addLinuxX86_64Macros(); + void addMacOSAArch64Macros(); + void addMacOSX86_64Macros(); + void addWindowsAArch64Macros(); + void addWindowsX86_64Macros(); + void addWASIWasm32Macros(); + void addLinuxC23Macros(); + void addMacOSC23Macros(); + void addWindowsC23Macros(); + void addWASIC23Macros(); + void addLinuxCxx26Macros(); + void addMacOSCxx26Macros(); + void addWindowsCxx26Macros(); + void addWASICxx26Macros(); + private: Preprocessor *preprocessor_; std::unique_ptr memoryLayout_; diff --git a/src/parser/cxx/wasm32_wasi_toolchain.cc b/src/parser/cxx/wasm32_wasi_toolchain.cc index 865a88ee..654d3176 100644 --- a/src/parser/cxx/wasm32_wasi_toolchain.cc +++ b/src/parser/cxx/wasm32_wasi_toolchain.cc @@ -74,9 +74,6 @@ void Wasm32WasiToolchain::addSystemCppIncludePaths() { } void Wasm32WasiToolchain::addPredefinedMacros() { - const auto is_cxx = language() == LanguageKind::kCXX; - - // clang-format off defineMacro("__extension__", ""); defineMacro("__autoreleasing", ""); defineMacro("__strong", ""); @@ -87,465 +84,16 @@ void Wasm32WasiToolchain::addPredefinedMacros() { defineMacro("_Pragma(x)", ""); defineMacro("_Thread_local", "thread_local"); - if (!is_cxx) { - defineMacro("__STDC_VERSION__", "202311L"); - } - - defineMacro("_GNU_SOURCE", "1"); - defineMacro("_ILP32", "1"); - defineMacro("__ATOMIC_ACQUIRE", "2"); - defineMacro("__ATOMIC_ACQ_REL", "4"); - defineMacro("__ATOMIC_CONSUME", "1"); - defineMacro("__ATOMIC_RELAXED", "0"); - defineMacro("__ATOMIC_RELEASE", "3"); - defineMacro("__ATOMIC_SEQ_CST", "5"); - defineMacro("__BIGGEST_ALIGNMENT__", "16"); - defineMacro("__BITINT_MAXWIDTH__", "128"); - defineMacro("__BOOL_WIDTH__", "1"); - defineMacro("__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__"); - defineMacro("__CHAR16_TYPE__", "unsigned short"); - defineMacro("__CHAR32_TYPE__", "unsigned int"); - defineMacro("__CHAR_BIT__", "8"); - defineMacro("__CLANG_ATOMIC_BOOL_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR16_T_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR32_T_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR8_T_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_CHAR_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_INT_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_LLONG_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_LONG_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_POINTER_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_SHORT_LOCK_FREE", "2"); - defineMacro("__CLANG_ATOMIC_WCHAR_T_LOCK_FREE", "2"); - defineMacro("__CONSTANT_CFSTRINGS__", "1"); - defineMacro("__DBL_DECIMAL_DIG__", "17"); - defineMacro("__DBL_DENORM_MIN__", "4.9406564584124654e-324"); - defineMacro("__DBL_DIG__", "15"); - defineMacro("__DBL_EPSILON__", "2.2204460492503131e-16"); - defineMacro("__DBL_HAS_DENORM__", "1"); - defineMacro("__DBL_HAS_INFINITY__", "1"); - defineMacro("__DBL_HAS_QUIET_NAN__", "1"); - defineMacro("__DBL_MANT_DIG__", "53"); - defineMacro("__DBL_MAX_10_EXP__", "308"); - defineMacro("__DBL_MAX_EXP__", "1024"); - defineMacro("__DBL_MAX__", "1.7976931348623157e+308"); - defineMacro("__DBL_MIN_10_EXP__", "(-307)"); - defineMacro("__DBL_MIN_EXP__", "(-1021)"); - defineMacro("__DBL_MIN__", "2.2250738585072014e-308"); - defineMacro("__DBL_NORM_MAX__", "1.7976931348623157e+308"); - defineMacro("__DECIMAL_DIG__", "__LDBL_DECIMAL_DIG__"); - defineMacro("__DEPRECATED", "1"); - defineMacro("__EXCEPTIONS", "1"); - defineMacro("__FINITE_MATH_ONLY__", "0"); - defineMacro("__FLOAT128__", "1"); - defineMacro("__FLT_DECIMAL_DIG__", "9"); - defineMacro("__FLT_DENORM_MIN__", "1.40129846e-45F"); - defineMacro("__FLT_DIG__", "6"); - defineMacro("__FLT_EPSILON__", "1.19209290e-7F"); - defineMacro("__FLT_HAS_DENORM__", "1"); - defineMacro("__FLT_HAS_INFINITY__", "1"); - defineMacro("__FLT_HAS_QUIET_NAN__", "1"); - defineMacro("__FLT_MANT_DIG__", "24"); - defineMacro("__FLT_MAX_10_EXP__", "38"); - defineMacro("__FLT_MAX_EXP__", "128"); - defineMacro("__FLT_MAX__", "3.40282347e+38F"); - defineMacro("__FLT_MIN_10_EXP__", "(-37)"); - defineMacro("__FLT_MIN_EXP__", "(-125)"); - defineMacro("__FLT_MIN__", "1.17549435e-38F"); - defineMacro("__FLT_NORM_MAX__", "3.40282347e+38F"); - defineMacro("__FLT_RADIX__", "2"); - defineMacro("__FPCLASS_NEGINF", "0x0004"); - defineMacro("__FPCLASS_NEGNORMAL", "0x0008"); - defineMacro("__FPCLASS_NEGSUBNORMAL", "0x0010"); - defineMacro("__FPCLASS_NEGZERO", "0x0020"); - defineMacro("__FPCLASS_POSINF", "0x0200"); - defineMacro("__FPCLASS_POSNORMAL", "0x0100"); - defineMacro("__FPCLASS_POSSUBNORMAL", "0x0080"); - defineMacro("__FPCLASS_POSZERO", "0x0040"); - defineMacro("__FPCLASS_QNAN", "0x0002"); - defineMacro("__FPCLASS_SNAN", "0x0001"); - defineMacro("__GCC_ATOMIC_BOOL_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR16_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR32_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR8_T_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_CHAR_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_INT_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_LLONG_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_LONG_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_SHORT_LOCK_FREE", "2"); - defineMacro("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL", "1"); - defineMacro("__GCC_ATOMIC_WCHAR_T_LOCK_FREE", "2"); - defineMacro("__GCC_CONSTRUCTIVE_SIZE", "64"); - defineMacro("__GCC_DESTRUCTIVE_SIZE", "64"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4", "1"); - defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8", "1"); - defineMacro("__GNUC_GNU_INLINE__", "1"); - defineMacro("__GNUC_MINOR__", "2"); - defineMacro("__GNUC_PATCHLEVEL__", "1"); - defineMacro("__GNUC__", "4"); - defineMacro("__GNUG__", "4"); - defineMacro("__GXX_ABI_VERSION", "1002"); - defineMacro("__GXX_EXPERIMENTAL_CXX0X__", "1"); - defineMacro("__GXX_RTTI", "1"); - defineMacro("__GXX_WEAK__", "1"); - defineMacro("__ILP32__", "1"); - defineMacro("__INT16_C_SUFFIX__", ""); - defineMacro("__INT16_FMTd__", "\"hd\""); - defineMacro("__INT16_FMTi__", "\"hi\""); - defineMacro("__INT16_MAX__", "32767"); - defineMacro("__INT16_TYPE__", "short"); - defineMacro("__INT32_C_SUFFIX__", ""); - defineMacro("__INT32_FMTd__", "\"d\""); - defineMacro("__INT32_FMTi__", "\"i\""); - defineMacro("__INT32_MAX__", "2147483647"); - defineMacro("__INT32_TYPE__", "int"); - defineMacro("__INT64_C_SUFFIX__", "LL"); - defineMacro("__INT64_FMTd__", "\"lld\""); - defineMacro("__INT64_FMTi__", "\"lli\""); - defineMacro("__INT64_MAX__", "9223372036854775807LL"); - defineMacro("__INT64_TYPE__", "long long int"); - defineMacro("__INT8_C_SUFFIX__", ""); - defineMacro("__INT8_FMTd__", "\"hhd\""); - defineMacro("__INT8_FMTi__", "\"hhi\""); - defineMacro("__INT8_MAX__", "127"); - defineMacro("__INT8_TYPE__", "signed char"); - defineMacro("__INTMAX_C_SUFFIX__", "LL"); - defineMacro("__INTMAX_FMTd__", "\"lld\""); - defineMacro("__INTMAX_FMTi__", "\"lli\""); - defineMacro("__INTMAX_MAX__", "9223372036854775807LL"); - defineMacro("__INTMAX_TYPE__", "long long int"); - defineMacro("__INTMAX_WIDTH__", "64"); - defineMacro("__INTPTR_FMTd__", "\"ld\""); - defineMacro("__INTPTR_FMTi__", "\"li\""); - defineMacro("__INTPTR_MAX__", "2147483647L"); - defineMacro("__INTPTR_TYPE__", "long int"); - defineMacro("__INTPTR_WIDTH__", "32"); - defineMacro("__INT_FAST16_FMTd__", "\"hd\""); - defineMacro("__INT_FAST16_FMTi__", "\"hi\""); - defineMacro("__INT_FAST16_MAX__", "32767"); - defineMacro("__INT_FAST16_TYPE__", "short"); - defineMacro("__INT_FAST16_WIDTH__", "16"); - defineMacro("__INT_FAST32_FMTd__", "\"d\""); - defineMacro("__INT_FAST32_FMTi__", "\"i\""); - defineMacro("__INT_FAST32_MAX__", "2147483647"); - defineMacro("__INT_FAST32_TYPE__", "int"); - defineMacro("__INT_FAST32_WIDTH__", "32"); - defineMacro("__INT_FAST64_FMTd__", "\"lld\""); - defineMacro("__INT_FAST64_FMTi__", "\"lli\""); - defineMacro("__INT_FAST64_MAX__", "9223372036854775807LL"); - defineMacro("__INT_FAST64_TYPE__", "long long int"); - defineMacro("__INT_FAST64_WIDTH__", "64"); - defineMacro("__INT_FAST8_FMTd__", "\"hhd\""); - defineMacro("__INT_FAST8_FMTi__", "\"hhi\""); - defineMacro("__INT_FAST8_MAX__", "127"); - defineMacro("__INT_FAST8_TYPE__", "signed char"); - defineMacro("__INT_FAST8_WIDTH__", "8"); - defineMacro("__INT_LEAST16_FMTd__", "\"hd\""); - defineMacro("__INT_LEAST16_FMTi__", "\"hi\""); - defineMacro("__INT_LEAST16_MAX__", "32767"); - defineMacro("__INT_LEAST16_TYPE__", "short"); - defineMacro("__INT_LEAST16_WIDTH__", "16"); - defineMacro("__INT_LEAST32_FMTd__", "\"d\""); - defineMacro("__INT_LEAST32_FMTi__", "\"i\""); - defineMacro("__INT_LEAST32_MAX__", "2147483647"); - defineMacro("__INT_LEAST32_TYPE__", "int"); - defineMacro("__INT_LEAST32_WIDTH__", "32"); - defineMacro("__INT_LEAST64_FMTd__", "\"lld\""); - defineMacro("__INT_LEAST64_FMTi__", "\"lli\""); - defineMacro("__INT_LEAST64_MAX__", "9223372036854775807LL"); - defineMacro("__INT_LEAST64_TYPE__", "long long int"); - defineMacro("__INT_LEAST64_WIDTH__", "64"); - defineMacro("__INT_LEAST8_FMTd__", "\"hhd\""); - defineMacro("__INT_LEAST8_FMTi__", "\"hhi\""); - defineMacro("__INT_LEAST8_MAX__", "127"); - defineMacro("__INT_LEAST8_TYPE__", "signed char"); - defineMacro("__INT_LEAST8_WIDTH__", "8"); - defineMacro("__INT_MAX__", "2147483647"); - defineMacro("__INT_WIDTH__", "32"); - defineMacro("__LDBL_DECIMAL_DIG__", "36"); - defineMacro("__LDBL_DENORM_MIN__", "6.47517511943802511092443895822764655e-4966L"); - defineMacro("__LDBL_DIG__", "33"); - defineMacro("__LDBL_EPSILON__", "1.92592994438723585305597794258492732e-34L"); - defineMacro("__LDBL_HAS_DENORM__", "1"); - defineMacro("__LDBL_HAS_INFINITY__", "1"); - defineMacro("__LDBL_HAS_QUIET_NAN__", "1"); - defineMacro("__LDBL_MANT_DIG__", "113"); - defineMacro("__LDBL_MAX_10_EXP__", "4932"); - defineMacro("__LDBL_MAX_EXP__", "16384"); - defineMacro("__LDBL_MAX__", "1.18973149535723176508575932662800702e+4932L"); - defineMacro("__LDBL_MIN_10_EXP__", "(-4931)"); - defineMacro("__LDBL_MIN_EXP__", "(-16381)"); - defineMacro("__LDBL_MIN__", "3.36210314311209350626267781732175260e-4932L"); - defineMacro("__LDBL_NORM_MAX__", "1.18973149535723176508575932662800702e+4932L"); - defineMacro("__LITTLE_ENDIAN__", "1"); - defineMacro("__LLONG_WIDTH__", "64"); - defineMacro("__LONG_LONG_MAX__", "9223372036854775807LL"); - defineMacro("__LONG_MAX__", "2147483647L"); - defineMacro("__LONG_WIDTH__", "32"); - defineMacro("__MEMORY_SCOPE_DEVICE", "1"); - defineMacro("__MEMORY_SCOPE_SINGLE", "4"); - defineMacro("__MEMORY_SCOPE_SYSTEM", "0"); - defineMacro("__MEMORY_SCOPE_WRKGRP", "2"); - defineMacro("__MEMORY_SCOPE_WVFRNT", "3"); - defineMacro("__NO_INLINE__", "1"); - defineMacro("__NO_MATH_ERRNO__", "1"); - defineMacro("__OBJC_BOOL_IS_BOOL", "0"); - defineMacro("__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES", "3"); - defineMacro("__OPENCL_MEMORY_SCOPE_DEVICE", "2"); - defineMacro("__OPENCL_MEMORY_SCOPE_SUB_GROUP", "4"); - defineMacro("__OPENCL_MEMORY_SCOPE_WORK_GROUP", "1"); - defineMacro("__OPENCL_MEMORY_SCOPE_WORK_ITEM", "0"); - defineMacro("__ORDER_BIG_ENDIAN__", "4321"); - defineMacro("__ORDER_LITTLE_ENDIAN__", "1234"); - defineMacro("__ORDER_PDP_ENDIAN__", "3412"); - defineMacro("__POINTER_WIDTH__", "32"); - defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1"); - defineMacro("__PTRDIFF_FMTd__", "\"ld\""); - defineMacro("__PTRDIFF_FMTi__", "\"li\""); - defineMacro("__PTRDIFF_MAX__", "2147483647L"); - defineMacro("__PTRDIFF_TYPE__", "long int"); - defineMacro("__PTRDIFF_WIDTH__", "32"); - defineMacro("__SCHAR_MAX__", "127"); - defineMacro("__SHRT_MAX__", "32767"); - defineMacro("__SHRT_WIDTH__", "16"); - defineMacro("__SIG_ATOMIC_MAX__", "2147483647L"); - defineMacro("__SIG_ATOMIC_WIDTH__", "32"); - defineMacro("__SIZEOF_DOUBLE__", "8"); - defineMacro("__SIZEOF_FLOAT__", "4"); - - // TODO: defineMacro("__SIZEOF_INT128__", "16"); - - defineMacro("__SIZEOF_INT__", "4"); - defineMacro("__SIZEOF_LONG_DOUBLE__", "16"); - defineMacro("__SIZEOF_LONG_LONG__", "8"); - defineMacro("__SIZEOF_LONG__", "4"); - defineMacro("__SIZEOF_POINTER__", "4"); - defineMacro("__SIZEOF_PTRDIFF_T__", "4"); - defineMacro("__SIZEOF_SHORT__", "2"); - defineMacro("__SIZEOF_SIZE_T__", "4"); + addCommonMacros(); + addCommonWASIMacros(); - if (is_cxx) { - defineMacro("__SIZEOF_WCHAR_T__", "4"); - defineMacro("__WCHAR_MAX__", "2147483647"); - defineMacro("__WCHAR_TYPE__", "int"); - defineMacro("__WCHAR_WIDTH__", "32"); + if (language() == LanguageKind::kCXX) { + addCommonCxx26Macros(); + addWASICxx26Macros(); + } else { + addCommonC23Macros(); + addWASIC23Macros(); } - - defineMacro("__SIZEOF_WINT_T__", "4"); - defineMacro("__SIZE_FMTX__", "\"lX\""); - defineMacro("__SIZE_FMTo__", "\"lo\""); - defineMacro("__SIZE_FMTu__", "\"lu\""); - defineMacro("__SIZE_FMTx__", "\"lx\""); - defineMacro("__SIZE_MAX__", "4294967295UL"); - defineMacro("__SIZE_TYPE__", "long unsigned int"); - defineMacro("__SIZE_WIDTH__", "32"); - defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__", "16UL"); - defineMacro("__STDC_EMBED_EMPTY__", "2"); - defineMacro("__STDC_EMBED_FOUND__", "1"); - defineMacro("__STDC_EMBED_NOT_FOUND__", "0"); - defineMacro("__STDC_HOSTED__", "1"); - defineMacro("__STDC_UTF_16__", "1"); - defineMacro("__STDC_UTF_32__", "1"); - defineMacro("__STDC__", "1"); - defineMacro("__STRICT_ANSI__", "1"); - defineMacro("__UINT16_C_SUFFIX__", ""); - defineMacro("__UINT16_FMTX__", "\"hX\""); - defineMacro("__UINT16_FMTo__", "\"ho\""); - defineMacro("__UINT16_FMTu__", "\"hu\""); - defineMacro("__UINT16_FMTx__", "\"hx\""); - defineMacro("__UINT16_MAX__", "65535"); - defineMacro("__UINT16_TYPE__", "unsigned short"); - defineMacro("__UINT32_C_SUFFIX__", "U"); - defineMacro("__UINT32_FMTX__", "\"X\""); - defineMacro("__UINT32_FMTo__", "\"o\""); - defineMacro("__UINT32_FMTu__", "\"u\""); - defineMacro("__UINT32_FMTx__", "\"x\""); - defineMacro("__UINT32_MAX__", "4294967295U"); - defineMacro("__UINT32_TYPE__", "unsigned int"); - defineMacro("__UINT64_C_SUFFIX__", "ULL"); - defineMacro("__UINT64_FMTX__", "\"llX\""); - defineMacro("__UINT64_FMTo__", "\"llo\""); - defineMacro("__UINT64_FMTu__", "\"llu\""); - defineMacro("__UINT64_FMTx__", "\"llx\""); - defineMacro("__UINT64_MAX__", "18446744073709551615ULL"); - defineMacro("__UINT64_TYPE__", "long long unsigned int"); - defineMacro("__UINT8_C_SUFFIX__", ""); - defineMacro("__UINT8_FMTX__", "\"hhX\""); - defineMacro("__UINT8_FMTo__", "\"hho\""); - defineMacro("__UINT8_FMTu__", "\"hhu\""); - defineMacro("__UINT8_FMTx__", "\"hhx\""); - defineMacro("__UINT8_MAX__", "255"); - defineMacro("__UINT8_TYPE__", "unsigned char"); - defineMacro("__UINTMAX_C_SUFFIX__", "ULL"); - defineMacro("__UINTMAX_FMTX__", "\"llX\""); - defineMacro("__UINTMAX_FMTo__", "\"llo\""); - defineMacro("__UINTMAX_FMTu__", "\"llu\""); - defineMacro("__UINTMAX_FMTx__", "\"llx\""); - defineMacro("__UINTMAX_MAX__", "18446744073709551615ULL"); - defineMacro("__UINTMAX_TYPE__", "long long unsigned int"); - defineMacro("__UINTMAX_WIDTH__", "64"); - defineMacro("__UINTPTR_FMTX__", "\"lX\""); - defineMacro("__UINTPTR_FMTo__", "\"lo\""); - defineMacro("__UINTPTR_FMTu__", "\"lu\""); - defineMacro("__UINTPTR_FMTx__", "\"lx\""); - defineMacro("__UINTPTR_MAX__", "4294967295UL"); - defineMacro("__UINTPTR_TYPE__", "long unsigned int"); - defineMacro("__UINTPTR_WIDTH__", "32"); - defineMacro("__UINT_FAST16_FMTX__", "\"hX\""); - defineMacro("__UINT_FAST16_FMTo__", "\"ho\""); - defineMacro("__UINT_FAST16_FMTu__", "\"hu\""); - defineMacro("__UINT_FAST16_FMTx__", "\"hx\""); - defineMacro("__UINT_FAST16_MAX__", "65535"); - defineMacro("__UINT_FAST16_TYPE__", "unsigned short"); - defineMacro("__UINT_FAST32_FMTX__", "\"X\""); - defineMacro("__UINT_FAST32_FMTo__", "\"o\""); - defineMacro("__UINT_FAST32_FMTu__", "\"u\""); - defineMacro("__UINT_FAST32_FMTx__", "\"x\""); - defineMacro("__UINT_FAST32_MAX__", "4294967295U"); - defineMacro("__UINT_FAST32_TYPE__", "unsigned int"); - defineMacro("__UINT_FAST64_FMTX__", "\"llX\""); - defineMacro("__UINT_FAST64_FMTo__", "\"llo\""); - defineMacro("__UINT_FAST64_FMTu__", "\"llu\""); - defineMacro("__UINT_FAST64_FMTx__", "\"llx\""); - defineMacro("__UINT_FAST64_MAX__", "18446744073709551615ULL"); - defineMacro("__UINT_FAST64_TYPE__", "long long unsigned int"); - defineMacro("__UINT_FAST8_FMTX__", "\"hhX\""); - defineMacro("__UINT_FAST8_FMTo__", "\"hho\""); - defineMacro("__UINT_FAST8_FMTu__", "\"hhu\""); - defineMacro("__UINT_FAST8_FMTx__", "\"hhx\""); - defineMacro("__UINT_FAST8_MAX__", "255"); - defineMacro("__UINT_FAST8_TYPE__", "unsigned char"); - defineMacro("__UINT_LEAST16_FMTX__", "\"hX\""); - defineMacro("__UINT_LEAST16_FMTo__", "\"ho\""); - defineMacro("__UINT_LEAST16_FMTu__", "\"hu\""); - defineMacro("__UINT_LEAST16_FMTx__", "\"hx\""); - defineMacro("__UINT_LEAST16_MAX__", "65535"); - defineMacro("__UINT_LEAST16_TYPE__", "unsigned short"); - defineMacro("__UINT_LEAST32_FMTX__", "\"X\""); - defineMacro("__UINT_LEAST32_FMTo__", "\"o\""); - defineMacro("__UINT_LEAST32_FMTu__", "\"u\""); - defineMacro("__UINT_LEAST32_FMTx__", "\"x\""); - defineMacro("__UINT_LEAST32_MAX__", "4294967295U"); - defineMacro("__UINT_LEAST32_TYPE__", "unsigned int"); - defineMacro("__UINT_LEAST64_FMTX__", "\"llX\""); - defineMacro("__UINT_LEAST64_FMTo__", "\"llo\""); - defineMacro("__UINT_LEAST64_FMTu__", "\"llu\""); - defineMacro("__UINT_LEAST64_FMTx__", "\"llx\""); - defineMacro("__UINT_LEAST64_MAX__", "18446744073709551615ULL"); - defineMacro("__UINT_LEAST64_TYPE__", "long long unsigned int"); - defineMacro("__UINT_LEAST8_FMTX__", "\"hhX\""); - defineMacro("__UINT_LEAST8_FMTo__", "\"hho\""); - defineMacro("__UINT_LEAST8_FMTu__", "\"hhu\""); - defineMacro("__UINT_LEAST8_FMTx__", "\"hhx\""); - defineMacro("__UINT_LEAST8_MAX__", "255"); - defineMacro("__UINT_LEAST8_TYPE__", "unsigned char"); - defineMacro("__USER_LABEL_PREFIX__", ""); - defineMacro("__VERSION__", "\"Clang 20.0.0git\""); - defineMacro("__WINT_MAX__", "2147483647"); - defineMacro("__WINT_TYPE__", "int"); - defineMacro("__WINT_WIDTH__", "32"); - defineMacro("__clang__", "1"); - defineMacro("__clang_literal_encoding__", "\"UTF-8\""); - defineMacro("__clang_major__", "20"); - defineMacro("__clang_minor__", "0"); - defineMacro("__clang_patchlevel__", "0"); - defineMacro("__clang_version__", "\"20.0.0git \""); - defineMacro("__clang_wide_literal_encoding__", "\"UTF-32\""); - - if (is_cxx) { - defineMacro("__cplusplus", "202400L"); - defineMacro("__cpp_aggregate_bases", "201603L"); - defineMacro("__cpp_aggregate_nsdmi", "201304L"); - defineMacro("__cpp_aggregate_paren_init", "201902L"); - defineMacro("__cpp_alias_templates", "200704L"); - defineMacro("__cpp_aligned_new", "201606L"); - defineMacro("__cpp_attributes", "200809L"); - defineMacro("__cpp_auto_cast", "202110L"); - defineMacro("__cpp_binary_literals", "201304L"); - defineMacro("__cpp_capture_star_this", "201603L"); - defineMacro("__cpp_char8_t", "202207L"); - defineMacro("__cpp_concepts", "202002"); - defineMacro("__cpp_conditional_explicit", "201806L"); - defineMacro("__cpp_consteval", "202211L"); - defineMacro("__cpp_constexpr", "202406L"); - defineMacro("__cpp_constexpr_dynamic_alloc", "201907L"); - defineMacro("__cpp_constexpr_in_decltype", "201711L"); - defineMacro("__cpp_constinit", "201907L"); - defineMacro("__cpp_decltype", "200707L"); - defineMacro("__cpp_decltype_auto", "201304L"); - defineMacro("__cpp_deduction_guides", "201703L"); - defineMacro("__cpp_delegating_constructors", "200604L"); - defineMacro("__cpp_deleted_function", "202403L"); - defineMacro("__cpp_designated_initializers", "201707L"); - defineMacro("__cpp_digit_separators", "201309L"); - defineMacro("__cpp_enumerator_attributes", "201411L"); - defineMacro("__cpp_exceptions", "199711L"); - defineMacro("__cpp_fold_expressions", "201603L"); - defineMacro("__cpp_generic_lambdas", "201707L"); - defineMacro("__cpp_guaranteed_copy_elision", "201606L"); - defineMacro("__cpp_hex_float", "201603L"); - defineMacro("__cpp_if_consteval", "202106L"); - defineMacro("__cpp_if_constexpr", "201606L"); - defineMacro("__cpp_impl_coroutine", "201902L"); - defineMacro("__cpp_impl_destroying_delete", "201806L"); - defineMacro("__cpp_impl_three_way_comparison", "201907L"); - defineMacro("__cpp_implicit_move", "202207L"); - defineMacro("__cpp_inheriting_constructors", "201511L"); - defineMacro("__cpp_init_captures", "201803L"); - defineMacro("__cpp_initializer_lists", "200806L"); - defineMacro("__cpp_inline_variables", "201606L"); - defineMacro("__cpp_lambdas", "200907L"); - defineMacro("__cpp_multidimensional_subscript", "202211L"); - defineMacro("__cpp_named_character_escapes", "202207L"); - defineMacro("__cpp_namespace_attributes", "201411L"); - defineMacro("__cpp_nested_namespace_definitions", "201411L"); - defineMacro("__cpp_noexcept_function_type", "201510L"); - defineMacro("__cpp_nontype_template_args", "201411L"); - defineMacro("__cpp_nontype_template_parameter_auto", "201606L"); - defineMacro("__cpp_nsdmi", "200809L"); - defineMacro("__cpp_pack_indexing", "202311L"); - defineMacro("__cpp_placeholder_variables", "202306L"); - defineMacro("__cpp_range_based_for", "202211L"); - defineMacro("__cpp_raw_strings", "200710L"); - defineMacro("__cpp_ref_qualifiers", "200710L"); - defineMacro("__cpp_return_type_deduction", "201304L"); - defineMacro("__cpp_rtti", "199711L"); - defineMacro("__cpp_rvalue_references", "200610L"); - defineMacro("__cpp_size_t_suffix", "202011L"); - defineMacro("__cpp_sized_deallocation", "201309L"); - defineMacro("__cpp_static_assert", "202306L"); - defineMacro("__cpp_static_call_operator", "202207L"); - defineMacro("__cpp_structured_bindings", "202403L"); - defineMacro("__cpp_template_auto", "201606L"); - defineMacro("__cpp_template_template_args", "201611L"); - defineMacro("__cpp_unicode_characters", "200704L"); - defineMacro("__cpp_unicode_literals", "200710L"); - defineMacro("__cpp_user_defined_literals", "200809L"); - defineMacro("__cpp_using_enum", "201907L"); - defineMacro("__cpp_variable_templates", "201304L"); - defineMacro("__cpp_variadic_friend", "202403L"); - defineMacro("__cpp_variadic_templates", "200704L"); - defineMacro("__cpp_variadic_using", "201611L"); - } - - defineMacro("__llvm__", "1"); - defineMacro("__private_extern__", "extern"); - defineMacro("__wasi__", "1"); - defineMacro("__wasm", "1"); - defineMacro("__wasm32", "1"); - defineMacro("__wasm32__", "1"); - defineMacro("__wasm__", "1"); - defineMacro("__wasm_bulk_memory__", "1"); - defineMacro("__wasm_bulk_memory_opt__", "1"); - defineMacro("__wasm_multivalue__", "1"); - defineMacro("__wasm_mutable_globals__", "1"); - defineMacro("__wasm_nontrapping_fptoint__", "1"); - defineMacro("__wasm_reference_types__", "1"); - defineMacro("__wasm_sign_ext__", "1"); - // clang-format off } } // namespace cxx diff --git a/tests/unit_tests/parser/c_stdlib.c b/tests/unit_tests/parser/c_stdlib.c index 8afd4cb1..19fbe8bd 100644 --- a/tests/unit_tests/parser/c_stdlib.c +++ b/tests/unit_tests/parser/c_stdlib.c @@ -1,4 +1,4 @@ -// RUN: %cxx -toolchain wasm32 -verify -xc %s +// RUN: %cxx -toolchain wasm32 -verify %s #include #include