1 | // Copyright (C) 2021 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef CLANGCODEPARSER_H |
5 | #define CLANGCODEPARSER_H |
6 | |
7 | #include "cppcodeparser.h" |
8 | |
9 | #include <QtCore/qtemporarydir.h> |
10 | #include <QtCore/QStringList> |
11 | |
12 | typedef struct CXTranslationUnitImpl *CXTranslationUnit; |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | class ClangCodeParser : public CodeParser |
17 | { |
18 | public: |
19 | static const QStringList accepted_header_file_extensions; |
20 | |
21 | public: |
22 | ~ClangCodeParser() override = default; |
23 | |
24 | void initializeParser() override; |
25 | void terminateParser() override {} |
26 | QString language() override; |
27 | QStringList sourceFileNameFilter() override; |
28 | void parseHeaderFile(const Location &location, const QString &filePath); |
29 | void parseSourceFile(const Location &location, const QString &filePath, CppCodeParser&) override; |
30 | void precompileHeaders(QString module_header); |
31 | Node *parseFnArg(const Location &location, const QString &fnSignature, const QString &idTag) override; |
32 | static const QByteArray &fn() { return s_fn; } |
33 | |
34 | private: |
35 | void getDefaultArgs(); |
36 | void getMoreArgs(); |
37 | |
38 | void buildPCH(QString module_header); |
39 | |
40 | void printDiagnostics(const CXTranslationUnit &translationUnit) const; |
41 | |
42 | QMultiHash<QString, QString> m_allHeaders {}; // file name->path |
43 | QList<QByteArray> m_includePaths {}; |
44 | QScopedPointer<QTemporaryDir> m_pchFileDir {}; |
45 | QByteArray m_pchName {}; |
46 | QList<QByteArray> m_defines {}; |
47 | std::vector<const char *> m_args {}; |
48 | QList<QByteArray> m_moreArgs {}; |
49 | QStringList m_namespaceScope {}; |
50 | static QByteArray s_fn; |
51 | }; |
52 | |
53 | QT_END_NAMESPACE |
54 | |
55 | #endif |
56 |