diff --git a/Doxyfile b/Doxyfile index 44c60dc..a7c1fe6 100644 --- a/Doxyfile +++ b/Doxyfile @@ -396,7 +396,7 @@ ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES -INCLUDE_PATH = +INCLUDE_PATH = INCLUDE_FILE_PATTERNS = *.h PREDEFINED = EXPAND_AS_DEFINED = diff --git a/src/polyglat-c/annotation-emitter.h b/src/polyglat-c/annotation-emitter.h index 4df267e..f9ab5e0 100644 --- a/src/polyglat-c/annotation-emitter.h +++ b/src/polyglat-c/annotation-emitter.h @@ -3,31 +3,44 @@ #include namespace polyglat::c { - + /** + * @brief A recursive-ast-visitor that emits annotations to symbols + * to preserve object-oriented things over low-level environment (LLVM). + */ class AnnotationEmitter final : public clang::RecursiveASTVisitor { clang::Sema *Sema; static auto ShouldBeAnnotated(const clang::NamedDecl *decl) -> bool; public: + /** + * @brief Creates new instance with specified semantic context. + * @param sema A semantic context to use. + */ explicit AnnotationEmitter(clang::Sema *sema) : Sema(sema) {} + /** + * @brief Tries to annotate declaration of record. + * @param decl A declaration to be annotated. + */ auto VisitRecordDecl(clang::RecordDecl *decl) -> bool; + /** + * @brief Tries to annotate declaration of function. + * @param decl A declaration to be annotated. + */ auto VisitFunctionDecl(clang::FunctionDecl *decl) -> bool; }; - class ASTConsumer final : public clang::SemaConsumer { - clang::Sema *Sema = nullptr; - - public: - void HandleTranslationUnit(clang::ASTContext &ctx) override; - - void InitializeSema(clang::Sema &sema) override; - }; - + /** + * @brief A plugin-ast-action that emits annotations to result IR + * to preserve object-oriented things over low-level environment (LLVM). + */ class AnnotationEmitAction final : public clang::PluginASTAction { public: + /** + * @brief Creates new instance. + */ auto CreateASTConsumer(clang::CompilerInstance &ci, llvm::StringRef inFile) -> std::unique_ptr override; auto ParseArgs(const clang::CompilerInstance &ci, const std::vector &arg) -> bool override; diff --git a/src/polyglat-c/src/annotation-emitter.cxx b/src/polyglat-c/src/annotation-emitter.cxx index 586d73c..cc622c6 100644 --- a/src/polyglat-c/src/annotation-emitter.cxx +++ b/src/polyglat-c/src/annotation-emitter.cxx @@ -59,14 +59,19 @@ auto polyglat::c::AnnotationEmitter::VisitFunctionDecl(clang::FunctionDecl *decl return true; } -void polyglat::c::ASTConsumer::HandleTranslationUnit(clang::ASTContext &Ctx) { - AnnotationEmitter emitter{Sema}; - emitter.TraverseDecl(Ctx.getTranslationUnitDecl()); -} +class ASTConsumer final : public clang::SemaConsumer { + clang::Sema *Sema = nullptr; -void polyglat::c::ASTConsumer::InitializeSema(clang::Sema &S) { - Sema = &S; -} +public: + void HandleTranslationUnit(clang::ASTContext &ctx) override { + polyglat::c::AnnotationEmitter emitter{Sema}; + emitter.TraverseDecl(ctx.getTranslationUnitDecl()); + } + + void InitializeSema(clang::Sema &sema) override { + Sema = &sema; + } +}; auto polyglat::c::AnnotationEmitAction::CreateASTConsumer(clang::CompilerInstance & /**/, llvm::StringRef /**/) -> std::unique_ptr { return std::make_unique();