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

网站与网址的区别wordpress data src

网站与网址的区别,wordpress data src,免费发帖论坛大全,网站优化方案基本流程原文 基于RecursiveASTVisitor的ASTFrontendActions. 创建用RecursiveASTVisitor查找特定名字的CXXRecordDeclAST节点的FrontendAction. 创建FrontendAction 编写基于clang的工具(如Clang插件或基于LibTooling的独立工具)时,常见入口是允许在编译过程中执行用户特定操作的F…原文 基于RecursiveASTVisitor的ASTFrontendActions. 创建用RecursiveASTVisitor查找特定名字的CXXRecordDeclAST节点的FrontendAction. 创建FrontendAction 编写基于clang的工具(如Clang插件或基于LibTooling的独立工具)时,常见入口是允许在编译过程中执行用户特定操作的FrontendAction接口. 为了在ASTclang上运行工具,提供了方便的负责执行操作的ASTFrontendAction接口.你只需要实现对每个转换单元返回一个ASTConsumer的CreateASTConsumer方法. class FindNamedClassAction : public clang::ASTFrontendAction { public:virtual std::unique_ptrclang::ASTConsumer CreateASTConsumer(clang::CompilerInstance Compiler, llvm::StringRef InFile) {return std::make_uniqueFindNamedClassConsumer();}//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*)形式的勾挂.只需要为相关节点类型实现方法,就可以了. 首先编写一个访问所有CXXRecordDecl的RecursiveASTVisitor. class FindNamedClassVisitor: public RecursiveASTVisitorFindNamedClassVisitor { 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; }访问SourceManager和ASTContext 有关AST的某些信息(如源位置和全局标识信息)不在AST节点自身中,而是在ASTContext及其关联的源管理器中存储. 要提取它们,需要传递ASTContext进RecursiveASTVisitor实现中. 调用CreateASTConsumer时,CompilerInstance可访问ASTContext.因此,可从那里提取,并把它交给新创建的FindNamedClassConsumer: virtual std::unique_ptrclang::ASTConsumer CreateASTConsumer(clang::CompilerInstance Compiler, llvm::StringRef InFile) {return std::make_uniqueFindNamedClassConsumer(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 RecursiveASTVisitorFindNamedClassVisitor { 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_ptrclang::ASTConsumer CreateASTConsumer(clang::CompilerInstance Compiler, llvm::StringRef InFile) {return std::make_uniqueFindNamedClassConsumer(Compiler.getASTContext());} }; int main(int argc, char **argv) {if (argc 1) {clang::tooling::runToolOnCode(std::make_uniqueFindNamedClassAction(), 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://www.hkea.cn/news/14572504/

相关文章:

  • 网站公告建设方案平顶山公司网站建设
  • 贵阳手机网站开发佛山市和城乡建设局网站
  • 公司网站制作找哪家seo网站推广的主要目的包括
  • 列举常用网站开发技术天津推广的平台
  • 新创建的网站西安网约车公司排行榜
  • 龙岗做网站冻品网站的建设背景
  • 重庆建站培训网页设计代码大全html
  • 网站如何注册微信公众平台 类型郑州网站建设蝶动科技
  • 如何查看自己制作的网站友情链接怎么弄
  • 做网站思想有什么网站可以做
  • 福建省住房和建设厅网站wordpress建站资源
  • 购买云服务器后怎么做网站在深圳学网站设计
  • 外贸seo站广州建网站的公司
  • 联想服务器怎么建设第二个网站广州网页搜索排名提升
  • 微网站和小程序的区别亚洲网站正在建设中
  • 建设网站要多久到账vultr安装WordPress目录
  • 网站有什么组成网站建设方案详解
  • 网站怎样秒收录网站建设公司谁管
  • 河南微网站开发亚马逊雨林电影
  • 自己创业网站开发公司的网址格式
  • 天商阳光网站邮箱北京最近的新闻大事
  • 扫码进入网站 怎么做建设网站翻译英文翻译
  • 跨境电商自建站平台深圳网站开发哪家好
  • 常设中国建设工程法律论坛网站2022百度seo最新规则
  • 网站建设与管理 自考广西城乡住房建设厅网站
  • app开发科技网站建设h5响应式网站建设代理
  • 域名注册好了怎么样做网站杭州模板网站制作方案
  • 网站平台如何推广缪斯国际设计公司官网
  • 做像百姓网这样网站多少钱网站域名组成
  • 网站开发通过什么途径接活自己设计手机的网站