mirror of
https://github.com/nasa/trick.git
synced 2025-05-14 22:42:56 +00:00
* Fix several bugs with processing templates in ICG - Fixed an issue where io_src code for some templates was being placed in the wrong file. - Fixed an issue with templates being instantiated with templates as parameters. - Fixed an issue with templates that instantiate templates. Added additional tests to cover these cases. * Moved the list of template argument header dependencies from ClassValues to PrintFileContents10 so they can be printed to the io_ file regardless of the order in which class info is printed. * Moved the list of template argument header dependencies from ClassValues to PrintFileContents10 so they can be printed to the io_ file regardless of the order in which class info is printed. Moved the list of template argument header dependencies from ClassValues to PrintFileContents10 so they can be printed to the io_ file regardless of the order in which class info is printed. * Added support to handle template enum class type argument and removed some commented code. Added support to handle template enum class type argument and removed some commented code. --------- Co-authored-by: Hong Chen <hchen99@users.noreply.github.com>
90 lines
2.7 KiB
C++
90 lines
2.7 KiB
C++
|
|
#ifndef CLASSVISITOR_HH
|
|
#define CLASSVISITOR_HH
|
|
|
|
#include <set>
|
|
#include <string>
|
|
|
|
#include "clang/Frontend/CompilerInstance.h"
|
|
#include "clang/AST/RecursiveASTVisitor.h"
|
|
#include "ClassValues.hh"
|
|
|
|
class CommentSaver ;
|
|
class EnumValues ;
|
|
class HeaderSearchDirs ;
|
|
class PrintAttributes ;
|
|
|
|
/**
|
|
|
|
This class is a recursive AST visitor that is called when a CXXRecordDecl node
|
|
is found. Inside of a CXXRecord we are only interested in 4 types of nodes, the
|
|
CXXRecord itself, template specializations, friends, and fields. If a field is
|
|
found a FieldVisitor is instantiated and parsing of the field continues in the
|
|
field visitor.
|
|
|
|
A class visitor is usually instantiated by the top level visitor, TranslationUnitVisitor,
|
|
or the typedef visitor, TypedefVisitor.
|
|
|
|
@author Alexander S. Lin
|
|
|
|
@date July 2012
|
|
|
|
*/
|
|
|
|
class CXXRecordVisitor : public clang::RecursiveASTVisitor<CXXRecordVisitor> {
|
|
public:
|
|
CXXRecordVisitor( clang::CompilerInstance & in_ci ,
|
|
CommentSaver & in_cs ,
|
|
HeaderSearchDirs & in_hsd ,
|
|
PrintAttributes & in_pa ,
|
|
bool in_include_virtual_base ) ;
|
|
|
|
~CXXRecordVisitor() ;
|
|
|
|
/* A custom traversal that handles only the node types we are interested in. */
|
|
bool TraverseDecl(clang::Decl *D);
|
|
|
|
/* VisitDecl and VisitType are here for debug printing. */
|
|
bool VisitDecl(clang::Decl *d) ;
|
|
bool VisitType(clang::Type *t) ;
|
|
|
|
/* These routines are called when nodes of the corresponding types are traversed */
|
|
bool VisitCXXRecordDecl(clang::CXXRecordDecl *rec) ;
|
|
bool VisitFriendDecl(clang::FriendDecl *fd) ;
|
|
|
|
/** Returns the class data */
|
|
ClassValues * get_class_data() ;
|
|
|
|
static void addPrivateEmbeddedClass(std::string in_name) ;
|
|
static bool isPrivateEmbeddedClass(std::string in_name) ;
|
|
private:
|
|
/* Save any additional #includes required by template arguments */
|
|
void addTemplateArgumentDependencies(const clang::CXXRecordDecl *rec) ;
|
|
|
|
/** The compiler instance. */
|
|
clang::CompilerInstance & ci ;
|
|
|
|
/** The header search directories */
|
|
HeaderSearchDirs & hsd ;
|
|
|
|
/** Holds all comments */
|
|
CommentSaver & cs ;
|
|
|
|
/** attributes printer */
|
|
PrintAttributes & pa ;
|
|
|
|
/** Holds the class information found, usually returned to caller of this visitor. */
|
|
ClassValues cval ;
|
|
|
|
/** Flag to specify if we should process virtual base classes. */
|
|
bool include_virtual_base ;
|
|
|
|
/** Flag indicating we have found a public/private/protected keyword */
|
|
bool access_spec_found ;
|
|
|
|
static std::set<std::string> private_embedded_classes ;
|
|
static std::set<std::string> friend_classes ;
|
|
} ;
|
|
|
|
#endif
|