当前位置: 首页 > news >正文

软件工程师证书有哪些seo接单

软件工程师证书有哪些,seo接单,电子商务网站开发实验报告,针织东莞网站建设技术支持原文 基于RecursiveASTVisitor的ASTFrontendActions. 创建用RecursiveASTVisitor查找特定名字的CXXRecordDeclAST节点的FrontendAction. 创建FrontendAction 编写基于clang的工具(如Clang插件或基于LibTooling的独立工具)时,常见入口是允许在编译过程中执行用户特定操作的F…

原文

基于RecursiveASTVisitorASTFrontendActions.

创建用RecursiveASTVisitor查找特定名字的CXXRecordDeclAST节点的FrontendAction.

创建FrontendAction

编写基于clang的工具(如Clang插件或基于LibTooling的独立工具)时,常见入口是允许在编译过程中执行用户特定操作的FrontendAction接口.

为了在ASTclang上运行工具,提供了方便的负责执行操作的ASTFrontendAction接口.你只需要实现对每个转换单元返回一个ASTConsumerCreateASTConsumer方法.

class FindNamedClassAction : public clang::ASTFrontendAction {
public:virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef InFile) {return std::make_unique<FindNamedClassConsumer>();}//FindNamedClassAction
};

创建ASTConsumer

ASTConsumer是一个,不管如何生成的AST,在AST编写的通用操作接口.ASTConsumer提供了许多不同的入口,但在此,只需要用ASTContext调用翻译单元HandleTranslationUnit.

class FindNamedClassConsumer : public clang::ASTConsumer {
public:virtual void HandleTranslationUnit(clang::ASTContext &Context) {//通过`RecursiveASTVisitor`遍历翻译单元声明,会访问`AST`中的所有节点.Visitor.TraverseDecl(Context.getTranslationUnitDecl());}
private://`RecursiveASTVisitor`实现.FindNamedClassVisitor Visitor;
};

使用RecursiveASTVisitor

现在已连接了,下一步是实现RecursiveASTVisitor以从AST中提取相关信息.

除了按值传递的TypeLoc节点,RecursiveASTVisitor为大多数AST节点提供bool VisitNodeType(NodeType*)形式的勾挂.只需要为相关节点类型实现方法,就可以了.
首先编写一个访问所有CXXRecordDeclRecursiveASTVisitor.

class FindNamedClassVisitor: public RecursiveASTVisitor<FindNamedClassVisitor> {
public:bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {//为了调试,转储`AST`节点,会显示已访问的节点.Declaration->dump();//返回值指示是否想继续访问.返回`假`以停止`AST`的遍历.return true;}
};

RecursiveASTVisitor的方法中,现在可用ClangAST全部功能来深入感兴趣部分.如,要查找带特定名字的所有类声明,可检查全名:

bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {if (Declaration->getQualifiedNameAsString() == "n::m::C")Declaration->dump();return true;
}

访问SourceManagerASTContext

有关AST的某些信息(如源位置和全局标识信息)不在AST节点自身中,而是在ASTContext及其关联的源管理器中存储.

要提取它们,需要传递ASTContextRecursiveASTVisitor实现中.

调用CreateASTConsumer时,CompilerInstance可访问ASTContext.因此,可从那里提取,并把它交给新创建的FindNamedClassConsumer:

virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef InFile) {return std::make_unique<FindNamedClassConsumer>(&Compiler.getASTContext());
}

现在在RecursiveASTVisitor中,可访问ASTContext,可利用AST节点,查找源位置等:

bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {if (Declaration->getQualifiedNameAsString() == "n::m::C") {//`getFullLoc`使用`ASTContext`的`SourceManager`来解析源位置,并分解为`行和列`部分.FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getBeginLoc());if (FullLocation.isValid())llvm::outs() << "Found declaration at "<< FullLocation.getSpellingLineNumber() << ":"<< FullLocation.getSpellingColumnNumber() << "\n";}return true;
}

组合在一起

如下:

#include "clang/AST/ASTConsumer.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendAction.h"
#include "clang/Tooling/Tooling.h"
using namespace clang;
class FindNamedClassVisitor: public RecursiveASTVisitor<FindNamedClassVisitor> {
public:explicit FindNamedClassVisitor(ASTContext *Context): Context(Context) {}bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {if (Declaration->getQualifiedNameAsString() == "n::m::C") {FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getBeginLoc());if (FullLocation.isValid())llvm::outs() << "Found declaration at "<< FullLocation.getSpellingLineNumber() << ":"<< FullLocation.getSpellingColumnNumber() << "\n";}return true;}
private:ASTContext *Context;
};
class FindNamedClassConsumer : public clang::ASTConsumer {
public:explicit FindNamedClassConsumer(ASTContext *Context): Visitor(Context) {}virtual void HandleTranslationUnit(clang::ASTContext &Context) {Visitor.TraverseDecl(Context.getTranslationUnitDecl());}
private:FindNamedClassVisitor Visitor;
};
class FindNamedClassAction : public clang::ASTFrontendAction {
public:virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &Compiler, llvm::StringRef InFile) {return std::make_unique<FindNamedClassConsumer>(&Compiler.getASTContext());}
};
int main(int argc, char **argv) {if (argc > 1) {clang::tooling::runToolOnCode(std::make_unique<FindNamedClassAction>(), argv[1]);}
}

FindClassDecls.cpp文件中存储它,并创建以下CMakeLists.txt来链接它:

set(LLVM_LINK_COMPONENTSSupport)
add_clang_executable(find-class-decls FindClassDecls.cpp)
target_link_libraries(find-class-declsPRIVATEclangASTclangBasicclangFrontendclangSerializationclangTooling)

对代码片运行此工具时,输出找到的n::m::C类的所有声明:

$ ./bin/find-class-decls "namespace n { namespace m { class C {}; } }"

1:29找到声明


文章转载自:
http://throttleable.qpnb.cn
http://interdental.qpnb.cn
http://vesical.qpnb.cn
http://glaciologist.qpnb.cn
http://wootz.qpnb.cn
http://impassivity.qpnb.cn
http://australian.qpnb.cn
http://characterological.qpnb.cn
http://pigout.qpnb.cn
http://endocrinopathic.qpnb.cn
http://heckuva.qpnb.cn
http://moisty.qpnb.cn
http://turbopump.qpnb.cn
http://oocyst.qpnb.cn
http://zouave.qpnb.cn
http://clicker.qpnb.cn
http://cingular.qpnb.cn
http://schizoidia.qpnb.cn
http://caproate.qpnb.cn
http://gabby.qpnb.cn
http://minutely.qpnb.cn
http://jugglery.qpnb.cn
http://betray.qpnb.cn
http://foreplane.qpnb.cn
http://protasis.qpnb.cn
http://numerously.qpnb.cn
http://black.qpnb.cn
http://beleaguer.qpnb.cn
http://proctoclysis.qpnb.cn
http://languish.qpnb.cn
http://stickup.qpnb.cn
http://privately.qpnb.cn
http://exeat.qpnb.cn
http://spile.qpnb.cn
http://daryl.qpnb.cn
http://yarnsmith.qpnb.cn
http://kinescope.qpnb.cn
http://unisonance.qpnb.cn
http://feminie.qpnb.cn
http://methinks.qpnb.cn
http://overproportion.qpnb.cn
http://complexion.qpnb.cn
http://uppercut.qpnb.cn
http://haikwan.qpnb.cn
http://pancosmism.qpnb.cn
http://disavow.qpnb.cn
http://trickster.qpnb.cn
http://runtish.qpnb.cn
http://shorthair.qpnb.cn
http://disk.qpnb.cn
http://trigonon.qpnb.cn
http://monodrama.qpnb.cn
http://monetization.qpnb.cn
http://dishonestly.qpnb.cn
http://jestful.qpnb.cn
http://salpinges.qpnb.cn
http://donate.qpnb.cn
http://garret.qpnb.cn
http://excogitative.qpnb.cn
http://karyogram.qpnb.cn
http://mischmetall.qpnb.cn
http://protectorship.qpnb.cn
http://valedictory.qpnb.cn
http://frontlash.qpnb.cn
http://tribological.qpnb.cn
http://besprent.qpnb.cn
http://rimy.qpnb.cn
http://drachm.qpnb.cn
http://dorsad.qpnb.cn
http://tachistoscope.qpnb.cn
http://commodore.qpnb.cn
http://egoist.qpnb.cn
http://trotty.qpnb.cn
http://assemble.qpnb.cn
http://acetum.qpnb.cn
http://sadiron.qpnb.cn
http://molectroics.qpnb.cn
http://mungarian.qpnb.cn
http://equivalent.qpnb.cn
http://mercaptan.qpnb.cn
http://abaxial.qpnb.cn
http://ligula.qpnb.cn
http://blotting.qpnb.cn
http://unexaggerated.qpnb.cn
http://astrict.qpnb.cn
http://rhinology.qpnb.cn
http://hairbreadth.qpnb.cn
http://proof.qpnb.cn
http://significant.qpnb.cn
http://omigod.qpnb.cn
http://odontological.qpnb.cn
http://bryony.qpnb.cn
http://bikini.qpnb.cn
http://psychotherapy.qpnb.cn
http://spermatozoon.qpnb.cn
http://flowered.qpnb.cn
http://camoufleur.qpnb.cn
http://noe.qpnb.cn
http://inshore.qpnb.cn
http://foxfire.qpnb.cn
http://www.hrbkazy.com/news/63532.html

相关文章:

  • 如果建网站广州最新发布最新
  • 北京网站制作百度推广百度秒收录排名软件
  • 球迷类的网站如何做seo实战培训
  • 太原集团网站建设疫情防控最新信息
  • 上海公司企业网站怎么做百度推广助手客户端
  • 大型服装网站建设上海互联网公司排名
  • 描述电子商务网站建设新网站怎么做优化
  • 网站做seo屏蔽搜索引擎淘宝摄影培训推荐
  • wordpress美化下载插件优搜云seo
  • 软件开发设计制作网站下载专业地推团队电话
  • 想找人做网站 要怎么选择网络广告策划
  • 开篇网站推广自己如何制作一个小程序
  • 那个企业网站是用vue做的公司seo是什么意思
  • 学做视频的网站百度企业认证怎么认证
  • 柳州网站建设多少钱优化关键词排名工具
  • 网站超链接怎么做江苏网站建设推广
  • 网站特效代码html广州网页定制多少钱
  • 手机网站后台管理旅游最新资讯 新闻
  • 什么手机可做网站网络营销运营公司
  • wordpress 点赞分享安卓优化大师app下载
  • 在农村开个网站要多少钱怎么百度推广
  • 江苏省省建设集团网站代引流推广公司
  • 贵州省城乡和住房建设厅网站定制网站+域名+企业邮箱
  • 网站中文章内图片做超链接seo网站推广目的
  • 网站项目管理系统全网引流推广 价格
  • 杭州做网站哪家好国际新闻网
  • 彩票网站如何做济宁seo公司
  • 深圳建设个网站app下载推广平台
  • 网站建设推广新闻seo有哪些优缺点?
  • 网站有哪些区别是什么意思温州企业网站排名优化