@@ -1006,6 +1006,14 @@ inline bool CmpHelper<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
10061006 }
10071007}
10081008
1009+ static inline bool IsOpaqueConstantCall (const CallExpr *E) {
1010+ unsigned Builtin = E->getBuiltinCallee ();
1011+ return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
1012+ Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
1013+ Builtin == Builtin::BI__builtin_ptrauth_sign_constant ||
1014+ Builtin == Builtin::BI__builtin_function_start);
1015+ }
1016+
10091017template <>
10101018inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
10111019 using BoolT = PrimConv<PT_Bool>::T;
@@ -1065,11 +1073,19 @@ inline bool CmpHelperEQ<Pointer>(InterpState &S, CodePtr OpPC, CompareFn Fn) {
10651073 for (const auto &P : {LHS, RHS}) {
10661074 if (P.isZero ())
10671075 continue ;
1068- if (BothNonNull && P.pointsToLiteral () &&
1069- isa<StringLiteral>(P.getDeclDesc ()->asExpr ())) {
1070- const SourceInfo &Loc = S.Current ->getSource (OpPC);
1071- S.FFDiag (Loc, diag::note_constexpr_literal_comparison);
1072- return false ;
1076+ if (BothNonNull && P.pointsToLiteral ()) {
1077+ const Expr *E = P.getDeclDesc ()->asExpr ();
1078+ if (isa<StringLiteral>(E)) {
1079+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
1080+ S.FFDiag (Loc, diag::note_constexpr_literal_comparison);
1081+ return false ;
1082+ } else if (const auto *CE = dyn_cast<CallExpr>(E);
1083+ CE && IsOpaqueConstantCall (CE)) {
1084+ const SourceInfo &Loc = S.Current ->getSource (OpPC);
1085+ S.FFDiag (Loc, diag::note_constexpr_opaque_call_comparison)
1086+ << P.toDiagnosticString (S.getASTContext ());
1087+ return false ;
1088+ }
10731089 }
10741090 }
10751091
0 commit comments