Skip to content

Commit 57592e9

Browse files
[Clang] Fixes of builtin definitions after PR #68324. (#81022)
This commit addresses few differences between the `Builtins.def` file before the refactoring done in PR #68324 and the currently generated `Builtins.inc` file.
1 parent 8d6e867 commit 57592e9

File tree

2 files changed

+54
-28
lines changed

2 files changed

+54
-28
lines changed

clang/include/clang/Basic/Builtins.td

+52-28
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ class FPMathTemplate : Template<["float", "double", "long double"],
1212
["f", "", "l"]>;
1313

1414
class FPMathWithF16Template :
15-
Template<["float", "double", "long double", "__fp16", "__float128"],
16-
["f", "", "l", "f16", "f128"]>;
15+
Template<["float", "double", "long double", "__fp16"],
16+
["f", "", "l", "f16"]>;
1717

1818
class FPMathWithF16F128Template :
1919
Template<["float", "double", "long double", "__fp16", "__float128"],
2020
["f", "", "l", "f16", "f128"]>;
2121

22+
class FPMathWithF128Template :
23+
Template<["float", "double", "long double", "__float128"],
24+
["f", "", "l", "f128"]>;
25+
2226
class F16F128MathTemplate : Template<["__fp16", "__float128"],
2327
["f16", "f128"]>;
2428

@@ -253,18 +257,30 @@ def FrexpF16F128 : F16F128MathTemplate, Builtin {
253257
let Prototype = "T(T, int*)";
254258
}
255259

256-
def HugeVal : Builtin, FPMathWithF16F128Template {
260+
def HugeVal : Builtin, FPMathWithF128Template {
257261
let Spellings = ["__builtin_huge_val"];
258262
let Attributes = [NoThrow, Const, Constexpr];
259263
let Prototype = "T()";
260264
}
261265

262-
def Inf : Builtin, FPMathWithF16F128Template {
266+
def HugeValF16 : Builtin {
267+
let Spellings = ["__builtin_huge_valf16"];
268+
let Attributes = [NoThrow, Const, Constexpr];
269+
let Prototype = "_Float16()";
270+
}
271+
272+
def Inf : Builtin, FPMathWithF128Template {
263273
let Spellings = ["__builtin_inf"];
264274
let Attributes = [NoThrow, Const, Constexpr];
265275
let Prototype = "T()";
266276
}
267277

278+
def InfF16 : Builtin {
279+
let Spellings = ["__builtin_inff16"];
280+
let Attributes = [NoThrow, Const, Constexpr];
281+
let Prototype = "_Float16()";
282+
}
283+
268284
def LdexpF16F128 : F16F128MathTemplate, Builtin {
269285
let Spellings = ["__builtin_ldexp"];
270286
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
@@ -1550,7 +1566,7 @@ def SyncBoolCompareAndSwap : Builtin {
15501566
def SyncBoolCompareAndSwapN : Builtin, SyncBuiltinsTemplate {
15511567
let Spellings = ["__sync_bool_compare_and_swap_"];
15521568
let Attributes = [CustomTypeChecking, NoThrow];
1553-
let Prototype = "T(T volatile*, T, ...)";
1569+
let Prototype = "bool(T volatile*, T, T, ...)";
15541570
}
15551571

15561572
def SyncValCompareAndSwap : Builtin {
@@ -1562,7 +1578,7 @@ def SyncValCompareAndSwap : Builtin {
15621578
def SynLockValCompareAndSwapN : Builtin, SyncBuiltinsTemplate {
15631579
let Spellings = ["__sync_val_compare_and_swap_"];
15641580
let Attributes = [CustomTypeChecking, NoThrow];
1565-
let Prototype = "T(T volatile*, T, ...)";
1581+
let Prototype = "T(T volatile*, T, T, ...)";
15661582
}
15671583

15681584
def SyncLockTestAndSet : Builtin {
@@ -1577,16 +1593,16 @@ def SynLockLockTestAndSetN : Builtin, SyncBuiltinsTemplate {
15771593
let Prototype = "T(T volatile*, T, ...)";
15781594
}
15791595

1580-
def SyncLockReleaseN : Builtin {
1596+
def SyncLockRelease : Builtin {
15811597
let Spellings = ["__sync_lock_release"];
15821598
let Attributes = [CustomTypeChecking];
15831599
let Prototype = "void(...)";
15841600
}
15851601

1586-
def SynLockReleaseN : Builtin, SyncBuiltinsTemplate {
1602+
def SyncLockReleaseN : Builtin, SyncBuiltinsTemplate {
15871603
let Spellings = ["__sync_lock_release_"];
15881604
let Attributes = [CustomTypeChecking, NoThrow];
1589-
let Prototype = "T(T volatile*, T, ...)";
1605+
let Prototype = "void(T volatile*, ...)";
15901606
}
15911607

15921608
def SyncSwap : Builtin {
@@ -2569,6 +2585,13 @@ def Abort : LibBuiltin<"stdlib.h"> {
25692585
let AddBuiltinPrefixedAlias = 1;
25702586
}
25712587

2588+
def Abs : IntMathTemplate, LibBuiltin<"stdlib.h"> {
2589+
let Spellings = ["abs"];
2590+
let Attributes = [NoThrow, Const];
2591+
let Prototype = "T(T)";
2592+
let AddBuiltinPrefixedAlias = 1;
2593+
}
2594+
25722595
def Calloc : LibBuiltin<"stdlib.h"> {
25732596
let Spellings = ["calloc"];
25742597
let Prototype = "void*(size_t, size_t)";
@@ -3085,38 +3108,38 @@ def MemAlign : GNULibBuiltin<"malloc.h"> {
30853108

30863109
// POSIX string.h
30873110

3088-
def MemcCpy : GNULibBuiltin<"stdlib.h"> {
3111+
def MemcCpy : GNULibBuiltin<"string.h"> {
30893112
let Spellings = ["memccpy"];
30903113
let Prototype = "void*(void*, void const*, int, size_t)";
30913114
}
30923115

3093-
def MempCpy : GNULibBuiltin<"stdlib.h"> {
3116+
def MempCpy : GNULibBuiltin<"string.h"> {
30943117
let Spellings = ["mempcpy"];
30953118
let Prototype = "void*(void*, void const*, size_t)";
30963119
}
30973120

3098-
def StpCpy : GNULibBuiltin<"stdlib.h"> {
3121+
def StpCpy : GNULibBuiltin<"string.h"> {
30993122
let Spellings = ["stpcpy"];
31003123
let Attributes = [NoThrow];
31013124
let Prototype = "char*(char*, char const*)";
31023125
let AddBuiltinPrefixedAlias = 1;
31033126
}
31043127

3105-
def StpnCpy : GNULibBuiltin<"stdlib.h"> {
3128+
def StpnCpy : GNULibBuiltin<"string.h"> {
31063129
let Spellings = ["stpncpy"];
31073130
let Attributes = [NoThrow];
31083131
let Prototype = "char*(char*, char const*, size_t)";
31093132
let AddBuiltinPrefixedAlias = 1;
31103133
}
31113134

3112-
def StrDup : GNULibBuiltin<"stdlib.h"> {
3135+
def StrDup : GNULibBuiltin<"string.h"> {
31133136
let Spellings = ["strdup"];
31143137
let Attributes = [NoThrow];
31153138
let Prototype = "char*(char const*)";
31163139
let AddBuiltinPrefixedAlias = 1;
31173140
}
31183141

3119-
def StrnDup : GNULibBuiltin<"stdlib.h"> {
3142+
def StrnDup : GNULibBuiltin<"string.h"> {
31203143
let Spellings = ["strndup"];
31213144
let Attributes = [NoThrow];
31223145
let Prototype = "char*(char const*, size_t)";
@@ -3286,22 +3309,22 @@ def ObjcEnumerationMutation : ObjCLibBuiltin<"objc/runtime.h"> {
32863309
let Prototype = "void(id)";
32873310
}
32883311

3289-
def ObjcReadWeak : ObjCLibBuiltin<"objc/message.h"> {
3312+
def ObjcReadWeak : ObjCLibBuiltin<"objc/objc-auto.h"> {
32903313
let Spellings = ["objc_read_weak"];
32913314
let Prototype = "id(id*)";
32923315
}
32933316

3294-
def ObjcAssignWeak : ObjCLibBuiltin<"objc/message.h"> {
3317+
def ObjcAssignWeak : ObjCLibBuiltin<"objc/objc-auto.h"> {
32953318
let Spellings = ["objc_assign_weak"];
32963319
let Prototype = "id(id, id*)";
32973320
}
32983321

3299-
def ObjcAssignIvar : ObjCLibBuiltin<"objc/message.h"> {
3322+
def ObjcAssignIvar : ObjCLibBuiltin<"objc/objc-auto.h"> {
33003323
let Spellings = ["objc_assign_ivar"];
33013324
let Prototype = "id(id, id, ptrdiff_t)";
33023325
}
33033326

3304-
def ObjcAssignGlobal : ObjCLibBuiltin<"objc/message.h"> {
3327+
def ObjcAssignGlobal : ObjCLibBuiltin<"objc/objc-auto.h"> {
33053328
let Spellings = ["objc_assign_global"];
33063329
let Prototype = "id(id, id*)";
33073330
}
@@ -3371,13 +3394,6 @@ def Atan2 : FPMathTemplate, LibBuiltin<"math.h"> {
33713394
let AddBuiltinPrefixedAlias = 1;
33723395
}
33733396

3374-
def Abs : IntMathTemplate, LibBuiltin<"math.h"> {
3375-
let Spellings = ["abs"];
3376-
let Attributes = [NoThrow, Const];
3377-
let Prototype = "T(T)";
3378-
let AddBuiltinPrefixedAlias = 1;
3379-
}
3380-
33813397
def Copysign : FPMathTemplate, LibBuiltin<"math.h"> {
33823398
let Spellings = ["copysign"];
33833399
let Attributes = [NoThrow, Const];
@@ -3996,8 +4012,16 @@ def BlockObjectDispose : LibBuiltin<"blocks.h"> {
39964012
}
39974013
// FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
39984014

4015+
def __Addressof : LangBuiltin<"CXX_LANG"> {
4016+
let Spellings = ["__addressof"];
4017+
let Attributes = [FunctionWithoutBuiltinPrefix, NoThrow, Const,
4018+
IgnoreSignature, Constexpr];
4019+
let Prototype = "void*(void&)";
4020+
let Namespace = "std";
4021+
}
4022+
39994023
def Addressof : CxxLibBuiltin<"memory"> {
4000-
let Spellings = ["addressof", "__addressof"];
4024+
let Spellings = ["addressof"];
40014025
let Attributes = [NoThrow, Const, IgnoreSignature, RequireDeclaration,
40024026
Constexpr];
40034027
let Prototype = "void*(void&)";
@@ -4036,7 +4060,7 @@ def Move : CxxLibBuiltin<"utility"> {
40364060
let Namespace = "std";
40374061
}
40384062

4039-
def MoveIfNsoexcept : CxxLibBuiltin<"memory"> {
4063+
def MoveIfNsoexcept : CxxLibBuiltin<"utility"> {
40404064
let Spellings = ["move_if_noexcept"];
40414065
let Attributes = [NoThrow, Const, IgnoreSignature, RequireDeclaration,
40424066
Constexpr];

clang/include/clang/Basic/BuiltinsBase.td

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def UnevaluatedArguments : Attribute<"u">;
4949
// is required for a builtin.
5050
def FunctionWithBuiltinPrefix : Attribute<"F">;
5151

52+
def FunctionWithoutBuiltinPrefix : Attribute<"f">;
53+
5254
// const, but only when -fno-math-errno and FP exceptions are ignored.
5355
def ConstIgnoringErrnoAndExceptions : Attribute<"e">;
5456

0 commit comments

Comments
 (0)