================
@@ -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 {
----------------
necto wrote:
Here `CleanupFunctionCall::getResultType()` would early-return with `void`
since `getOriginExpr()` gives null. That can be misleading and break if some
checker is interested in the return type.
I think you can use the `FD` type to deduce the result type, but you'd need to
make `getResultType` `virtual`.
While it might be controversial what to consider the "result" of the cleanup
call,
[apparently](https://compiler-explorer.com/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:33,endLineNumber:5,positionColumn:33,positionLineNumber:5,selectionStartColumn:32,selectionStartLineNumber:5,startColumn:32,startLineNumber:5),source:'static+bool+dump_cleanup(int+*p)+%7B%0A++(void)p%3B%0A%7D%0A%0Avoid+inlined_cleanup_observes_value(void)+%7B%0A++int+x+__attribute__((cleanup(dump_cleanup)))%3B%0A++x+%3D+42%3B%0A%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:cg162,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,libs:!(),options:'',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+gcc+16.2+(Editor+%231)',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+gcc+16.2+(Compiler+%231)',t:'0')),k:33.33333333333333,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
cleanup functions can return non-void.
https://github.com/llvm/llvm-project/pull/221110
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits