Skip to content

Commit 007486b

Browse files
committed
exclusion filters also apply to members
#feat
1 parent c54f1db commit 007486b

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

docs/modules/ROOT/pages/config-file.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ The rules for whitelisting symbols (`include-symbols`, `implementation-defined`,
200200
4. The symbol is a child of a literal pattern representing a namespace.
201201
** For instance, the literal pattern `std` matches `std::filesystem::path::iterator` because `std` is a literal pattern matching a namespace. In other words, these literal patterns represent the namespace and its subnamespaces as if the pattern were `std::**`.
202202

203-
For exclusion rules, the symbol must strictly match the pattern to be excluded.
203+
For exclusion rules, the symbol must strictly match the pattern to be excluded. If a scope is escaped by a pattern, all symbols in that scope are also excluded.
204204

205205
[#config-options-reference]
206206
== Reference

src/lib/AST/ASTVisitor.cpp

+23-6
Original file line numberDiff line numberDiff line change
@@ -2821,12 +2821,29 @@ checkSymbolFilters(Decl const* D, bool const AllowParent)
28212821

28222822
// We should check the exclusion filters first. If a symbol is
28232823
// explicitly excluded, there's nothing else to check.
2824-
if (!config_->excludeSymbols.empty() &&
2825-
checkSymbolFiltersImpl<Strict>(config_->excludeSymbols, symbolName))
2824+
if (!config_->excludeSymbols.empty())
28262825
{
2827-
ExtractionInfo const res{ExtractionMode::Dependency, ExtractionMatchType::Strict};
2828-
updateCache(res);
2829-
return res;
2826+
if (checkSymbolFiltersImpl<Strict>(config_->excludeSymbols, symbolName))
2827+
{
2828+
ExtractionInfo const res{ExtractionMode::Dependency, ExtractionMatchType::Strict};
2829+
updateCache(res);
2830+
return res;
2831+
}
2832+
// If the parent scope is excluded, the symbol should also be excluded
2833+
// since it would not be possible to refer to this member.
2834+
if (AllowParent)
2835+
{
2836+
if (Decl const* P = getParent(D))
2837+
{
2838+
if (auto const [mode, kind] = checkSymbolFilters(P);
2839+
mode == ExtractionMode::Dependency)
2840+
{
2841+
ExtractionInfo const res = {mode, ExtractionMatchType::StrictParent};
2842+
updateCache(res);
2843+
return res;
2844+
}
2845+
}
2846+
}
28302847
}
28312848

28322849
// If not excluded, we should check the filters in this order:
@@ -2923,7 +2940,7 @@ checkSymbolFilters(Decl const* D, bool const AllowParent)
29232940
// prefixes that can potentially include children, but
29242941
// we have to check if any children actually matches
29252942
// the pattern strictly.
2926-
DeclContext const* DC = cast<DeclContext>(D);
2943+
auto const* DC = cast<DeclContext>(D);
29272944
auto childrenMode = ExtractionMode::Dependency;
29282945
for (auto* M : DC->decls())
29292946
{

0 commit comments

Comments
 (0)