[clang] [clang][dataflow] Expose getReferencedDecls and relocate free functions. (PR #88754)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 16 00:16:11 PDT 2024
================
@@ -648,36 +563,13 @@ void Environment::initialize() {
void Environment::initFieldsGlobalsAndFuncs(const FunctionDecl *FuncDecl) {
assert(FuncDecl->doesThisDeclarationHaveABody());
- FieldSet Fields;
- llvm::DenseSet<const VarDecl *> Vars;
- llvm::DenseSet<const FunctionDecl *> Funcs;
-
- // Look for global variable and field references in the
- // constructor-initializers.
- if (const auto *CtorDecl = dyn_cast<CXXConstructorDecl>(FuncDecl)) {
- for (const auto *Init : CtorDecl->inits()) {
- if (Init->isMemberInitializer()) {
- Fields.insert(Init->getMember());
- } else if (Init->isIndirectMemberInitializer()) {
- for (const auto *I : Init->getIndirectMember()->chain())
- Fields.insert(cast<FieldDecl>(I));
- }
- const Expr *E = Init->getInit();
- assert(E != nullptr);
- getFieldsGlobalsAndFuncs(*E, Fields, Vars, Funcs);
- }
- // Add all fields mentioned in default member initializers.
- for (const FieldDecl *F : CtorDecl->getParent()->fields())
- if (const auto *I = F->getInClassInitializer())
- getFieldsGlobalsAndFuncs(*I, Fields, Vars, Funcs);
- }
- getFieldsGlobalsAndFuncs(*FuncDecl->getBody(), Fields, Vars, Funcs);
+ ReferencedDecls FGF = getReferencedDecls(*FuncDecl);
----------------
martinboehme wrote:
```suggestion
ReferencedDecls Referenced = getReferencedDecls(*FuncDecl);
```
(Now that the struct is called `ReferencedDecls`, it's not clear why the variable should be called `FGF`.)
https://github.com/llvm/llvm-project/pull/88754
More information about the cfe-commits
mailing list