4#ifndef CLANG_TOOL_AST_READER_H
5#define CLANG_TOOL_AST_READER_H
10QT_WARNING_DISABLE_MSVC(4100)
11QT_WARNING_DISABLE_MSVC(4146)
12QT_WARNING_DISABLE_MSVC(4267)
13QT_WARNING_DISABLE_MSVC(4624)
14QT_WARNING_DISABLE_GCC(
"-Wnonnull")
16#include <clang/AST/RecursiveASTVisitor.h>
17#include <clang/Frontend/CompilerInstance.h>
18#include <clang/Frontend/FrontendActions.h>
19#include <clang/Tooling/Tooling.h>
45 m_inputFile = m_context->getSourceManager().getFileEntryRefForID(
46 m_context->getSourceManager().getMainFileID())->getName();
56 std::vector<QString> rawCommentsForCallExpr(
const clang::CallExpr *callExpr)
const;
57 std::vector<QString> rawCommentsFromSourceLocation(
clang::SourceLocation sourceLocation)
const;
62 void processIsolatedComments();
63 void processIsolatedComments(
const clang::FileID file);
65 clang::ASTContext *m_context =
nullptr;
69 std::string m_inputFile;
71 Stores *m_stores =
nullptr;
73 TranslationStores m_trCalls;
74 TranslationStores m_qDeclareTrMacroAll;
75 TranslationStores m_noopTranslationMacroAll;
96 m_visitor.processPreprocessorCalls();
97 bool traverse = m_visitor.TraverseAST(context);
98 qCDebug(lcClang) <<
"TraverseAST: " << traverse;
99 m_visitor.generateOutput();
114 clang::CompilerInstance &compiler, llvm::StringRef )
override
117 auto consumer =
new LupdateASTConsumer(&compiler.getASTContext(),
118 &compiler.getPreprocessor(), m_stores);
122 return std::unique_ptr<clang::ASTConsumer>(consumer);
126 Stores *m_stores =
nullptr;
149 Stores *m_stores =
nullptr;
void HandleTranslationUnit(clang::ASTContext &context) override
LupdateASTConsumer(clang::ASTContext *context, Stores *stores)
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &compiler, llvm::StringRef) override
LupdateFrontendAction(Stores *stores)
bool operator()(const clang::RawComment &LHS, const clang::RawComment &RHS)
BeforeThanCompare(const clang::SourceManager &SM)
bool operator()(const clang::RawComment *LHS, const clang::RawComment *RHS)
bool VisitNamedDecl(clang::NamedDecl *namedDeclaration)
void findContextForTranslationStoresFromPP(clang::NamedDecl *namedDeclaration)
LupdateVisitor(clang::ASTContext *context, Stores *stores)
bool VisitCallExpr(clang::CallExpr *callExpression)
void processPreprocessorCalls()
#define LUPDATE_CLANG_VERSION
#define LUPDATE_CLANG_VERSION_CHECK(major, minor, patch)
bool hasQuote(llvm::StringRef source)
void exploreChildrenForFirstStringLiteral(clang::Stmt *stmt, QString &context)
bool trFunctionPresent(llvm::StringRef text)
QString exploreBases(clang::CXXRecordDecl *recordDecl, const clang::SourceManager &sm)
bool isPointWithin(const clang::SourceRange &sourceRange, const clang::SourceLocation &point, const clang::SourceManager &sm)
bool isQObjectOrQDeclareTrFunctionMacroDeclared(clang::CXXRecordDecl *recordDecl, QString &context, const clang::SourceManager &sm)
static bool capture(const QRegularExpression &exp, const QString &line, QString *i, QString *c)
bool isFileSignificant(const std::string &filePath)
QString contextForFunctionDecl(clang::FunctionDecl *func, const std::string &funcName)
QString contextForNoopMacro(clang::NamedDecl *namedDecl, const clang::SourceManager &sm)
QString lookForContext(clang::CXXRecordDecl *recordDecl, const clang::SourceManager &sm)
Combined button and popup list for selecting options.