clang: include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
17
31#include "llvm/ADT/DenseMap.h"
32#include "llvm/ADT/FoldingSet.h"
33#include "llvm/ADT/PointerIntPair.h"
34#include "llvm/ADT/iterator_range.h"
35#include "llvm/Support/Allocator.h"
36#include "llvm/Support/Casting.h"
37#include "llvm/Support/ErrorHandling.h"
38#include
39#include
40#include
41#include
42#include
43#include
44
46
47class AnalysisDeclContext;
48class CXXRecordDecl;
50class LocationContext;
51class StackFrameContext;
52
53namespace ento {
54
55class CodeTextRegion;
56class MemRegion;
57class MemRegionManager;
58class MemSpaceRegion;
59class SValBuilder;
60class SymbolicRegion;
61class VarRegion;
62
63
65
67
68
69 int64_t Offset;
70
71public:
72
73
74 static const int64_t Symbolic = std::numeric_limits<int64_t>::max();
75
78
79
81
83
86 return Offset;
87 }
88
89 bool isValid() const { return R; }
90};
91
92
93
94
95
96
97class MemRegion : public llvm::FoldingSetNode {
98public:
100#define REGION(Id, Parent) Id ## Kind,
101#define REGION_RANGE(Id, First, Last) BEGIN_##Id = First, END_##Id = Last,
102#include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
103#undef REGION
104#undef REGION_RANGE
105 };
106
107private:
108 const Kind kind;
109 mutable std::optional cachedOffset;
110
111protected:
114
115public:
117
118 virtual void Profile(llvm::FoldingSetNodeID& ID) const = 0;
119
121
123
125
126
127
128 LLVM_ATTRIBUTE_RETURNS_NONNULL
130
131
132
134
135 LLVM_ATTRIBUTE_RETURNS_NONNULL
137
138
139
140
142
144
146
148
149
151
152
154
155 virtual void dumpToStream(raw_ostream &os) const;
156
157 void dump() const;
158
159
161
162
163 virtual void printPretty(raw_ostream &os) const;
164
165
166
168
169
170
171
172
174
176
178
179 template const RegionTy* getAs() const;
180 template
181 LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy *castAs() const;
182
184
185
186
187
188
189
190
191
192
194
195
196
197
198
199
200
201
202
204};
205
206
207
209protected:
211
214 }
215
217
218public:
220
221 void Profile(llvm::FoldingSetNodeID &ID) const override;
222
225 return k >= BEGIN_MEMSPACES && k <= END_MEMSPACES;
226 }
227};
228
229
230
233
236
237public:
238 void dumpToStream(raw_ostream &os) const override;
239
241 return R->getKind() == CodeSpaceRegionKind;
242 }
243};
244
246 virtual void anchor();
247
248protected:
251 }
252
253public:
256 return k >= BEGIN_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
257 }
258};
259
260
261
262
263
264
267
269
272 assert(cr);
273 }
274
275public:
276 void Profile(llvm::FoldingSetNodeID &ID) const override;
277
278 void dumpToStream(raw_ostream &os) const override;
279
280 LLVM_ATTRIBUTE_RETURNS_NONNULL
282
284 return R->getKind() == StaticGlobalSpaceRegionKind;
285 }
286};
287
288
289
290
291
292
293
295 void anchor() override;
296
297protected:
301 }
302
303public:
306 return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
307 k <= END_NON_STATIC_GLOBAL_MEMSPACES;
308 }
309};
310
311
312
315
318
319public:
320 void dumpToStream(raw_ostream &os) const override;
321
323 return R->getKind() == GlobalSystemSpaceRegionKind;
324 }
325};
326
327
328
329
330
331
334
337
338public:
339 void dumpToStream(raw_ostream &os) const override;
340
342 return R->getKind() == GlobalImmutableSpaceRegionKind;
343 }
344};
345
346
347
348
351
354
355public:
356 void dumpToStream(raw_ostream &os) const override;
357
359 return R->getKind() == GlobalInternalSpaceRegionKind;
360 }
361};
362
365
368
369public:
370 void dumpToStream(raw_ostream &os) const override;
371
373 return R->getKind() == HeapSpaceRegionKind;
374 }
375};
376
379
382
383public:
384 void dumpToStream(raw_ostream &os) const override;
385
387 return R->getKind() == UnknownSpaceRegionKind;
388 }
389};
390
392 virtual void anchor();
393
395
396protected:
400 assert(sfc);
401 }
402
403public:
404 LLVM_ATTRIBUTE_RETURNS_NONNULL
406
407 void Profile(llvm::FoldingSetNodeID &ID) const override;
408
411 return k >= BEGIN_STACK_MEMSPACES && k <= END_STACK_MEMSPACES;
412 }
413};
414
417
420
421public:
422 void dumpToStream(raw_ostream &os) const override;
423
425 return R->getKind() == StackLocalsSpaceRegionKind;
426 }
427};
428
430private:
432
434 : StackSpaceRegion(mgr, StackArgumentsSpaceRegionKind, sfc) {}
435
436public:
437 void dumpToStream(raw_ostream &os) const override;
438
440 return R->getKind() == StackArgumentsSpaceRegionKind;
441 }
442};
443
444
445
447 virtual void anchor();
448
449protected:
451
454 assert(sReg);
455 }
456
457public:
458 LLVM_ATTRIBUTE_RETURNS_NONNULL
461 }
462
464
466
468 return R->getKind() > END_MEMSPACES;
469 }
470};
471
472
473
474
475
476
477
480
481
482
483 unsigned Cnt;
484
485 const Expr *Ex;
486
489 assert(Ex);
490 }
491
492 static void ProfileRegion(llvm::FoldingSetNodeID& ID, const Expr *Ex,
494
495public:
496 LLVM_ATTRIBUTE_RETURNS_NONNULL
498
500
501 void Profile(llvm::FoldingSetNodeID& ID) const override;
502
503 void dumpToStream(raw_ostream &os) const override;
504
506 return R->getKind() == AllocaRegionKind;
507 }
508};
509
510
512 void anchor() override;
513
514protected:
517 }
518
519public:
521
524 }
525
527
529 unsigned k = R->getKind();
530 return k >= BEGIN_TYPED_REGIONS && k <= END_TYPED_REGIONS;
531 }
532};
533
534
536 void anchor() override;
537
538protected:
541 }
542
543public:
545
547
553 }
554
557 return T.getTypePtrOrNull() ? T.getDesugaredType(Context) : T;
558 }
559
561 unsigned k = R->getKind();
562 return k >= BEGIN_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
563 }
564};
565
567 void anchor() override;
568
569protected:
572 }
573
574public:
576
579 return k >= BEGIN_CODE_TEXT_REGIONS && k <= END_CODE_TEXT_REGIONS;
580 }
581};
582
583
586
588
590 : CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
591 assert(isa(fd) || isa(fd));
592 }
593
594 static void ProfileRegion(llvm::FoldingSetNodeID& ID, const NamedDecl *FD,
596
597public:
600 if (const auto *D = dyn_cast(FD)) {
602 }
603
604 assert(isa(FD));
605 assert(false && "Getting the type of ObjCMethod is not supported yet");
606
607
608
609 return {};
610 }
611
613 return FD;
614 }
615
616 void dumpToStream(raw_ostream &os) const override;
617
618 void Profile(llvm::FoldingSetNodeID& ID) const override;
619
621 return R->getKind() == FunctionCodeRegionKind;
622 }
623};
624
625
626
627
628
629
630
633
637
640 : CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {
641 assert(bd);
642 assert(ac);
644 }
645
646 static void ProfileRegion(llvm::FoldingSetNodeID& ID, const BlockDecl *BD,
649
650public:
652 return locTy;
653 }
654
655 LLVM_ATTRIBUTE_RETURNS_NONNULL
657 return BD;
658 }
659
660 LLVM_ATTRIBUTE_RETURNS_NONNULL
662
663 void dumpToStream(raw_ostream &os) const override;
664
665 void Profile(llvm::FoldingSetNodeID& ID) const override;
666
668 return R->getKind() == BlockCodeRegionKind;
669 }
670};
671
672
673
674
675
676
677
680
683 unsigned BlockCount;
684 void *ReferencedVars = nullptr;
685 void *OriginalVars = nullptr;
686
689 : TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
690 BlockCount(count) {
691 assert(bc);
693 assert(lc);
694 assert(isa(sreg) ||
695 isa(sreg) ||
696 isa(sreg));
697 }
698
699 static void ProfileRegion(llvm::FoldingSetNodeID&, const BlockCodeRegion *,
702
703public:
704 LLVM_ATTRIBUTE_RETURNS_NONNULL
706
707 LLVM_ATTRIBUTE_RETURNS_NONNULL
709
711
714 const MemRegion * const *OriginalR;
715
716 public:
718 const MemRegion * const *originalR)
719 : R(r), OriginalR(originalR) {}
720
721 LLVM_ATTRIBUTE_RETURNS_NONNULL
723 return cast(*R);
724 }
725
726 LLVM_ATTRIBUTE_RETURNS_NONNULL
728 return cast(*OriginalR);
729 }
730
732 assert((R == nullptr) == (I.R == nullptr));
733 return I.R == R;
734 }
735
737 assert((R == nullptr) == (I.R == nullptr));
738 return I.R != R;
739 }
740
742 ++R;
743 ++OriginalR;
744 return *this;
745 }
746
747
748
749
751 };
752
753
754
756
759 llvm::iterator_range<referenced_vars_iterator> referenced_vars() const;
760
761 void dumpToStream(raw_ostream &os) const override;
762
763 void Profile(llvm::FoldingSetNodeID& ID) const override;
764
766 return R->getKind() == BlockDataRegionKind;
767 }
768
769private:
770 void LazyInitializeReferencedVars();
771 std::pair<const VarRegion *, const VarRegion *>
772 getCaptureRegions(const VarDecl *VD);
773};
774
775
776
777
778
779
782
784
786 : SubRegion(sreg, SymbolicRegionKind), sym(s) {
787
788
789 assert(isa_and_nonnull(s));
790 assert(s->getType()->isAnyPointerType() ||
791 s->getType()->isReferenceType() ||
792 s->getType()->isBlockPointerType());
793 assert(isa(sreg) || isa(sreg) ||
794 isa(sreg));
795 }
796
797public:
798
800
801
802
803
804
805
806
807
808
811 }
812
814
815 void Profile(llvm::FoldingSetNodeID& ID) const override;
816
820
821 void dumpToStream(raw_ostream &os) const override;
822
824 return R->getKind() == SymbolicRegionKind;
825 }
826};
827
828
831
833
836 assert(str);
837 }
838
839 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
842
843public:
844 LLVM_ATTRIBUTE_RETURNS_NONNULL
846
848
850
851 void Profile(llvm::FoldingSetNodeID& ID) const override {
853 }
854
855 void dumpToStream(raw_ostream &os) const override;
856
858 return R->getKind() == StringRegionKind;
859 }
860};
861
862
865
867
871 assert(str);
872 }
873
874 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
877
878public:
879 LLVM_ATTRIBUTE_RETURNS_NONNULL
881
883
885
886 void Profile(llvm::FoldingSetNodeID& ID) const override {
888 }
889
890 void dumpToStream(raw_ostream &os) const override;
891
893 return R->getKind() == ObjCStringRegionKind;
894 }
895};
896
897
898
899
902
904
907 : TypedValueRegion(sReg, CompoundLiteralRegionKind), CL(cl) {
908 assert(cl);
909 assert(isa(sReg) ||
910 isa(sReg));
911 }
912
913 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
916
917public:
919
921
922 void Profile(llvm::FoldingSetNodeID& ID) const override;
923
924 void dumpToStream(raw_ostream &os) const override;
925
926 LLVM_ATTRIBUTE_RETURNS_NONNULL
928
930 return R->getKind() == CompoundLiteralRegionKind;
931 }
932};
933
935protected:
938 }
939
940public:
941
943
945 unsigned k = R->getKind();
946 return k >= BEGIN_DECL_REGIONS && k <= END_DECL_REGIONS;
947 }
948};
949
952
953protected:
954
956
957
958
959
960 assert(isa(sReg) || isa(sReg) ||
961 isa(sReg) || isa(sReg));
962 }
963
964public:
965
967
968
970
972
974 }
975
977 unsigned k = R->getKind();
978 return k >= BEGIN_VAR_REGIONS && k <= END_VAR_REGIONS;
979 }
980};
981
984
986
987
989 : VarRegion(sReg, NonParamVarRegionKind), VD(vd) {
990
991
992
993
994 assert(isa(sReg) || isa(sReg) ||
995 isa(sReg) || isa(sReg));
996 assert(vd);
997 }
998
999 static void ProfileRegion(llvm::FoldingSetNodeID &ID, const VarDecl *VD,
1001
1002public:
1003 void Profile(llvm::FoldingSetNodeID &ID) const override;
1004
1005 LLVM_ATTRIBUTE_RETURNS_NONNULL
1007
1009
1011 }
1012
1013 void dumpToStream(raw_ostream &os) const override;
1014
1016
1018
1020 return R->getKind() == NonParamVarRegionKind;
1021 }
1022};
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1036
1037 const Expr *OriginExpr;
1038 unsigned Index;
1039
1041 : VarRegion(SReg, ParamVarRegionKind), OriginExpr(OE), Index(Idx) {
1042 assert(!cast(SReg)->getStackFrame()->inTopFrame());
1043 assert(OriginExpr);
1044 }
1045
1046 static void ProfileRegion(llvm::FoldingSetNodeID &ID, const Expr *OE,
1047 unsigned Idx, const MemRegion *SReg);
1048
1049public:
1050 LLVM_ATTRIBUTE_RETURNS_NONNULL
1053
1054 void Profile(llvm::FoldingSetNodeID& ID) const override;
1055
1056 void dumpToStream(raw_ostream &os) const override;
1057
1059
1060
1062
1065
1067 return R->getKind() == ParamVarRegionKind;
1068 }
1069};
1070
1071
1072
1073
1076
1080 ThisPointerTy(thisPointerTy) {
1082 "Invalid region type!");
1083 }
1084
1085 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1088
1089public:
1090 void Profile(llvm::FoldingSetNodeID &ID) const override;
1091
1093 return QualType(ThisPointerTy, 0);
1094 }
1095
1096 void dumpToStream(raw_ostream &os) const override;
1097
1099 return R->getKind() == CXXThisRegionKind;
1100 }
1101
1102private:
1104};
1105
1108
1110
1112 : DeclRegion(sReg, FieldRegionKind), FD(fd) {
1113 assert(FD);
1114 }
1115
1116 static void ProfileRegion(llvm::FoldingSetNodeID &ID, const FieldDecl *FD,
1118 ID.AddInteger(static_cast<unsigned>(FieldRegionKind));
1119 ID.AddPointer(FD);
1121 }
1122
1123public:
1124 LLVM_ATTRIBUTE_RETURNS_NONNULL
1126
1127 void Profile(llvm::FoldingSetNodeID &ID) const override;
1128
1130
1132 }
1133
1134 void dumpToStream(raw_ostream &os) const override;
1135
1137 void printPretty(raw_ostream &os) const override;
1140
1142 return R->getKind() == FieldRegionKind;
1143 }
1144};
1145
1148
1150
1152
1153 static void ProfileRegion(llvm::FoldingSetNodeID& ID, const ObjCIvarDecl *ivd,
1155
1156public:
1157 LLVM_ATTRIBUTE_RETURNS_NONNULL
1159
1160 void Profile(llvm::FoldingSetNodeID& ID) const override;
1161
1163
1166
1167 void dumpToStream(raw_ostream &os) const override;
1168
1170 return R->getKind() == ObjCIvarRegionKind;
1171 }
1172};
1173
1174
1175
1176
1177
1180
1183
1185 : Region(reg), Offset(offset) {}
1186
1187public:
1188
1190
1191
1193
1195 void dump() const;
1196};
1197
1198
1201
1204
1206 : TypedValueRegion(sReg, ElementRegionKind), ElementType(elementType),
1207 Index(Idx) {
1208 assert((!isanonloc::ConcreteInt(Idx) ||
1210 "The index must be signed");
1211 assert(!elementType.isNull() && !elementType->isVoidType() &&
1212 "Invalid region type!");
1213 }
1214
1215 static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType elementType,
1217
1218public:
1220
1222
1224
1225
1227
1228 void dumpToStream(raw_ostream &os) const override;
1229
1230 void Profile(llvm::FoldingSetNodeID& ID) const override;
1231
1233 return R->getKind() == ElementRegionKind;
1234 }
1235};
1236
1237
1240
1241 Expr const *Ex;
1242
1245 assert(E);
1246 assert(isa(sReg));
1247 }
1248
1249 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1251
1252public:
1253 LLVM_ATTRIBUTE_RETURNS_NONNULL
1255
1256 LLVM_ATTRIBUTE_RETURNS_NONNULL
1258
1260
1261 void dumpToStream(raw_ostream &os) const override;
1262
1263 void Profile(llvm::FoldingSetNodeID &ID) const override;
1264
1266 return R->getKind() == CXXTempObjectRegionKind;
1267 }
1268};
1269
1270
1271
1274
1275 Expr const *Ex;
1277
1280 : TypedValueRegion(sReg, CXXLifetimeExtendedObjectRegionKind), Ex(E),
1281 ExD(D) {
1282 assert(E);
1283 assert(D);
1284 assert((isa<StackLocalsSpaceRegion, GlobalInternalSpaceRegion>(sReg)));
1285 }
1286
1287 static void ProfileRegion(llvm::FoldingSetNodeID &ID, Expr const *E,
1289
1290public:
1291 LLVM_ATTRIBUTE_RETURNS_NONNULL
1293 LLVM_ATTRIBUTE_RETURNS_NONNULL
1295
1297
1299
1300 void dumpToStream(raw_ostream &os) const override;
1301
1302 void Profile(llvm::FoldingSetNodeID &ID) const override;
1303
1305 return R->getKind() == CXXLifetimeExtendedObjectRegionKind;
1306 }
1307};
1308
1309
1310
1313
1314 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> Data;
1315
1319 assert(RD);
1320 }
1321
1322 static void ProfileRegion(llvm::FoldingSetNodeID &ID, const CXXRecordDecl *RD,
1323 bool IsVirtual, const MemRegion *SReg);
1324
1325public:
1326 LLVM_ATTRIBUTE_RETURNS_NONNULL
1329
1331
1332 void dumpToStream(raw_ostream &os) const override;
1333
1334 void Profile(llvm::FoldingSetNodeID &ID) const override;
1335
1337
1339
1341 return region->getKind() == CXXBaseObjectRegionKind;
1342 }
1343};
1344
1345
1346
1347
1348
1349
1352
1354
1356 : TypedValueRegion(SReg, CXXDerivedObjectRegionKind), DerivedD(DerivedD) {
1357 assert(DerivedD);
1358
1359
1360
1362 "Should have unwrapped a base region instead!");
1363 }
1364
1365 static void ProfileRegion(llvm::FoldingSetNodeID &ID, const CXXRecordDecl *RD,
1367
1368public:
1369 LLVM_ATTRIBUTE_RETURNS_NONNULL
1371
1373
1374 void dumpToStream(raw_ostream &os) const override;
1375
1376 void Profile(llvm::FoldingSetNodeID &ID) const override;
1377
1379
1381
1383 return region->getKind() == CXXDerivedObjectRegionKind;
1384 }
1385};
1386
1387template
1389 if (const auto *RT = dyn_cast(this))
1390 return RT;
1391
1392 return nullptr;
1393}
1394
1395template
1397 return cast(this);
1398}
1399
1400
1401
1402
1403
1406 llvm::BumpPtrAllocator& A;
1407
1408 llvm::FoldingSet Regions;
1409
1413
1414 llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *>
1415 StackLocalsSpaceRegions;
1416 llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *>
1417 StackArgumentsSpaceRegions;
1418 llvm::DenseMap<const CodeTextRegion *, StaticGlobalSpaceRegion *>
1419 StaticsGlobalSpaceRegions;
1420
1424
1425public:
1428
1431
1433
1434
1435
1438
1439
1440
1443
1444
1445
1448
1449
1450
1452 MemRegion::Kind K = MemRegion::GlobalInternalSpaceRegionKind,
1454
1455
1456
1458
1459
1460
1462
1464
1465
1468
1469
1470
1474
1475
1476
1479
1480
1481
1484
1485
1487
1489
1491
1492
1493
1495
1496
1497
1500
1501
1502
1504 unsigned Index,
1506
1507
1508
1512
1517 }
1518
1519
1520
1521
1522
1525
1529 }
1530
1531
1532
1533
1534
1537
1540
1541
1542
1546
1547
1548
1549
1550
1553
1554
1555
1556
1557
1560 bool IsVirtual);
1561
1562
1563
1569 }
1570
1571
1572
1573
1574
1578
1583
1584
1585
1586
1587
1590 unsigned blockCount);
1591
1592private:
1593 template <typename RegionTy, typename SuperTy,
1594 typename Arg1Ty>
1595 RegionTy* getSubRegion(const Arg1Ty arg1,
1596 const SuperTy* superRegion);
1597
1598 template <typename RegionTy, typename SuperTy,
1599 typename Arg1Ty, typename Arg2Ty>
1600 RegionTy* getSubRegion(const Arg1Ty arg1, const Arg2Ty arg2,
1601 const SuperTy* superRegion);
1602
1603 template <typename RegionTy, typename SuperTy,
1604 typename Arg1Ty, typename Arg2Ty, typename Arg3Ty>
1605 RegionTy* getSubRegion(const Arg1Ty arg1, const Arg2Ty arg2,
1606 const Arg3Ty arg3,
1607 const SuperTy* superRegion);
1608
1609 template
1610 const REG* LazyAllocate(REG*& region);
1611
1612 template <typename REG, typename ARG>
1613 const REG* LazyAllocate(REG*& region, ARG a);
1614};
1615
1616
1617
1618
1619
1622}
1623
1624
1625
1626
1627
1628
1630 using StorageTypeForKinds = unsigned char;
1631
1632 llvm::DenseMap<const MemRegion *, StorageTypeForKinds> MRTraitsMap;
1633 llvm::DenseMap<SymbolRef, StorageTypeForKinds> SymTraitsMap;
1634
1635 using const_region_iterator =
1636 llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator;
1637 using const_symbol_iterator =
1638 llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator;
1639
1640public:
1641
1643
1645
1646
1648
1649
1651
1652
1653
1655
1656
1657
1659
1664};
1665
1666
1667
1668
1671 return os;
1672}
1673
1674}
1675
1676}
1677
1678#endif
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents a C++ struct/union/class.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
CompoundLiteralExpr - [C99 6.5.2.5].
This represents one expression.
Represents a member of a struct/union/class.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
This represents a decl that may have a name.
ObjCIvarDecl - Represents an ObjC instance variable.
Represents a class type in Objective C.
ObjCStringLiteral, used for Objective-C string literals i.e.
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack (based on CallEvent).
StringLiteral - This represents a string literal expression, e.g.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
const T * getAs() const
Member-template getAs'.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
bool isBoundable() const override
BlockCodeRegion - A region that represents code texts of blocks (closures).
QualType getLocationType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
bool operator==(const referenced_vars_iterator &I) const
const referenced_vars_iterator & operator*() const
bool operator!=(const referenced_vars_iterator &I) const
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarRegion * getCapturedRegion() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarRegion * getOriginalRegion() const
referenced_vars_iterator & operator++()
referenced_vars_iterator(const MemRegion *const *r, const MemRegion *const *originalR)
BlockDataRegion - A region that represents a block instance.
const VarRegion * getOriginalRegion(const VarRegion *VR) const
Return the original region for a captured region, if one exists.
QualType getLocationType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
static bool classof(const MemRegion *R)
referenced_vars_iterator referenced_vars_begin() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockCodeRegion * getCodeRegion() const
void Profile(llvm::FoldingSetNodeID &ID) const override
referenced_vars_iterator referenced_vars_end() const
void dumpToStream(raw_ostream &os) const override
llvm::iterator_range< referenced_vars_iterator > referenced_vars() const
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
static bool classof(const MemRegion *region)
void dumpToStream(raw_ostream &os) const override
QualType getValueType() const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *region)
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const ValueDecl * getExtendingDecl() const
void dumpToStream(raw_ostream &os) const override
const StackFrameContext * getStackFrame() const
It might return null.
QualType getValueType() const override
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
CXXThisRegion - Represents the region for the implicit 'this' parameter in a call to a C++ method.
QualType getValueType() const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
CodeSpaceRegion - The memory space that holds the executable code of functions and blocks.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
CodeTextRegion(const MemSpaceRegion *sreg, Kind k)
static bool classof(const MemRegion *R)
bool isBoundable() const override
CompoundLiteralRegion - A memory region representing a compound literal.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CompoundLiteralExpr * getLiteralExpr() const
QualType getValueType() const override
bool isBoundable() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
DeclRegion(const MemRegion *sReg, Kind k)
virtual const ValueDecl * getDecl() const =0
static bool classof(const MemRegion *R)
ElementRegion is used to represent both array elements and casts.
static bool classof(const MemRegion *R)
QualType getValueType() const override
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID) const override
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
static bool classof(const MemRegion *R)
bool canPrintPretty() const override
Returns true if this region can be printed in a user-friendly way.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void dumpToStream(raw_ostream &os) const override
QualType getValueType() const override
void printPretty(raw_ostream &os) const override
Print the region for use in diagnostics.
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const FieldDecl * getDecl() const override
FunctionCodeRegion - A region that represents code texts of function.
static bool classof(const MemRegion *R)
QualType getLocationType() const override
const NamedDecl * getDecl() const
void dumpToStream(raw_ostream &os) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
The region containing globals which are considered not to be modified or point to data which could be...
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
The region containing globals which can be modified by calls to "internally" defined functions - (for...
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
The region containing globals which are defined in system/external headers and are considered modifia...
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
GlobalsSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
const HeapSpaceRegion * getHeapRegion()
getHeapRegion - Retrieve the memory region associated with the generic "heap".
const StackArgumentsSpaceRegion * getStackArgumentsRegion(const StackFrameContext *STC)
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the...
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const LocationContext *LC)
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
llvm::BumpPtrAllocator & getAllocator()
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
const ASTContext & getContext() const
const UnknownSpaceRegion * getUnknownRegion()
getUnknownRegion - Retrieve the memory region associated with unknown memory space.
const CXXDerivedObjectRegion * getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super)
Create a CXXDerivedObjectRegion with the given derived class for region Super.
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const LocationContext *LC)
getAllocaRegion - Retrieve a region associated with a call to alloca().
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, const ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type,...
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const NonParamVarRegion * getNonParamVarRegion(const VarDecl *VD, const MemRegion *superR)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const FieldRegion * getFieldRegionWithSuper(const FieldRegion *FR, const SubRegion *superRegion)
const StackLocalsSpaceRegion * getStackLocalsRegion(const StackFrameContext *STC)
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
const ObjCStringRegion * getObjCStringRegion(const ObjCStringLiteral *Str)
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
const StringRegion * getStringRegion(const StringLiteral *Str)
ASTContext & getContext()
DefinedOrUnknownSVal getStaticSize(const MemRegion *MR, SValBuilder &SVB) const
const ParamVarRegion * getParamVarRegion(const Expr *OriginExpr, unsigned Index, const LocationContext *LC)
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr,...
const CodeSpaceRegion * getCodeRegion()
const CXXLifetimeExtendedObjectRegion * getCXXLifetimeExtendedObjectRegion(Expr const *Ex, ValueDecl const *VD, LocationContext const *LC)
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by local referen...
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, LocationContext const *LC)
const GlobalsSpaceRegion * getGlobalsRegion(MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
getGlobalsRegion - Retrieve the memory region associated with global variables.
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
Retrieve or create a "symbolic" memory region.
const ElementRegion * getElementRegionWithSuper(const ElementRegion *ER, const SubRegion *superRegion)
const FunctionCodeRegion * getFunctionCodeRegion(const NamedDecl *FD)
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
const CXXLifetimeExtendedObjectRegion * getCXXStaticLifetimeExtendedObjectRegion(const Expr *Ex, ValueDecl const *VD)
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by static refere...
const CXXBaseObjectRegion * getCXXBaseObjectRegionWithSuper(const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion)
Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region.
MemRegion - The root abstract class for all memory regions.
virtual bool canPrintPrettyAsExpr() const
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getMemorySpace() const
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
bool hasStackParametersStorage() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy * castAs() const
virtual bool isBoundable() const
StringRef getKindStr() const
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
bool hasStackStorage() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
ASTContext & getContext() const
std::string getDescriptiveName(bool UseQuotes=true) const
Get descriptive name for memory region.
virtual bool isSubRegionOf(const MemRegion *R) const
Check if the region is a subregion of the given region.
virtual void dumpToStream(raw_ostream &os) const
const SymbolicRegion * getSymbolicBase() const
If this is a symbolic region, returns the region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
virtual void printPretty(raw_ostream &os) const
Print the region for use in diagnostics.
virtual void printPrettyAsExpr(raw_ostream &os) const
Print the region as expression.
bool hasStackNonParametersStorage() const
std::string getString() const
Get a string representation of a region for debug use.
const RegionTy * getAs() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getMostDerivedObjectRegion() const
Recursively retrieve the region of the most derived class instance of regions of C++ base class insta...
virtual MemRegionManager & getMemRegionManager() const =0
virtual bool canPrintPretty() const
Returns true if this region can be printed in a user-friendly way.
SourceRange sourceRange() const
Retrieve source range from memory region.
MemSpaceRegion - A memory region that represents a "memory space"; for example, the set of global var...
MemRegionManager & getMemRegionManager() const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
bool isBoundable() const override
MemSpaceRegion(MemRegionManager &mgr, Kind k)
QualType getValueType() const override
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarDecl * getDecl() const override
static bool classof(const MemRegion *R)
The region for all the non-static global variables.
NonStaticGlobalSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
static bool classof(const MemRegion *R)
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCIvarDecl * getDecl() const override
void dumpToStream(raw_ostream &os) const override
The region associated with an ObjCStringLiteral.
QualType getValueType() const override
bool isBoundable() const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCStringLiteral * getObjCStringLiteral() const
void Profile(llvm::FoldingSetNodeID &ID) const override
ParamVarRegion - Represents a region for paremters.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getOriginExpr() const
static bool classof(const MemRegion *R)
const ParmVarDecl * getDecl() const override
TODO: What does this return?
unsigned getIndex() const
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Information about invalidation for a particular region/symbol.
InvalidationKinds
Describes different invalidation traits.
@ TK_PreserveContents
Tells that a region's contents is not changed.
@ TK_DoNotInvalidateSuperRegion
@ TK_EntireMemSpace
When applied to a MemSpaceRegion, indicates the entire memory space should be invalidated.
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
void setTrait(SymbolRef Sym, InvalidationKinds IK)
Represent a region's offset within the top level base region.
static const int64_t Symbolic
bool hasSymbolicOffset() const
const MemRegion * getRegion() const
It might return null.
RegionOffset(const MemRegion *r, int64_t off)
int64_t getOffset() const
CharUnits getOffset() const
void dumpToStream(raw_ostream &os) const
const MemRegion * getRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
StackSpaceRegion(MemRegionManager &mgr, Kind k, const StackFrameContext *sfc)
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
void Profile(llvm::FoldingSetNodeID &ID) const override
The region of the static variables within the current CodeTextRegion scope.
void Profile(llvm::FoldingSetNodeID &ID) const override
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const CodeTextRegion * getCodeRegion() const
StringRegion - Region associated with a StringLiteral.
static bool classof(const MemRegion *R)
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
bool isBoundable() const override
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const StringLiteral * getStringLiteral() const
SubRegion - A region that subsets another larger region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
static bool classof(const MemRegion *R)
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
SubRegion(const MemRegion *sReg, Kind k)
const MemRegion * superRegion
MemRegionManager & getMemRegionManager() const override
virtual QualType getType() const =0
SymbolicRegion - A special, "non-concrete" region.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
bool isBoundable() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
SymbolRef getSymbol() const
It might return null.
static void ProfileRegion(llvm::FoldingSetNodeID &ID, SymbolRef sym, const MemRegion *superRegion)
QualType getPointeeStaticType() const
Gets the type of the wrapped symbol.
TypedRegion - An abstract class representing regions that are typed.
QualType getDesugaredLocationType(ASTContext &Context) const
bool isBoundable() const override
virtual QualType getLocationType() const =0
TypedRegion(const MemRegion *sReg, Kind k)
static bool classof(const MemRegion *R)
TypedValueRegion - An abstract class representing regions having a typed value.
virtual QualType getValueType() const =0
QualType getLocationType() const override
static bool classof(const MemRegion *R)
QualType getDesugaredValueType(ASTContext &Context) const
TypedValueRegion(const MemRegion *sReg, Kind k)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
QualType getValueType() const override
const VarDecl * getDecl() const override=0
const StackFrameContext * getStackFrame() const
It might return null.
VarRegion(const MemRegion *sReg, Kind k)
static bool classof(const MemRegion *R)
Value representing integer constant.
APSIntPtr getValue() const
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
raw_ostream & operator<<(raw_ostream &Out, const CheckerBase &Checker)
Dump checker name to stream.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T