This file implements the class DeclResolver which is used to record and order types and functions in the input code that are required by the target regions.
DeclInfo Records information to resolve a single declaration, including if its declared in a system header and other declaration that this declaration depends on.
class
DeclResolver Records, orders and finds the dependencies of Decls (TypeDecls or FunctionDecls)
//===-- sotoc/src/DeclResolver.h -----------------------------------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////===----------------------------------------------------------------------===//#pragma once#include<map>#include<set>#include<stack>#include<unordered_set>llvm::Optional<std::string>getSystemHeaderForDecl(constclang::Decl*D);namespaceclang{classDecl;}classTargetCode;structDeclInfo{constclang::Decl*Decl;std::set<clang::Decl*>DeclDependencies;// std::set<clang::Decl *> ForwardDecls; // for the moment we solve this// differentlyboolIsFromSystemHeader;DeclInfo(clang::Decl*D,boolisFromSysHeader):Decl(D),IsFromSystemHeader(isFromSysHeader){};};usingDeclMap=std::map<clang::Decl*,DeclInfo>;classDeclResolver{DeclMapAllDecls;std::set<clang::Decl*>NonDependentDecls;std::set<std::string>RequiredSystemHeaders;public:virtual~DeclResolver()=0;voidaddDecl(clang::Decl*D);voidorderAndAddFragments(TargetCode&TC);protected:virtualvoidrunOwnVisitor(clang::Decl*D,std::function<void(clang::Decl*Dep)>Fn)=0;virtualvoidfindDependDecls(clang::Decl*D,std::unordered_set<clang::Decl*>&UnresolvedDecls);private:voidtopoSort(std::stack<clang::Decl*>&q);voidtopoSortUtil(std::stack<clang::Decl*>&q,std::map<clang::Decl*,bool>&visited,clang::Decl*D);};classTypeDeclResolver:publicDeclResolver{private:voidrunOwnVisitor(clang::Decl*D,std::function<void(clang::Decl*Dep)>Fn)override;};classFunctionDeclResolver:publicDeclResolver{TypeDeclResolver&Types;public:FunctionDeclResolver(TypeDeclResolver&Types):Types(Types){};private:voidrunOwnVisitor(clang::Decl*D,std::function<void(clang::Decl*Dep)>Fn)override;voidfindDependDecls(clang::Decl*D,std::unordered_set<clang::Decl*>&UnresolvedDecls)override;};