diff --git a/compilerplugins/clang/plugin.cxx b/compilerplugins/clang/plugin.cxx index d91acf722f1a..14d8af8d65b3 100644 --- a/compilerplugins/clang/plugin.cxx +++ b/compilerplugins/clang/plugin.cxx @@ -201,9 +201,10 @@ Stmt* Plugin::getParentStmt( Stmt* stmt ) static const Decl* getFunctionDeclContext(ASTContext& context, const Stmt* stmt) { - auto it = context.getParents(*stmt).begin(); + auto const parents = context.getParents(*stmt); + auto it = parents.begin(); - if (it == context.getParents(*stmt).end()) + if (it == parents.end()) return nullptr; const Decl *decl = it->get(); diff --git a/compilerplugins/clang/unusedfields.cxx b/compilerplugins/clang/unusedfields.cxx index 5f5101e85af9..e4f3f5ba7983 100644 --- a/compilerplugins/clang/unusedfields.cxx +++ b/compilerplugins/clang/unusedfields.cxx @@ -1146,9 +1146,10 @@ bool UnusedFields::VisitDeclRefExpr( const DeclRefExpr* declRefExpr ) static const Decl* getFunctionDeclContext(ASTContext& context, const Stmt* stmt) { - auto it = context.getParents(*stmt).begin(); + auto const parents = context.getParents(*stmt); + auto it = parents.begin(); - if (it == context.getParents(*stmt).end()) + if (it == parents.end()) return nullptr; const Decl *decl = it->get();