@@ -100,15 +100,15 @@ class SVal {
100
100
// / the desired type.
101
101
template <typename T>
102
102
T castAs () const {
103
- assert (T::isKind (*this ));
103
+ assert (T::classof (*this ));
104
104
return *static_cast <const T *>(this );
105
105
}
106
106
107
107
// / Convert to the specified SVal type, returning None if this SVal is
108
108
// / not of the desired type.
109
109
template <typename T>
110
110
Optional<T> getAs () const {
111
- if (!T::isKind (*this ))
111
+ if (!T::classof (*this ))
112
112
return None;
113
113
return *static_cast <const T *>(this );
114
114
}
@@ -124,13 +124,11 @@ class SVal {
124
124
ID.AddPointer (Data);
125
125
}
126
126
127
- bool operator ==(const SVal & R) const {
127
+ bool operator ==(SVal R) const {
128
128
return getRawKind () == R.getRawKind () && Data == R.Data ;
129
129
}
130
130
131
- bool operator !=(const SVal &R) const {
132
- return !(*this == R);
133
- }
131
+ bool operator !=(SVal R) const { return !(*this == R); }
134
132
135
133
bool isUnknown () const {
136
134
return getRawKind () == UnknownValKind;
@@ -221,12 +219,10 @@ class UndefinedVal : public SVal {
221
219
public:
222
220
UndefinedVal () : SVal(UndefinedValKind) {}
223
221
222
+ static bool classof (SVal V) { return V.getBaseKind () == UndefinedValKind; }
223
+
224
224
private:
225
225
friend class SVal ;
226
-
227
- static bool isKind (const SVal& V) {
228
- return V.getBaseKind () == UndefinedValKind;
229
- }
230
226
};
231
227
232
228
class DefinedOrUnknownSVal : public SVal {
@@ -236,6 +232,8 @@ class DefinedOrUnknownSVal : public SVal {
236
232
bool isUndef () const = delete;
237
233
bool isValid () const = delete;
238
234
235
+ static bool classof (SVal V) { return !V.isUndef (); }
236
+
239
237
protected:
240
238
DefinedOrUnknownSVal () = default ;
241
239
explicit DefinedOrUnknownSVal (const void *d, bool isLoc, unsigned ValKind)
@@ -244,22 +242,16 @@ class DefinedOrUnknownSVal : public SVal {
244
242
245
243
private:
246
244
friend class SVal ;
247
-
248
- static bool isKind (const SVal& V) {
249
- return !V.isUndef ();
250
- }
251
245
};
252
246
253
247
class UnknownVal : public DefinedOrUnknownSVal {
254
248
public:
255
249
explicit UnknownVal () : DefinedOrUnknownSVal(UnknownValKind) {}
256
250
251
+ static bool classof (SVal V) { return V.getBaseKind () == UnknownValKind; }
252
+
257
253
private:
258
254
friend class SVal ;
259
-
260
- static bool isKind (const SVal &V) {
261
- return V.getBaseKind () == UnknownValKind;
262
- }
263
255
};
264
256
265
257
class DefinedSVal : public DefinedOrUnknownSVal {
@@ -270,32 +262,26 @@ class DefinedSVal : public DefinedOrUnknownSVal {
270
262
bool isUnknownOrUndef () const = delete;
271
263
bool isValid () const = delete;
272
264
265
+ static bool classof (SVal V) { return !V.isUnknownOrUndef (); }
266
+
273
267
protected:
274
268
DefinedSVal () = default ;
275
269
explicit DefinedSVal (const void *d, bool isLoc, unsigned ValKind)
276
270
: DefinedOrUnknownSVal(d, isLoc, ValKind) {}
277
271
278
272
private:
279
273
friend class SVal ;
280
-
281
- static bool isKind (const SVal& V) {
282
- return !V.isUnknownOrUndef ();
283
- }
284
274
};
285
275
286
276
// / Represents an SVal that is guaranteed to not be UnknownVal.
287
277
class KnownSVal : public SVal {
288
278
friend class SVal ;
289
-
290
279
KnownSVal () = default ;
291
280
292
- static bool isKind (const SVal &V) {
293
- return !V.isUnknown ();
294
- }
295
-
296
281
public:
297
282
KnownSVal (const DefinedSVal &V) : SVal(V) {}
298
283
KnownSVal (const UndefinedVal &V) : SVal(V) {}
284
+ static bool classof (SVal V) { return !V.isUnknown (); }
299
285
};
300
286
301
287
class NonLoc : public DefinedSVal {
@@ -312,12 +298,10 @@ class NonLoc : public DefinedSVal {
312
298
T->isAnyComplexType () || T->isVectorType ();
313
299
}
314
300
301
+ static bool classof (SVal V) { return V.getBaseKind () == NonLocKind; }
302
+
315
303
private:
316
304
friend class SVal ;
317
-
318
- static bool isKind (const SVal& V) {
319
- return V.getBaseKind () == NonLocKind;
320
- }
321
305
};
322
306
323
307
class Loc : public DefinedSVal {
@@ -334,12 +318,10 @@ class Loc : public DefinedSVal {
334
318
T->isReferenceType () || T->isNullPtrType ();
335
319
}
336
320
321
+ static bool classof (SVal V) { return V.getBaseKind () == LocKind; }
322
+
337
323
private:
338
324
friend class SVal ;
339
-
340
- static bool isKind (const SVal& V) {
341
- return V.getBaseKind () == LocKind;
342
- }
343
325
};
344
326
345
327
// ==------------------------------------------------------------------------==//
@@ -365,17 +347,14 @@ class SymbolVal : public NonLoc {
365
347
return !isa<SymbolData>(getSymbol ());
366
348
}
367
349
368
- private:
369
- friend class SVal ;
370
-
371
- static bool isKind (const SVal& V) {
372
- return V.getBaseKind () == NonLocKind &&
373
- V.getSubKind () == SymbolValKind;
350
+ static bool classof (SVal V) {
351
+ return V.getBaseKind () == NonLocKind && V.getSubKind () == SymbolValKind;
374
352
}
375
353
376
- static bool isKind (const NonLoc& V) {
377
- return V.getSubKind () == SymbolValKind;
378
- }
354
+ static bool classof (NonLoc V) { return V.getSubKind () == SymbolValKind; }
355
+
356
+ private:
357
+ friend class SVal ;
379
358
};
380
359
381
360
// / Value representing integer constant.
@@ -392,19 +371,15 @@ class ConcreteInt : public NonLoc {
392
371
393
372
ConcreteInt evalMinus (SValBuilder &svalBuilder) const ;
394
373
374
+ static bool classof (SVal V) {
375
+ return V.getBaseKind () == NonLocKind && V.getSubKind () == ConcreteIntKind;
376
+ }
377
+
378
+ static bool classof (NonLoc V) { return V.getSubKind () == ConcreteIntKind; }
379
+
395
380
private:
396
381
friend class SVal ;
397
-
398
382
ConcreteInt () = default ;
399
-
400
- static bool isKind (const SVal& V) {
401
- return V.getBaseKind () == NonLocKind &&
402
- V.getSubKind () == ConcreteIntKind;
403
- }
404
-
405
- static bool isKind (const NonLoc& V) {
406
- return V.getSubKind () == ConcreteIntKind;
407
- }
408
383
};
409
384
410
385
class LocAsInteger : public NonLoc {
@@ -432,19 +407,15 @@ class LocAsInteger : public NonLoc {
432
407
return D->second ;
433
408
}
434
409
410
+ static bool classof (SVal V) {
411
+ return V.getBaseKind () == NonLocKind && V.getSubKind () == LocAsIntegerKind;
412
+ }
413
+
414
+ static bool classof (NonLoc V) { return V.getSubKind () == LocAsIntegerKind; }
415
+
435
416
private:
436
417
friend class SVal ;
437
-
438
418
LocAsInteger () = default ;
439
-
440
- static bool isKind (const SVal& V) {
441
- return V.getBaseKind () == NonLocKind &&
442
- V.getSubKind () == LocAsIntegerKind;
443
- }
444
-
445
- static bool isKind (const NonLoc& V) {
446
- return V.getSubKind () == LocAsIntegerKind;
447
- }
448
419
};
449
420
450
421
class CompoundVal : public NonLoc {
@@ -462,18 +433,15 @@ class CompoundVal : public NonLoc {
462
433
iterator begin () const ;
463
434
iterator end () const ;
464
435
465
- private:
466
- friend class SVal ;
467
-
468
- CompoundVal () = default ;
469
-
470
- static bool isKind (const SVal& V) {
436
+ static bool classof (SVal V) {
471
437
return V.getBaseKind () == NonLocKind && V.getSubKind () == CompoundValKind;
472
438
}
473
439
474
- static bool isKind (const NonLoc& V) {
475
- return V.getSubKind () == CompoundValKind;
476
- }
440
+ static bool classof (NonLoc V) { return V.getSubKind () == CompoundValKind; }
441
+
442
+ private:
443
+ friend class SVal ;
444
+ CompoundVal () = default ;
477
445
};
478
446
479
447
class LazyCompoundVal : public NonLoc {
@@ -490,19 +458,18 @@ class LazyCompoundVal : public NonLoc {
490
458
const void *getStore () const ;
491
459
const TypedValueRegion *getRegion () const ;
492
460
493
- private:
494
- friend class SVal ;
495
-
496
- LazyCompoundVal () = default ;
497
-
498
- static bool isKind (const SVal& V) {
461
+ static bool classof (SVal V) {
499
462
return V.getBaseKind () == NonLocKind &&
500
463
V.getSubKind () == LazyCompoundValKind;
501
464
}
502
465
503
- static bool isKind ( const NonLoc& V) {
466
+ static bool classof ( NonLoc V) {
504
467
return V.getSubKind () == LazyCompoundValKind;
505
468
}
469
+
470
+ private:
471
+ friend class SVal ;
472
+ LazyCompoundVal () = default ;
506
473
};
507
474
508
475
// / Value representing pointer-to-member.
@@ -540,21 +507,21 @@ class PointerToMember : public NonLoc {
540
507
iterator begin () const ;
541
508
iterator end () const ;
542
509
543
- private:
544
- friend class SVal ;
545
-
546
- PointerToMember () = default ;
547
- explicit PointerToMember (const PTMDataType D)
548
- : NonLoc(PointerToMemberKind, D.getOpaqueValue()) {}
549
-
550
- static bool isKind (const SVal& V) {
510
+ static bool classof (SVal V) {
551
511
return V.getBaseKind () == NonLocKind &&
552
512
V.getSubKind () == PointerToMemberKind;
553
513
}
554
514
555
- static bool isKind ( const NonLoc& V) {
515
+ static bool classof ( NonLoc V) {
556
516
return V.getSubKind () == PointerToMemberKind;
557
517
}
518
+
519
+ private:
520
+ friend class SVal ;
521
+
522
+ PointerToMember () = default ;
523
+ explicit PointerToMember (const PTMDataType D)
524
+ : NonLoc(PointerToMemberKind, D.getOpaqueValue()) {}
558
525
};
559
526
560
527
} // namespace nonloc
@@ -575,18 +542,15 @@ class GotoLabel : public Loc {
575
542
return static_cast <const LabelDecl *>(Data);
576
543
}
577
544
578
- private:
579
- friend class SVal ;
580
-
581
- GotoLabel () = default ;
582
-
583
- static bool isKind (const SVal& V) {
545
+ static bool classof (SVal V) {
584
546
return V.getBaseKind () == LocKind && V.getSubKind () == GotoLabelKind;
585
547
}
586
548
587
- static bool isKind (const Loc& V) {
588
- return V.getSubKind () == GotoLabelKind;
589
- }
549
+ static bool classof (Loc V) { return V.getSubKind () == GotoLabelKind; }
550
+
551
+ private:
552
+ friend class SVal ;
553
+ GotoLabel () = default ;
590
554
};
591
555
592
556
class MemRegionVal : public Loc {
@@ -616,19 +580,15 @@ class MemRegionVal : public Loc {
616
580
return getRegion () != R.getRegion ();
617
581
}
618
582
583
+ static bool classof (SVal V) {
584
+ return V.getBaseKind () == LocKind && V.getSubKind () == MemRegionValKind;
585
+ }
586
+
587
+ static bool classof (Loc V) { return V.getSubKind () == MemRegionValKind; }
588
+
619
589
private:
620
590
friend class SVal ;
621
-
622
591
MemRegionVal () = default ;
623
-
624
- static bool isKind (const SVal& V) {
625
- return V.getBaseKind () == LocKind &&
626
- V.getSubKind () == MemRegionValKind;
627
- }
628
-
629
- static bool isKind (const Loc& V) {
630
- return V.getSubKind () == MemRegionValKind;
631
- }
632
592
};
633
593
634
594
class ConcreteInt : public Loc {
@@ -639,25 +599,19 @@ class ConcreteInt : public Loc {
639
599
return *static_cast <const llvm::APSInt *>(Data);
640
600
}
641
601
602
+ static bool classof (SVal V) {
603
+ return V.getBaseKind () == LocKind && V.getSubKind () == ConcreteIntKind;
604
+ }
605
+
606
+ static bool classof (Loc V) { return V.getSubKind () == ConcreteIntKind; }
607
+
642
608
private:
643
609
friend class SVal ;
644
-
645
610
ConcreteInt () = default ;
646
-
647
- static bool isKind (const SVal& V) {
648
- return V.getBaseKind () == LocKind &&
649
- V.getSubKind () == ConcreteIntKind;
650
- }
651
-
652
- static bool isKind (const Loc& V) {
653
- return V.getSubKind () == ConcreteIntKind;
654
- }
655
611
};
656
612
657
613
} // namespace loc
658
-
659
614
} // namespace ento
660
-
661
615
} // namespace clang
662
616
663
617
#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SVALS_H
0 commit comments