clang: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.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_CALLEVENT_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_CALLEVENT_H
17
35#include "llvm/ADT/ArrayRef.h"
36#include "llvm/ADT/IntrusiveRefCntPtr.h"
37#include "llvm/ADT/PointerIntPair.h"
38#include "llvm/ADT/PointerUnion.h"
39#include "llvm/ADT/STLExtras.h"
40#include "llvm/ADT/SmallVector.h"
41#include "llvm/ADT/StringRef.h"
42#include "llvm/ADT/iterator_range.h"
43#include "llvm/Support/Allocator.h"
44#include "llvm/Support/Casting.h"
45#include "llvm/Support/ErrorHandling.h"
46#include
47#include
48#include
49#include
50
52
53class LocationContext;
54class ProgramPoint;
55class ProgramPointTag;
56class StackFrameContext;
57
58namespace ento {
59
79
80class CallEvent;
81
82template
84public:
87
88
89
91
93 return this->get()->template cloneWithState(State);
94 }
95
96
97
99 return this->get();
100 }
101};
102
103
104
105
106
107
108
109
111
112
113 const Decl *D = nullptr;
114
115
116
117
118
120
121
122
123 const bool Foreign = false;
124
125public:
130
133
134
135
136
138
139
140
142};
143
144
145
146
147
148
149
150
151
152
154public:
156
157private:
160 llvm::PointerUnion<const Expr *, const Decl *> Origin;
162 mutable std::optional Foreign;
163
164protected:
165
167
168
169
170
172
173private:
175
176 mutable unsigned RefCount = 0;
177
178 void Retain() const { ++RefCount; }
179 void Release() const;
180
181protected:
183
186 : State(std::move(state)), LCtx(lctx), Origin(E), ElemRef(ElemRef) {}
187
190 : State(std::move(state)), LCtx(lctx), Origin(D), ElemRef(ElemRef) {}
191
192
194 : State(Original.State), LCtx(Original.LCtx), Origin(Original.Origin),
195 ElemRef(Original.ElemRef), Data(Original.Data),
197
198
199 virtual void cloneTo(void *Dest) const = 0;
200
201
204 }
205
207
208
209
210 virtual void
213
214public:
217
218
221
222
223
225 return Origin.dyn_cast<const Decl *>();
226 }
227
229 assert(Foreign && "Foreign must be set before querying");
230 return *Foreign;
231 }
233
234
236
237
239
241 return ElemRef;
242 }
243
244
245
247
248
249
251 return Origin.dyn_cast<const Expr *>();
252 }
253
254
255
256
257
258
260
261
264 if ()
265 return false;
266
270 getState()->getStateManager().getContext().getSourceManager();
271 return SM.isInSystemHeader(D->getLocation());
272 }
273
274
275
276 if (const auto *FD = dyn_cast(D))
277 return FD->isOverloadedOperator() && FD->isImplicit() && FD->isGlobal();
278
279 return false;
280 }
281
282
283
286 }
287
288
290
291
292
293 virtual const Expr *getArgExpr(unsigned Index) const { return nullptr; }
294
295
296
297
299
300
302
303
304
305
306
308
309
310
312
313
315
316
318
319
320
321
322
323
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342 bool isGlobalCFunction(StringRef SpecificName = StringRef()) const;
343
344
345
346
347
348
349
350
352 const auto *ND = dyn_cast_or_null(getDecl());
353 if (!ND)
354 return nullptr;
355 return ND->getIdentifier();
356 }
357
358
361
362
363
364
365
368
371
372
373
376
377
378 template
380
381
383 return cloneWithState(NewState);
384 }
385
386
387
389
390
391
392
394
395
396
397
399
400
401
403
404
405
406
407
409
410
411
412
414 unsigned BlockCount) const;
415
416
417
418
419
420
421
423
426 .has_value();
427 }
428
429
430
431
432
433 virtual std::optional
435 return ASTArgumentIndex;
436 }
437
438
439
440
442 return CallArgumentIndex;
443 }
444
445
446
447
449
450
451
453
454
456
457
458
459
461
462
463private:
464 struct GetTypeFn {
466 };
467
468public:
469
470
471
472
473
475
477 llvm::mapped_iterator<ArrayRef<ParmVarDecl *>::iterator, GetTypeFn>;
478
479
480
481
482
483
485 return llvm::map_iterator(parameters().begin(), GetTypeFn());
486 }
487
489 return llvm::map_iterator(parameters().end(), GetTypeFn());
490 }
491
492
493 void dump(raw_ostream &Out) const;
494 void dump() const;
495};
496
497
498
500protected:
510
511public:
512
513
516 }
517
519
521
524
526
530 }
531};
532
533
534
535
538
539protected:
545
546 void cloneTo(void *Dest) const override {
548 }
549
550public:
553 }
554
556
558
561 }
562
564 StringRef getKindAsString() const override { return "SimpleFunctionCall"; }
565
568 }
569};
570
571
572
573
576
577protected:
580 : CallEvent(CE, St, LCtx, ElemRef) {}
582
584
588
589public:
592 }
593
595
598 }
599
600
601
602
604
607 if (!BR)
608 return nullptr;
610 }
611
614 if (!BD)
615 return false;
616
618 }
619
620
621
625 assert(BR && "Block converted from lambda must have a block region");
626
628 assert(!ReferencedVars.empty());
629 return ReferencedVars.begin().getCapturedRegion();
630 }
631
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
658
660 }
661
663
666
668
671
673};
674
675
676
678protected:
688
692
693
694
695
697
698public:
699
701
702
704
706
708
711
715 }
716};
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
736
737protected:
743
744 void cloneTo(void *Dest) const override {
746 }
747
748public:
751 }
752
754
757 }
758
760
762 }
763
764 std::optional
766
767 if (ASTArgumentIndex == 0)
768 return std::nullopt;
769 return ASTArgumentIndex - 1;
770 }
771
773
774 return CallArgumentIndex + 1;
775 }
776
779 }
780
782 StringRef getKindAsString() const override { return "CXXStaticOperatorCall"; }
783
786 }
787};
788
789
790
791
794
795protected:
801
803
804public:
807 }
808
811 return CE->getNumArgs();
812 return 0;
813 }
814
817 }
818
820
822
824 StringRef getKindAsString() const override { return "CXXMemberCall"; }
825
828 }
829};
830
831
832
833
834
837
838protected:
844
845 void cloneTo(void *Dest) const override {
847 }
848
849public:
852 }
853
856 }
857
860 }
861
863
865 StringRef getKindAsString() const override { return "CXXMemberOperatorCall"; }
866
869 }
870
871 std::optional
873
874
875 return (ASTArgumentIndex > 0)
876 ? std::optional(ASTArgumentIndex - 1)
877 : std::nullopt;
878 }
879
881
882
883 return CallArgumentIndex + 1;
884 }
885
888 }
889};
890
891
892
893
894
897
898protected:
899 using DtorDataTy = llvm::PointerIntPair<const MemRegion *, 1, bool>;
900
901
902
903
904
905
906
907
908
909
910
911
912
913
921 }
922
924
925 void cloneTo(void *Dest) const override {
927 }
928
929public:
931 unsigned getNumArgs() const override { return 0; }
932
934
935
937
938
940 return DtorDataTy::getFromOpaqueValue(Data).getInt();
941 }
942
944 StringRef getKindAsString() const override { return "CXXDestructorCall"; }
945
948 }
949};
950
951
952
954protected:
959 assert(E && (isa(E) || isa(E)));
960
962 }
963
967
970
971public:
972
974
978 }
979};
980
981
982
983
986
987protected:
988
989
990
991
992
993
994
995
996
997
998
1003
1005
1006 void cloneTo(void *Dest) const override {
1008 }
1009
1010public:
1013 }
1014
1017 }
1018
1020
1023 }
1024
1026 StringRef getKindAsString() const override { return "CXXConstructorCall"; }
1027
1030 }
1031};
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1055
1056protected:
1062
1064 default;
1065
1066 void cloneTo(void *Dest) const override {
1068 }
1069
1070public:
1073 }
1074
1077 }
1078
1079
1080
1082
1083
1084
1085
1088 }
1089
1092 }
1093
1096 }
1097
1102 }
1103
1106 return "CXXInheritedConstructorCall";
1107 }
1108
1111 }
1112};
1113
1114
1115
1116
1119
1120protected:
1126
1127 void cloneTo(void *Dest) const override {
1129 }
1130
1131public:
1134 }
1135
1138 }
1139
1143 }
1144
1145
1146
1147
1150 }
1151
1154 }
1155
1157
1160 }
1161
1163 assert(isArray() && "The allocator call doesn't allocate and array!");
1164
1166 }
1167
1169
1171 return nullptr;
1173 }
1174
1175
1176
1177
1178
1181 }
1182
1184 StringRef getKindAsString() const override { return "CXXAllocatorCall"; }
1185
1188 }
1189};
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1203
1204protected:
1210
1211 void cloneTo(void *Dest) const override {
1213 }
1214
1215public:
1218 }
1219
1222 }
1223
1225
1227
1229 }
1230
1232 StringRef getKindAsString() const override { return "CXXDeallocatorCall"; }
1233
1236 }
1237};
1238
1239
1240
1241
1242
1244
1245
1246
1247
1250
1251 const PseudoObjectExpr *getContainingPseudoObjectExpr() const;
1252
1253protected:
1257 : CallEvent(Msg, St, LCtx, ElemRef) {
1258 Data = nullptr;
1259 }
1260
1262
1264
1268
1269
1272
1273public:
1276 }
1277
1280 }
1281
1283
1286 }
1287
1290 }
1291
1294 }
1295
1297
1299
1300
1302
1303
1304
1305
1306
1309 }
1310
1311
1313
1314
1315
1317
1318
1319
1323 llvm_unreachable("This is not a pseudo-object access!");
1328 }
1329 llvm_unreachable("Unknown message kind");
1330 }
1331
1332
1333
1334
1336
1338
1340
1343
1345
1348
1351 }
1352};
1353
1354
1355
1356
1357
1358
1359
1360
1363
1364 llvm::BumpPtrAllocator &Alloc;
1366
1368
1369 void reclaim(const void *Memory) {
1370 Cache.push_back(const_cast<void *>(Memory));
1371 }
1372
1373
1374 void *allocate() {
1375 if (Cache.empty())
1376 return Alloc.Allocate();
1377 else
1378 return Cache.pop_back_val();
1379 }
1380
1381 template <typename T, typename Arg>
1384 static_assert(sizeof(T) == sizeof(CallEventTemplateTy),
1385 "CallEvent subclasses are not all the same size");
1386 return new (allocate()) T(A, St, LCtx, ElemRef);
1387 }
1388
1389 template <typename T, typename Arg1, typename Arg2>
1390 T *create(Arg1 A1, Arg2 A2, ProgramStateRef St, const LocationContext *LCtx,
1392 static_assert(sizeof(T) == sizeof(CallEventTemplateTy),
1393 "CallEvent subclasses are not all the same size");
1394 return new (allocate()) T(A1, A2, St, LCtx, ElemRef);
1395 }
1396
1397 template <typename T, typename Arg1, typename Arg2, typename Arg3>
1400 static_assert(sizeof(T) == sizeof(CallEventTemplateTy),
1401 "CallEvent subclasses are not all the same size");
1402 return new (allocate()) T(A1, A2, A3, St, LCtx, ElemRef);
1403 }
1404
1405 template <typename T, typename Arg1, typename Arg2, typename Arg3,
1406 typename Arg4>
1407 T *create(Arg1 A1, Arg2 A2, Arg3 A3, Arg4 A4, ProgramStateRef St,
1409 static_assert(sizeof(T) == sizeof(CallEventTemplateTy),
1410 "CallEvent subclasses are not all the same size");
1411 return new (allocate()) T(A1, A2, A3, A4, St, LCtx, ElemRef);
1412 }
1413
1414public:
1416
1417
1420
1421
1422
1426
1430
1435 return create(E, State, LCtx, ElemRef);
1436 }
1437
1442 return create(E, Target, State, LCtx, ElemRef);
1443 }
1444
1450 return create(E, Target, State, LCtx, ElemRef);
1451 }
1452
1458 return create(DD, Trigger, Target, IsBase, State, LCtx,
1459 ElemRef);
1460 }
1461
1466 return create(E, State, LCtx, ElemRef);
1467 }
1468
1473 return create(E, State, LCtx, ElemRef);
1474 }
1475};
1476
1477template
1479 assert(isa(*this) && "Cloning to unrelated type");
1480 static_assert(sizeof(T) == sizeof(CallEvent),
1481 "Subclasses may not add fields");
1482
1483 if (NewState == State)
1484 return cast(this);
1485
1486 CallEventManager &Mgr = State->getStateManager().getCallEventManager();
1487 T *Copy = static_cast<T *>(Mgr.allocate());
1489 assert(Copy->getKind() == this->getKind() && "Bad copy");
1490
1491 Copy->State = NewState;
1492 return Copy;
1493}
1494
1495inline void CallEvent::Release() const {
1496 assert(RefCount > 0 && "Reference count is already zero.");
1497 --RefCount;
1498
1499 if (RefCount > 0)
1500 return;
1501
1502 CallEventManager &Mgr = State->getStateManager().getCallEventManager();
1503 Mgr.reclaim(this);
1504
1506}
1507
1508}
1509
1510}
1511
1512namespace llvm {
1513
1514
1515template struct simplify_type<clang::ento::CallEventRef> {
1517
1519 return Val.get();
1520 }
1521};
1522
1523}
1524
1525#endif
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Target Target
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
TypePropertyCache< Private > Cache
C Language Family Type Representation.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool isConversionFromLambda() const
ElementRefImpl< true > ConstCFGElementRef
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ constructor within a class.
Represents a delete expression for memory deallocation and destructor calls, e.g.
FunctionDecl * getOperatorDelete() const
Represents a C++ destructor within a class.
Represents a call to an inherited base class constructor from an inheriting constructor.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
Represents a call to a member function that may be written either with member call syntax (e....
Represents a static or instance method of a struct/union/class.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
Expr * getPlacementArg(unsigned I)
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function.
unsigned getNumPlacementArgs() const
FunctionDecl * getOperatorNew() const
A call to an overloaded operator written using operator syntax.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
Represents a C++ struct/union/class.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
ConstructionContext's subclasses describe different ways of constructing an object in C++.
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a function declaration or definition.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
One of these records is kept for each identifier that is lexed.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Represents an ObjC class declaration.
An expression that sends a message to the given Objective-C object or class.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
ObjCMethodFamily getMethodFamily() const
Selector getSelector() const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
const ObjCMethodDecl * getMethodDecl() const
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents one property declaration in an Objective-C interface.
Represents a parameter to a function.
ProgramPoints can be "tagged" as representing points specific to a given analysis entity.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack (based on CallEvent).
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a variable declaration or definition.
Represents any constructor invocation.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
AnyCXXConstructorCall(const Expr *E, const MemRegion *Target, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
static bool classof(const CallEvent *Call)
Represents a call to any sort of function that might have a FunctionDecl.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
AnyFunctionCall(const Expr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
static bool classof(const CallEvent *CA)
AnyFunctionCall(const Decl *D, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
AnyFunctionCall(const AnyFunctionCall &Other)=default
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
Represents a call to a block.
const BlockDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
const BlockDataRegion * getBlockRegion() const
Returns the region associated with this instance of the block.
bool isConversionFromLambda() const
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
Kind getKind() const override
Returns the kind of call this is.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
const VarRegion * getRegionStoringCapturedLambda() const
For a block converted from a C++ lambda, returns the block VarRegion for the variable holding the cap...
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
BlockCall(const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
BlockCall(const BlockCall &Other)=default
static bool classof(const CallEvent *CA)
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
StringRef getKindAsString() const override
const CallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
BlockDataRegion - A region that represents a block instance.
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
llvm::iterator_range< referenced_vars_iterator > referenced_vars() const
Represents the memory allocation call in a C++ new-expression.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
unsigned getNumImplicitArgs() const
Number of non-placement arguments to the call.
const CXXNewExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
Kind getKind() const override
Returns the kind of call this is.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
std::optional< const clang::Expr * > getArraySizeExpr() const
static bool classof(const CallEvent *CE)
const Expr * getPlacementArgExpr(unsigned Index) const
Number of placement arguments to the operator new() call.
CXXAllocatorCall(const CXXAllocatorCall &Other)=default
SVal getArraySizeVal() const
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
StringRef getKindAsString() const override
SVal getObjectUnderConstruction() const
CXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
Represents a call to a C++ constructor.
CXXConstructorCall(const CXXConstructorCall &Other)=default
const CXXConstructorDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
const CXXConstructExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
Kind getKind() const override
Returns the kind of call this is.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
CXXConstructorCall(const CXXConstructExpr *CE, const MemRegion *Target, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
Creates a constructor call.
StringRef getKindAsString() const override
static bool classof(const CallEvent *CA)
Represents the memory deallocation call in a C++ delete-expression.
Kind getKind() const override
Returns the kind of call this is.
const CXXDeleteExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
CXXDeallocatorCall(const CXXDeallocatorCall &Other)=default
static bool classof(const CallEvent *CE)
StringRef getKindAsString() const override
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
CXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
Represents an implicit call to a C++ destructor.
static bool classof(const CallEvent *CA)
SVal getCXXThisVal() const override
Returns the value of the implicit 'this' object.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
bool isBaseDestructor() const
Returns true if this is a call to a base class destructor.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
llvm::PointerIntPair< const MemRegion *, 1, bool > DtorDataTy
CXXDestructorCall(const CXXDestructorCall &Other)=default
SourceRange getSourceRange() const override
Returns a source range for the entire call, suitable for outputting in diagnostics.
CXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBaseDestructor, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
Creates an implicit destructor.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
StringRef getKindAsString() const override
Kind getKind() const override
Returns the kind of call this is.
Represents a call to a C++ inherited constructor.
CXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *CE, const MemRegion *Target, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CXXInheritedConstructorCall(const CXXInheritedConstructorCall &Other)=default
static bool classof(const CallEvent *CA)
const CXXInheritedCtorInitExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const StackFrameContext * getInheritingStackFrame() const
Obtain the stack frame of the inheriting constructor.
StringRef getKindAsString() const override
Kind getKind() const override
Returns the kind of call this is.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
const CXXConstructorDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
const CXXConstructExpr * getInheritingConstructor() const
Obtain the CXXConstructExpr for the sub-class that inherited the current constructor (possibly indire...
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
SVal getArgSVal(unsigned Index) const override
Returns the value of a given argument at the time of the call.
Represents a non-static C++ member function call, no matter how it is written.
std::pair< const CXXRecordDecl *, bool > getDeclForDynamicType() const
Returns the decl refered to by the "dynamic type" of the current object and if the class can be a sub...
CXXInstanceCall(const CXXInstanceCall &Other)=default
CXXInstanceCall(const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CXXInstanceCall(const FunctionDecl *D, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
virtual SVal getCXXThisVal() const
Returns the value of the implicit 'this' object.
static bool classof(const CallEvent *CA)
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
virtual const Expr * getCXXThisExpr() const
Returns the expression representing the implicit 'this' object.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
Represents a non-static C++ member function call.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
CXXMemberCall(const CXXMemberCall &Other)=default
const CXXMemberCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
static bool classof(const CallEvent *CA)
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
CXXMemberCall(const CXXMemberCallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
StringRef getKindAsString() const override
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
Kind getKind() const override
Returns the kind of call this is.
Represents a C++ overloaded operator call where the operator is implemented as a non-static member fu...
std::optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const override
Some calls have parameter numbering mismatched from argument numbering.
OverloadedOperatorKind getOverloadedOperator() const
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
Kind getKind() const override
Returns the kind of call this is.
StringRef getKindAsString() const override
const Expr * getCXXThisExpr() const override
Returns the expression representing the implicit 'this' object.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
CXXMemberOperatorCall(const CXXOperatorCallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
const CXXOperatorCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
CXXMemberOperatorCall(const CXXMemberOperatorCall &Other)=default
unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const override
Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
static bool classof(const CallEvent *CA)
Represents a static C++ operator call.
std::optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const override
Some calls have parameter numbering mismatched from argument numbering.
CXXStaticOperatorCall(const CXXStaticOperatorCall &Other)=default
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
OverloadedOperatorKind getOverloadedOperator() const
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
StringRef getKindAsString() const override
Kind getKind() const override
Returns the kind of call this is.
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
const CXXOperatorCallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
CXXStaticOperatorCall(const CXXOperatorCallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
static bool classof(const CallEvent *CA)
unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const override
Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
Manages the lifetime of CallEvent objects.
CallEventRef< CXXDestructorCall > getCXXDestructorCall(const CXXDestructorDecl *DD, const Stmt *Trigger, const MemRegion *Target, bool IsBase, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef getCall(const Stmt *S, ProgramStateRef State, const LocationContext *LC, CFGBlock::ConstCFGElementRef ElemRef)
Gets a call event for a function call, Objective-C method call, a 'new', or a 'delete' call.
CallEventRef< CXXDeallocatorCall > getCXXDeallocatorCall(const CXXDeleteExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef getSimpleCall(const CallExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< ObjCMethodCall > getObjCMethodCall(const ObjCMessageExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXAllocatorCall > getCXXAllocatorCall(const CXXNewExpr *E, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXConstructorCall > getCXXConstructorCall(const CXXConstructExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< CXXInheritedConstructorCall > getCXXInheritedConstructorCall(const CXXInheritedCtorInitExpr *E, const MemRegion *Target, ProgramStateRef State, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventManager(llvm::BumpPtrAllocator &alloc)
CallEventRef getCaller(const StackFrameContext *CalleeCtx, ProgramStateRef State)
Gets an outside caller given a callee context.
CallEventRef(const T *Call)
CallEventRef(const CallEventRef &Orig)
CallEventRef & operator=(const CallEventRef &)=delete
CallEventRef< T > cloneWithState(ProgramStateRef State) const
Represents an abstract call to a function or method along a particular path.
virtual SourceRange getArgSourceRange(unsigned Index) const
Returns the source range for errors associated with this argument.
virtual void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const
Used to specify non-argument regions that will be invalidated as a result of this call.
virtual StringRef getKindAsString() const =0
void setForeign(bool B) const
virtual const Expr * getOriginExpr() const
Returns the expression whose value will be the result of this call.
virtual RuntimeDefinition getRuntimeDefinition() const =0
Returns the definition of the function or method that will be called.
CallEventRef cloneWithState(ProgramStateRef NewState) const
Returns a copy of this CallEvent, but using the given state.
static bool isCallStmt(const Stmt *S)
Returns true if this is a statement is a function or method call of some kind.
CallEvent & operator=(const CallEvent &)=delete
llvm::mapped_iterator< ArrayRef< ParmVarDecl * >::iterator, GetTypeFn > param_type_iterator
const ConstructionContext * getConstructionContext() const
Returns the construction context of the call, if it is a C++ constructor call or a call of a function...
param_type_iterator param_type_end() const
const ParamVarRegion * getParameterLocation(unsigned Index, unsigned BlockCount) const
Returns memory location for a parameter variable within the callee stack frame.
bool isCalledFromSystemHeader() const
const IdentifierInfo * getCalleeIdentifier() const
Returns the name of the callee, if its name is a simple identifier.
AnalysisDeclContext * getCalleeAnalysisDeclContext() const
Returns AnalysisDeclContext for the callee stack frame.
ProgramStateRef invalidateRegions(unsigned BlockCount, ProgramStateRef Orig=nullptr) const
Returns a new state with all argument regions invalidated.
virtual std::optional< unsigned > getAdjustedParameterIndex(unsigned ASTArgumentIndex) const
Some calls have parameter numbering mismatched from argument numbering.
const ProgramStateRef & getState() const
The state in which the call is being evaluated.
QualType getResultType() const
Returns the result type, adjusted for references.
CallEvent(const Expr *E, ProgramStateRef state, const LocationContext *lctx, CFGBlock::ConstCFGElementRef ElemRef)
CallEventRef< T > cloneWithState(ProgramStateRef NewState) const
Returns a copy of this CallEvent, but using the given state.
bool isInSystemHeader() const
Returns true if the callee is known to be from a system header.
bool isGlobalCFunction(StringRef SpecificName=StringRef()) const
Returns true if the callee is an externally-visible function in the top-level namespace,...
virtual bool argumentsMayEscape() const
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
CallEvent(const CallEvent &Original)
param_type_iterator param_type_begin() const
Returns an iterator over the types of the call's formal parameters.
std::pair< SVal, SVal > FrameBindingTy
ProgramPoint getProgramPoint(bool IsPreVisit=false, const ProgramPointTag *Tag=nullptr) const
Returns an appropriate ProgramPoint for this call.
virtual ~CallEvent()=default
const StackFrameContext * getCalleeStackFrame(unsigned BlockCount) const
Returns the callee stack frame.
static QualType getDeclaredResultType(const Decl *D)
Returns the result type of a function or method declaration.
SVal getSVal(const Stmt *S) const
Get the value of arbitrary expressions at this point in the path.
virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const =0
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
virtual void cloneTo(void *Dest) const =0
Copies this CallEvent, with vtable intact, into a new block of memory.
static bool isVariadic(const Decl *D)
Returns true if the given decl is known to be variadic.
virtual SVal getArgSVal(unsigned Index) const
Returns the value of a given argument at the time of the call.
bool hasNonNullArgumentsWithType(bool(*Condition)(QualType)) const
Returns true if the type of any of the non-null arguments satisfies the condition.
std::optional< SVal > getReturnValueUnderConstruction() const
If the call returns a C++ record type then the region of its return value can be retrieved from its c...
virtual const Expr * getArgExpr(unsigned Index) const
Returns the expression associated with a given argument.
virtual unsigned getNumArgs() const =0
Returns the number of arguments (explicit and implicit).
bool hasVoidPointerToNonConstArg() const
Returns true if any of the arguments is void*.
const CallEventRef getCaller() const
bool isArgumentConstructedDirectly(unsigned Index) const
Returns true if on the current path, the argument was constructed by calling a C++ constructor over i...
SmallVectorImpl< FrameBindingTy > BindingsTy
SVal getReturnValue() const
Returns the return value of the call.
virtual const Decl * getDecl() const
Returns the declaration of the function or method that will be called.
const LocationContext * getLocationContext() const
The context in which the call is being evaluated.
const CFGBlock::ConstCFGElementRef & getCFGElementRef() const
CallEvent(const Decl *D, ProgramStateRef state, const LocationContext *lctx, CFGBlock::ConstCFGElementRef ElemRef)
virtual ArrayRef< ParmVarDecl * > parameters() const =0
Return call's formal parameters.
bool hasNonZeroCallbackArg() const
Returns true if any of the arguments appear to represent callbacks.
virtual Kind getKind() const =0
Returns the kind of call this is.
virtual SourceRange getSourceRange() const
Returns a source range for the entire call, suitable for outputting in diagnostics.
virtual unsigned getASTArgumentIndex(unsigned CallArgumentIndex) const
Some call event sub-classes conveniently adjust mismatching AST indices to match parameter indices.
bool isValid() const =delete
static std::optional< SVal > getObjectUnderConstruction(ProgramStateRef State, const ConstructionContextItem &Item, const LocationContext *LC)
By looking at a certain item that may be potentially part of an object's ConstructionContext,...
MemRegion - The root abstract class for all memory regions.
Represents any expression that calls an Objective-C method.
ObjCMethodCall(const ObjCMethodCall &Other)=default
const ObjCMethodDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
void getExtraInvalidatedValues(ValueList &Values, RegionAndSymbolInvalidationTraits *ETraits) const override
Used to specify non-argument regions that will be invalidated as a result of this call.
static bool classof(const CallEvent *CA)
bool isInstanceMessage() const
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
ObjCMessageKind getMessageKind() const
Returns how the message was written in the source (property access, subscript, or explicit message se...
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
bool isSetter() const
Returns true if this property access or subscript is a setter (has the form of an assignment).
const ObjCMessageExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
ObjCMethodFamily getMethodFamily() const
ObjCMethodCall(const ObjCMessageExpr *Msg, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
ArrayRef< ParmVarDecl * > parameters() const override
Return call's formal parameters.
StringRef getKindAsString() const override
SourceRange getSourceRange() const override
Returns a source range for the entire call, suitable for outputting in diagnostics.
virtual bool canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl, Selector Sel) const
Check if the selector may have multiple definitions (may have overrides).
bool argumentsMayEscape() const override
Returns true if any of the arguments are known to escape to long- term storage, even if this method w...
SVal getReceiverSVal() const
Returns the value of the receiver at the time of this call.
RuntimeDefinition getRuntimeDefinition() const override
Returns the definition of the function or method that will be called.
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
const ObjCInterfaceDecl * getReceiverInterface() const
Get the interface for the receiver.
bool isReceiverSelfOrSuper() const
Checks if the receiver refers to 'self' or 'super'.
Selector getSelector() const
const ObjCPropertyDecl * getAccessedProperty() const
Kind getKind() const override
Returns the kind of call this is.
void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const override
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
ParamVarRegion - Represents a region for paremters.
Information about invalidation for a particular region/symbol.
Defines the runtime definition of the called function.
RuntimeDefinition(const Decl *InD, const MemRegion *InR)
RuntimeDefinition(const Decl *InD, bool Foreign)
const MemRegion * getDispatchRegion()
When other definitions are possible, returns the region whose runtime type determines the method defi...
RuntimeDefinition()=default
RuntimeDefinition(const Decl *InD)
bool mayHaveOtherDefinitions()
Check if the definition we have is precise.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
Represents a C function or static C++ member function call.
static bool classof(const CallEvent *CA)
Kind getKind() const override
Returns the kind of call this is.
unsigned getNumArgs() const override
Returns the number of arguments (explicit and implicit).
SimpleFunctionCall(const CallExpr *CE, ProgramStateRef St, const LocationContext *LCtx, CFGBlock::ConstCFGElementRef ElemRef)
void cloneTo(void *Dest) const override
Copies this CallEvent, with vtable intact, into a new block of memory.
SimpleFunctionCall(const SimpleFunctionCall &Other)=default
StringRef getKindAsString() const override
const Expr * getArgExpr(unsigned Index) const override
Returns the expression associated with a given argument.
const CallExpr * getOriginExpr() const override
Returns the expression whose value will be the result of this call.
const FunctionDecl * getDecl() const override
Returns the declaration of the function or method that will be called.
const VarDecl * getDecl() const override=0
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
@ CE_END_CXX_CONSTRUCTOR_CALLS
@ CE_CXXInheritedConstructor
@ CE_END_CXX_INSTANCE_CALLS
@ CE_BEG_CXX_INSTANCE_CALLS
@ CE_BEG_CXX_CONSTRUCTOR_CALLS
ObjCMessageKind
Represents the ways an Objective-C message send can occur.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
ObjCMethodFamily
A family of Objective-C methods.
const FunctionProtoType * T
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
static SimpleType getSimplifiedValue(clang::ento::CallEventRef< T > Val)