summaryrefslogtreecommitdiffstats
path: root/src/qdoc/qdoc/src/qdoc/clangcodeparser.h
blob: 2318a048d39049aacef283791d88097327e6a926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef CLANGCODEPARSER_H
#define CLANGCODEPARSER_H

#include "cppcodeparser.h"

#include "config.h"

#include <QtCore/qtemporarydir.h>
#include <QtCore/QStringList>

#include <optional>

typedef struct CXTranslationUnitImpl *CXTranslationUnit;

QT_BEGIN_NAMESPACE

struct ParsedCppFileIR {
    std::vector<UntiedDocumentation> untied;
    std::vector<TiedDocumentation> tied;
};

struct PCHFile {
    QTemporaryDir dir;
    QByteArray name;
};

std::optional<PCHFile> buildPCH(
    QDocDatabase* qdb,
    QString module_header,
    const std::set<Config::HeaderFilePath>& all_headers,
    const std::vector<QByteArray>& include_paths,
    const QList<QByteArray>& defines
);

class ClangCodeParser : public CodeParser
{
public:
    ClangCodeParser(
        Config&,
        const std::vector<QByteArray>& include_paths,
        const QList<QByteArray>& defines,
        std::optional<std::reference_wrapper<const PCHFile>> pch
    );
    ~ClangCodeParser() override = default;

    void initializeParser() override {}
    void terminateParser() override {}
    QString language() override;
    QStringList sourceFileNameFilter() override;
    void parseSourceFile(const Location &, const QString &, CppCodeParser&) override {}
    ParsedCppFileIR parse_cpp_file(const QString &filePath);
    Node *parseFnArg(const Location &location, const QString &fnSignature, const QString &idTag, QStringList context);

private:
    std::set<Config::HeaderFilePath> m_allHeaders {}; // file name->path
    const std::vector<QByteArray>& m_includePaths;
    QList<QByteArray> m_defines {};
    std::vector<const char *> m_args {};
    QStringList m_namespaceScope {};
    QByteArray s_fn;
    std::optional<std::reference_wrapper<const PCHFile>> m_pch;
};

QT_END_NAMESPACE

#endif