File indexing completed on 2024-04-28 16:57:51
0001 /* 0002 This file is part of the clazy static checker. 0003 0004 Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com 0005 Author: Sérgio Martins <sergio.martins@kdab.com> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #ifndef CLAZY_MINI_AST_DUMPER 0024 #define CLAZY_MINI_AST_DUMPER 0025 0026 #include <clang/AST/ASTConsumer.h> 0027 #include <clang/Frontend/FrontendAction.h> 0028 #include <clang/AST/RecursiveASTVisitor.h> 0029 #include <llvm/ADT/StringRef.h> 0030 0031 #include <memory> 0032 #include <vector> 0033 #include <string> 0034 #include <utility> 0035 0036 namespace clang { 0037 class CompilerInstance; 0038 class ASTContext; 0039 class Decl; 0040 class Stmt; 0041 } 0042 0043 class MiniAstDumperASTAction : public clang::PluginASTAction 0044 { 0045 public: 0046 MiniAstDumperASTAction(); 0047 protected: 0048 bool ParseArgs(const clang::CompilerInstance &ci, const std::vector<std::string> &args_) override; 0049 std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &ci, llvm::StringRef) override; 0050 }; 0051 0052 class MiniASTDumperConsumer 0053 : public clang::ASTConsumer 0054 , public clang::RecursiveASTVisitor<MiniASTDumperConsumer> 0055 { 0056 public: 0057 explicit MiniASTDumperConsumer(); 0058 ~MiniASTDumperConsumer() override; 0059 0060 bool VisitDecl(clang::Decl *decl); 0061 bool VisitStmt(clang::Stmt *stm); 0062 void HandleTranslationUnit(clang::ASTContext &ctx) override; 0063 0064 private: 0065 MiniASTDumperConsumer(const MiniASTDumperConsumer &) = delete; 0066 }; 0067 0068 #endif