Skip to content

Commit

Permalink
feat: allow multiple implementation-defined and see-below namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkrystian committed Jun 7, 2024
1 parent 3122db0 commit 2753767
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
14 changes: 7 additions & 7 deletions src/lib/AST/ASTVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2456,13 +2456,12 @@ class ASTVisitor
void
traverseContext(DeclContext* DC);


bool
isInSpecialNamespace(
const Decl* D,
std::string_view Namespace)
std::span<const FilterPattern> Patterns)
{
if(! D || Namespace.empty())
if(! D || Patterns.empty())
return false;
const DeclContext* DC = isa<DeclContext>(D) ?
dyn_cast<DeclContext>(D) : D->getDeclContext();
Expand All @@ -2471,16 +2470,17 @@ class ASTVisitor
const NamespaceDecl* ND = dyn_cast<NamespaceDecl>(DC);
if(! ND)
continue;
if(ND->getQualifiedNameAsString() == Namespace)
return true;
for(const auto& Pattern : Patterns)
if(Pattern.matches(ND->getQualifiedNameAsString()))
return true;
}
return false;
}

bool
isInSpecialNamespace(
const NestedNameSpecifier* NNS,
std::string_view Namespace)
std::span<const FilterPattern> Patterns)
{
const NamedDecl* ND = nullptr;
while(NNS)
Expand All @@ -2491,7 +2491,7 @@ class ASTVisitor
break;
NNS = NNS->getPrefix();
}
return ND && isInSpecialNamespace(ND, Namespace);
return ND && isInSpecialNamespace(ND, Patterns);
}

bool
Expand Down
16 changes: 10 additions & 6 deletions src/lib/Lib/ConfigImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,16 @@ struct llvm::yaml::MappingTraits<SettingsImpl>

io.mapOptional("filters", cfg.filters);

io.mapOptional("see-below", cfg.seeBelow);
io.mapOptional("implementation-defined", cfg.implementationDefined);
// KRYSTIAN FIXME: This should really be done with mapping traits.
std::vector<std::string> seeBelow;
io.mapOptional("see-below", seeBelow);
for(std::string_view pattern : seeBelow)
cfg.seeBelow.emplace_back(pattern);

std::vector<std::string> implementationDefined;
io.mapOptional("implementation-defined", implementationDefined);
for(std::string_view pattern : implementationDefined)
cfg.implementationDefined.emplace_back(pattern);
}
};

Expand Down Expand Up @@ -223,13 +231,9 @@ ConfigImpl(

// Parse the filters
for(std::string_view pattern : settings_.filters.symbols.exclude)
{
parseSymbolFilter(settings_.symbolFilter, pattern, true);
}
for(std::string_view pattern : settings_.filters.symbols.include)
{
parseSymbolFilter(settings_.symbolFilter, pattern, false);
}
settings_.symbolFilter.finalize(false, false, false);
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/Lib/ConfigImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ class ConfigImpl
*/
std::string baseURL;

/** Namespace for symbols rendered as "see-below".
/** Namespaces for symbols rendered as "see-below".
*/
std::string seeBelow;
std::vector<FilterPattern> seeBelow;

/** Namespace for symbols rendered as "implementation-defined".
/** Namespaces for symbols rendered as "implementation-defined".
*/
std::string implementationDefined;
std::vector<FilterPattern> implementationDefined;
};

/// @copydoc Config::settings()
Expand Down

0 comments on commit 2753767

Please sign in to comment.