================
@@ -1342,6 +1342,14 @@ class Analyzer {
return Result;
}
+ bool TraverseParmVarDecl(ParmVarDecl *D) override {
+ // Uninstantiated default arguments are dependent expressions that cannot
+ // be analyzed for function effects without producing incorrect warnings.
+ if (D->hasUninstantiatedDefaultArg())
----------------
MitraGulla wrote:
Instead of skipping the entire parameter declaration, which also skipped
parameter destructor checks. Now normal parameter traversal is there and skips
only the uninstantiated default argument expression.
Using this new variable const Expr *UninstantiatedDefaultArgToSkip = nullptr;
to check it.
In `TraverseStmt()`:
```cpp
bool TraverseStmt(Stmt *Statement) override {
if (Statement != TrailingRequiresClause &&
Statement != NoexceptExpr &&
Statement != UninstantiatedDefaultArgToSkip)
return DynamicRecursiveASTVisitor::TraverseStmt(Statement);
return true;
}
```
In `TraverseParmVarDecl()`:
```cpp
bool TraverseParmVarDecl(ParmVarDecl *D) override {
llvm::SaveAndRestore SavedDefaultArg(UninstantiatedDefaultArgToSkip);
if (D->hasUninstantiatedDefaultArg())
UninstantiatedDefaultArgToSkip = D->getUninstantiatedDefaultArg();
return DynamicRecursiveASTVisitor::TraverseParmVarDecl(D);
}
```
This way, parameter destructor checks are preserved while unused default
arguments are not unnecessarily analyzed.
By adding this, the tests for destructor also passed, can you check this, if
this approach is correct?
https://github.com/llvm/llvm-project/pull/235457
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits