================
@@ -1239,6 +1245,60 @@ class CXXDeallocatorCall : public AnyFunctionCall {
}
};
+/// Represents an implicit call to a cleanup function, triggered by a
+/// `__attribute__((cleanup(f)))` variable going out of scope.
+///
+/// The call has no syntactic representation: like \c CXXDestructorCall it is
+/// Decl-origin, and its single argument, the address of the annotated
+/// variable, is not written in the source.
+class CleanupFunctionCall : public AnyFunctionCall {
+ friend class CallEventManager;
+
+protected:
+ CleanupFunctionCall(const FunctionDecl *FD, const VarDecl *VD,
+ ProgramStateRef St, const StackFrame *SF,
+ CFGBlock::ConstCFGElementRef ElemRef)
+ : AnyFunctionCall(FD, St, SF, ElemRef) {
+ Data = VD;
+ Location = VD->getAttr<CleanupAttr>()->getLoc();
+ }
+
+ CleanupFunctionCall(const CleanupFunctionCall &Other) = default;
+
+ void cloneTo(void *Dest) const override {
+ new (Dest) CleanupFunctionCall(*this);
+ }
+
+public:
+ /// Returns the variable declaration whose scope exit triggered this call.
+ const VarDecl *getVarDecl() const {
+ return static_cast<const VarDecl *>(Data);
+ }
+
+ SourceRange getSourceRange() const override { return Location; }
+
+ unsigned getNumArgs() const override { return 1; }
+
+ // The implicit `&var` argument has no expression in the source.
+ const Expr *getArgExpr(unsigned Index) const override { return nullptr; }
----------------
necto wrote:
Also, why not assert `Index == 0` simmetric to `getArgSVal`?
https://github.com/llvm/llvm-project/pull/221110
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits