================
@@ -632,13 +579,45 @@ void FactsGenerator::handleFunctionCall(const Expr *Call,
ArrayRef<const Expr *> Args,
bool IsGslConstruction) {
OriginList *CallList = getOriginsList(*Call);
+ SourceManager &SM = AC.getASTContext().getSourceManager();
+ // To avoid over-reporting, we assume the following are noescape:
+ // - All parameters to functions declared in the system headers
+ // - The implicit `this` parameter for member functions
+ auto IsArgNoEscape = [FD, &SM](unsigned I) -> bool {
+ const ParmVarDecl *PVD = nullptr;
+ if (const auto *Method = dyn_cast<CXXMethodDecl>(FD);
+ Method && Method->isInstance()) {
+ // There is currently no way to declare 'this' is noescape for member
+ // functions We therefore return true as the user cannot do anything via
+ // annotation, so we make the conservative approximation
+ if (I == 0) {
+ return true;
+ }
+ if ((I - 1) < Method->getNumParams()) {
+ PVD = Method->getParamDecl(I - 1);
+ }
+ } else if (I < FD->getNumParams()) {
+ PVD = FD->getParamDecl(I);
----------------
Xazax-hun wrote:
I wonder if Clang has some abstractions to pair up arguments with parameters.
Unfortunately, this is very error prone in general. Might worth taking a look
at what the compiler is doing at some other code paths just in case we can
simplify some of the special casing here.
https://github.com/llvm/llvm-project/pull/186126
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits