本文整理汇总了C++中Analyser::is_component方法的典型用法代码示例。如果您正苦于以下问题:C++ Analyser::is_component方法的具体用法?C++ Analyser::is_component怎么用?C++ Analyser::is_component使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyser
的用法示例。
在下文中一共展示了Analyser::is_component方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
static void check(Analyser& analyser, Decl const* decl)
{
if (analyser.is_main() &&
analyser.config()->value("main_namespace_check") == "off") {
return; // RETURN
}
if (analyser.is_global_package()) {
return; // RETURN
}
Location location(analyser.get_location(decl));
NamedDecl const* named(llvm::dyn_cast<NamedDecl>(decl));
if (analyser.is_component(location.file()) && named) {
if (llvm::dyn_cast<NamespaceDecl>(decl)
|| llvm::dyn_cast<UsingDirectiveDecl>(decl)) {
// namespace declarations are permissible e.g. for forward declarations.
return; // RETURN
}
else if (TagDecl const* tag = llvm::dyn_cast<TagDecl>(decl)) {
// Forward declarations are always permissible but definitions are not.
if (!tag->isThisDeclarationADefinition()
&& analyser.is_component_header(location.file())) {
return; // RETURN
}
}
else if (llvm::dyn_cast<NamespaceAliasDecl>(decl)
&& analyser.is_component_source(decl)) {
return; // RETURN
}
DeclContext const* context(decl->getDeclContext());
std::string name = named->getNameAsString();
if (llvm::dyn_cast<TranslationUnitDecl>(context)) {
if (name != "main"
&& name != "RCSId"
&& !llvm::dyn_cast<ClassTemplateSpecializationDecl>(decl)
&& !llvm::dyn_cast<ClassTemplatePartialSpecializationDecl>(decl)
&& name.find("operator new") == std::string::npos
&& name.find("operator delete") == std::string::npos
) {
analyser.report(decl, check_name, "TR04",
"Declaration of '%0' at global scope", true)
<< decl->getSourceRange()
<< name;
}
return; // RETURN
}
NamespaceDecl const* space =
llvm::dyn_cast<NamespaceDecl>(context);
if (!space) {
return; // RETURN
}
std::string pkgns = analyser.package();
if ( space->isAnonymousNamespace()
&& llvm::dyn_cast<NamespaceDecl>(space->getDeclContext())) {
space =
llvm::dyn_cast<NamespaceDecl>(space->getDeclContext());
}
if (space->getNameAsString() ==
analyser.config()->toplevel_namespace()) {
// No package namespace. This is OK if no package namespace has
// been seen, for the sake of legacy "package_name" components.
DeclContext::decl_iterator b = space->decls_begin();
DeclContext::decl_iterator e = space->decls_end();
bool found = false;
while (!found && b != e) {
const NamespaceDecl *ns =
llvm::dyn_cast<NamespaceDecl>(*b++);
found = ns && ns->getNameAsString() == analyser.package();
}
if (!found) {
pkgns = analyser.config()->toplevel_namespace();
}
}
if (name.length() > 0)
{
std::string spname = space->getNameAsString();
NamespaceDecl const* outer = space;
if (pkgns == analyser.package()) {
outer = llvm::dyn_cast<NamespaceDecl>(
space->getDeclContext());
}
if ((spname != pkgns
|| !outer
|| outer->getNameAsString() !=
analyser.config()->toplevel_namespace())
&& ( spname != analyser.config()->toplevel_namespace()
|| name.find(analyser.package() + '_') != 0
)
&& to_lower(spname) != to_lower(analyser.component())
&& !llvm::dyn_cast<ClassTemplateSpecializationDecl>(decl)
&& !llvm::dyn_cast<ClassTemplatePartialSpecializationDecl>(decl)
&& name.find("operator new") == std::string::npos
&& name.find("operator delete") == std::string::npos
&& !isSpecialFunction(named)
&& ( analyser.is_component_header(named)
|| named->hasLinkage()
//.........这里部分代码省略.........