@@ -247,13 +247,15 @@ class APValue {
247
247
struct NoLValuePath {};
248
248
struct UninitArray {};
249
249
struct UninitStruct {};
250
+ struct ConstexprUnknown {};
250
251
251
252
template <typename Impl> friend class clang ::serialization::BasicReaderBase;
252
253
friend class ASTImporter ;
253
254
friend class ASTNodeImporter ;
254
255
255
256
private:
256
257
ValueKind Kind;
258
+ bool AllowConstexprUnknown : 1 ;
257
259
258
260
struct ComplexAPSInt {
259
261
APSInt Real, Imag;
@@ -312,32 +314,39 @@ class APValue {
312
314
DataType Data;
313
315
314
316
public:
317
+ bool allowConstexprUnknown () const { return AllowConstexprUnknown; }
318
+
319
+ void setConstexprUnknown (bool IsConstexprUnknown = true ) {
320
+ AllowConstexprUnknown = IsConstexprUnknown;
321
+ }
322
+
315
323
// / Creates an empty APValue of type None.
316
- APValue () : Kind(None) {}
324
+ APValue () : Kind(None), AllowConstexprUnknown( false ) {}
317
325
// / Creates an integer APValue holding the given value.
318
- explicit APValue (APSInt I) : Kind(None) {
326
+ explicit APValue (APSInt I) : Kind(None), AllowConstexprUnknown( false ) {
319
327
MakeInt (); setInt (std::move (I));
320
328
}
321
329
// / Creates a float APValue holding the given value.
322
- explicit APValue (APFloat F) : Kind(None) {
330
+ explicit APValue (APFloat F) : Kind(None), AllowConstexprUnknown( false ) {
323
331
MakeFloat (); setFloat (std::move (F));
324
332
}
325
333
// / 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 ) {
327
335
MakeFixedPoint (std::move (FX));
328
336
}
329
337
// / Creates a vector APValue with \p N elements. The elements
330
338
// / 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 ) {
332
341
MakeVector (); setVector (E, N);
333
342
}
334
343
// / Creates an integer complex APValue with the given real and imaginary
335
344
// / values.
336
- APValue (APSInt R, APSInt I) : Kind(None) {
345
+ APValue (APSInt R, APSInt I) : Kind(None), AllowConstexprUnknown( false ) {
337
346
MakeComplexInt (); setComplexInt (std::move (R), std::move (I));
338
347
}
339
348
// / 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 ) {
341
350
MakeComplexFloat (); setComplexFloat (std::move (R), std::move (I));
342
351
}
343
352
APValue (const APValue &RHS);
@@ -348,7 +357,7 @@ class APValue {
348
357
// / \param IsNullPtr Whether this lvalue is a null pointer.
349
358
APValue (LValueBase Base, const CharUnits &Offset, NoLValuePath,
350
359
bool IsNullPtr = false )
351
- : Kind(None) {
360
+ : Kind(None), AllowConstexprUnknown( false ) {
352
361
MakeLValue ();
353
362
setLValue (Base, Offset, NoLValuePath{}, IsNullPtr);
354
363
}
@@ -362,31 +371,44 @@ class APValue {
362
371
APValue (LValueBase Base, const CharUnits &Offset,
363
372
ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
364
373
bool IsNullPtr = false )
365
- : Kind(None) {
374
+ : Kind(None), AllowConstexprUnknown( false ) {
366
375
MakeLValue ();
367
376
setLValue (Base, Offset, Path, OnePastTheEnd, IsNullPtr);
368
377
}
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
+
369
389
// / Creates a new array APValue.
370
390
// / \param UninitArray Marker. Pass an empty UninitArray.
371
391
// / \param InitElts Number of elements you're going to initialize in the
372
392
// / array.
373
393
// / \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 ) {
375
396
MakeArray (InitElts, Size );
376
397
}
377
398
// / Creates a new struct APValue.
378
399
// / \param UninitStruct Marker. Pass an empty UninitStruct.
379
400
// / \param NumBases Number of bases.
380
401
// / \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 ) {
382
404
MakeStruct (NumBases, NumMembers);
383
405
}
384
406
// / Creates a new union APValue.
385
407
// / \param ActiveDecl The FieldDecl of the active union member.
386
408
// / \param ActiveValue The value of the active union member.
387
409
explicit APValue (const FieldDecl *ActiveDecl,
388
410
const APValue &ActiveValue = APValue())
389
- : Kind(None) {
411
+ : Kind(None), AllowConstexprUnknown( false ) {
390
412
MakeUnion ();
391
413
setUnion (ActiveDecl, ActiveValue);
392
414
}
@@ -395,14 +417,15 @@ class APValue {
395
417
// / \param IsDerivedMember Whether member is a derived one.
396
418
// / \param Path The path of the member.
397
419
APValue (const ValueDecl *Member, bool IsDerivedMember,
398
- ArrayRef<const CXXRecordDecl*> Path) : Kind(None) {
420
+ ArrayRef<const CXXRecordDecl *> Path)
421
+ : Kind(None), AllowConstexprUnknown(false ) {
399
422
MakeMemberPointer (Member, IsDerivedMember, Path);
400
423
}
401
424
// / Creates a new address label diff APValue.
402
425
// / \param LHSExpr The left-hand side of the difference.
403
426
// / \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 ) {
406
429
MakeAddrLabelDiff (); setAddrLabelDiff (LHSExpr, RHSExpr);
407
430
}
408
431
static APValue IndeterminateValue () {
0 commit comments