@@ -247,13 +247,15 @@ class APValue {
247247 struct NoLValuePath {};
248248 struct UninitArray {};
249249 struct UninitStruct {};
250+ struct ConstexprUnknown {};
250251
251252 template <typename Impl> friend class clang ::serialization::BasicReaderBase;
252253 friend class ASTImporter ;
253254 friend class ASTNodeImporter ;
254255
255256private:
256257 ValueKind Kind;
258+ bool AllowConstexprUnknown : 1 ;
257259
258260 struct ComplexAPSInt {
259261 APSInt Real, Imag;
@@ -312,32 +314,39 @@ class APValue {
312314 DataType Data;
313315
314316public:
317+ bool allowConstexprUnknown () const { return AllowConstexprUnknown; }
318+
319+ void setConstexprUnknown (bool IsConstexprUnknown = true ) {
320+ AllowConstexprUnknown = IsConstexprUnknown;
321+ }
322+
315323 // / Creates an empty APValue of type None.
316- APValue () : Kind(None) {}
324+ APValue () : Kind(None), AllowConstexprUnknown( false ) {}
317325 // / Creates an integer APValue holding the given value.
318- explicit APValue (APSInt I) : Kind(None) {
326+ explicit APValue (APSInt I) : Kind(None), AllowConstexprUnknown( false ) {
319327 MakeInt (); setInt (std::move (I));
320328 }
321329 // / Creates a float APValue holding the given value.
322- explicit APValue (APFloat F) : Kind(None) {
330+ explicit APValue (APFloat F) : Kind(None), AllowConstexprUnknown( false ) {
323331 MakeFloat (); setFloat (std::move (F));
324332 }
325333 // / Creates a fixed-point APValue holding the given value.
326- explicit APValue (APFixedPoint FX) : Kind(None) {
334+ explicit APValue (APFixedPoint FX) : Kind(None), AllowConstexprUnknown( false ) {
327335 MakeFixedPoint (std::move (FX));
328336 }
329337 // / Creates a vector APValue with \p N elements. The elements
330338 // / are read from \p E.
331- explicit APValue (const APValue *E, unsigned N) : Kind(None) {
339+ explicit APValue (const APValue *E, unsigned N)
340+ : Kind(None), AllowConstexprUnknown(false ) {
332341 MakeVector (); setVector (E, N);
333342 }
334343 // / Creates an integer complex APValue with the given real and imaginary
335344 // / values.
336- APValue (APSInt R, APSInt I) : Kind(None) {
345+ APValue (APSInt R, APSInt I) : Kind(None), AllowConstexprUnknown( false ) {
337346 MakeComplexInt (); setComplexInt (std::move (R), std::move (I));
338347 }
339348 // / Creates a float complex APValue with the given real and imaginary values.
340- APValue (APFloat R, APFloat I) : Kind(None) {
349+ APValue (APFloat R, APFloat I) : Kind(None), AllowConstexprUnknown( false ) {
341350 MakeComplexFloat (); setComplexFloat (std::move (R), std::move (I));
342351 }
343352 APValue (const APValue &RHS);
@@ -348,7 +357,7 @@ class APValue {
348357 // / \param IsNullPtr Whether this lvalue is a null pointer.
349358 APValue (LValueBase Base, const CharUnits &Offset, NoLValuePath,
350359 bool IsNullPtr = false )
351- : Kind(None) {
360+ : Kind(None), AllowConstexprUnknown( false ) {
352361 MakeLValue ();
353362 setLValue (Base, Offset, NoLValuePath{}, IsNullPtr);
354363 }
@@ -362,31 +371,44 @@ class APValue {
362371 APValue (LValueBase Base, const CharUnits &Offset,
363372 ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
364373 bool IsNullPtr = false )
365- : Kind(None) {
374+ : Kind(None), AllowConstexprUnknown( false ) {
366375 MakeLValue ();
367376 setLValue (Base, Offset, Path, OnePastTheEnd, IsNullPtr);
368377 }
378+ // / Creates a constexpr unknown lvalue APValue.
379+ // / \param Base The base of the lvalue.
380+ // / \param Offset The offset of the lvalue.
381+ // / \param IsNullPtr Whether this lvalue is a null pointer.
382+ APValue (LValueBase Base, const CharUnits &Offset, ConstexprUnknown,
383+ bool IsNullPtr = false )
384+ : Kind(None), AllowConstexprUnknown(true ) {
385+ MakeLValue ();
386+ setLValue (Base, Offset, NoLValuePath{}, IsNullPtr);
387+ }
388+
369389 // / Creates a new array APValue.
370390 // / \param UninitArray Marker. Pass an empty UninitArray.
371391 // / \param InitElts Number of elements you're going to initialize in the
372392 // / array.
373393 // / \param Size Full size of the array.
374- APValue (UninitArray, unsigned InitElts, unsigned Size) : Kind(None) {
394+ APValue (UninitArray, unsigned InitElts, unsigned Size)
395+ : Kind(None), AllowConstexprUnknown(false ) {
375396 MakeArray (InitElts, Size);
376397 }
377398 // / Creates a new struct APValue.
378399 // / \param UninitStruct Marker. Pass an empty UninitStruct.
379400 // / \param NumBases Number of bases.
380401 // / \param NumMembers Number of members.
381- APValue (UninitStruct, unsigned NumBases, unsigned NumMembers) : Kind(None) {
402+ APValue (UninitStruct, unsigned NumBases, unsigned NumMembers)
403+ : Kind(None), AllowConstexprUnknown(false ) {
382404 MakeStruct (NumBases, NumMembers);
383405 }
384406 // / Creates a new union APValue.
385407 // / \param ActiveDecl The FieldDecl of the active union member.
386408 // / \param ActiveValue The value of the active union member.
387409 explicit APValue (const FieldDecl *ActiveDecl,
388410 const APValue &ActiveValue = APValue())
389- : Kind(None) {
411+ : Kind(None), AllowConstexprUnknown( false ) {
390412 MakeUnion ();
391413 setUnion (ActiveDecl, ActiveValue);
392414 }
@@ -395,14 +417,15 @@ class APValue {
395417 // / \param IsDerivedMember Whether member is a derived one.
396418 // / \param Path The path of the member.
397419 APValue (const ValueDecl *Member, bool IsDerivedMember,
398- ArrayRef<const CXXRecordDecl*> Path) : Kind(None) {
420+ ArrayRef<const CXXRecordDecl *> Path)
421+ : Kind(None), AllowConstexprUnknown(false ) {
399422 MakeMemberPointer (Member, IsDerivedMember, Path);
400423 }
401424 // / Creates a new address label diff APValue.
402425 // / \param LHSExpr The left-hand side of the difference.
403426 // / \param RHSExpr The right-hand side of the difference.
404- APValue (const AddrLabelExpr* LHSExpr, const AddrLabelExpr* RHSExpr)
405- : Kind(None) {
427+ APValue (const AddrLabelExpr * LHSExpr, const AddrLabelExpr * RHSExpr)
428+ : Kind(None), AllowConstexprUnknown( false ) {
406429 MakeAddrLabelDiff (); setAddrLabelDiff (LHSExpr, RHSExpr);
407430 }
408431 static APValue IndeterminateValue () {
0 commit comments