23
23
namespace clang {
24
24
namespace interp {
25
25
26
+ static bool isNoopBuiltin (unsigned ID) {
27
+ switch (ID) {
28
+ case Builtin::BIas_const:
29
+ case Builtin::BIforward:
30
+ case Builtin::BIforward_like:
31
+ case Builtin::BImove:
32
+ case Builtin::BImove_if_noexcept:
33
+ case Builtin::BIaddressof:
34
+ case Builtin::BI__addressof:
35
+ case Builtin::BI__builtin_addressof:
36
+ case Builtin::BI__builtin_launder:
37
+ return true ;
38
+ default :
39
+ return false ;
40
+ }
41
+ return false ;
42
+ }
43
+
26
44
static unsigned callArgSize (const InterpState &S, const CallExpr *C) {
27
45
unsigned O = 0 ;
28
46
@@ -100,6 +118,8 @@ static bool retBI(InterpState &S, const CallExpr *Call, unsigned BuiltinID) {
100
118
static bool retPrimValue (InterpState &S, CodePtr OpPC,
101
119
std::optional<PrimType> &T, const CallExpr *Call,
102
120
unsigned BuiltinID) {
121
+ if (isNoopBuiltin (BuiltinID))
122
+ return true ;
103
123
104
124
if (!T) {
105
125
if (!Context::isUnevaluatedBuiltin (BuiltinID)) {
@@ -742,24 +762,14 @@ static bool interp__builtin_addressof(InterpState &S, CodePtr OpPC,
742
762
const CallExpr *Call) {
743
763
assert (Call->getArg (0 )->isLValue ());
744
764
PrimType PtrT = S.getContext ().classify (Call->getArg (0 )).value_or (PT_Ptr);
745
-
746
- if (PtrT == PT_Ptr) {
747
- const Pointer &Arg = S.Stk .peek <Pointer>();
748
- S.Stk .push <Pointer>(Arg);
749
- } else {
750
- assert (false && " Unsupported pointer type passed to __builtin_addressof()" );
751
- }
765
+ assert (PtrT == PT_Ptr &&
766
+ " Unsupported pointer type passed to __builtin_addressof()" );
752
767
return true ;
753
768
}
754
769
755
770
static bool interp__builtin_move (InterpState &S, CodePtr OpPC,
756
771
const InterpFrame *Frame,
757
772
const CallExpr *Call) {
758
-
759
- PrimType ArgT = S.getContext ().classify (Call->getArg (0 )).value_or (PT_Ptr);
760
-
761
- TYPE_SWITCH (ArgT, const T &Arg = S.Stk .peek <T>(); S.Stk .push <T>(Arg););
762
-
763
773
return Call->getDirectCallee ()->isConstexpr ();
764
774
}
765
775
@@ -775,13 +785,6 @@ static bool interp__builtin_eh_return_data_regno(InterpState &S, CodePtr OpPC,
775
785
return true ;
776
786
}
777
787
778
- // / Just takes the first Argument to the call and puts it on the stack.
779
- static bool noopPointer (InterpState &S) {
780
- const Pointer &Arg = S.Stk .peek <Pointer>();
781
- S.Stk .push <Pointer>(Arg);
782
- return true ;
783
- }
784
-
785
788
// Two integral values followed by a pointer (lhs, rhs, resultOut)
786
789
static bool interp__builtin_overflowop (InterpState &S, CodePtr OpPC,
787
790
const CallExpr *Call,
@@ -2504,6 +2507,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
2504
2507
case Builtin::BIaddressof:
2505
2508
case Builtin::BI__addressof:
2506
2509
case Builtin::BI__builtin_addressof:
2510
+ assert (isNoopBuiltin (BuiltinID));
2507
2511
if (!interp__builtin_addressof (S, OpPC, Frame, Call))
2508
2512
return false ;
2509
2513
break ;
@@ -2513,6 +2517,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
2513
2517
case Builtin::BIforward_like:
2514
2518
case Builtin::BImove:
2515
2519
case Builtin::BImove_if_noexcept:
2520
+ assert (isNoopBuiltin (BuiltinID));
2516
2521
if (!interp__builtin_move (S, OpPC, Frame, Call))
2517
2522
return false ;
2518
2523
break ;
@@ -2523,8 +2528,7 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
2523
2528
break ;
2524
2529
2525
2530
case Builtin::BI__builtin_launder:
2526
- if (!noopPointer (S))
2527
- return false ;
2531
+ assert (isNoopBuiltin (BuiltinID));
2528
2532
break ;
2529
2533
2530
2534
case Builtin::BI__builtin_add_overflow:
0 commit comments