summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mkspecs/features/qt_find_clang.prf4
-rw-r--r--src/qdoc/clangcodeparser.cpp44
-rw-r--r--src/qdoc/clangcodeparser.h1
-rw-r--r--src/qdoc/config.cpp1
-rw-r--r--src/qdoc/config.h2
5 files changed, 47 insertions, 5 deletions
diff --git a/mkspecs/features/qt_find_clang.prf b/mkspecs/features/qt_find_clang.prf
index 14a2e80bf..7e65d23fb 100644
--- a/mkspecs/features/qt_find_clang.prf
+++ b/mkspecs/features/qt_find_clang.prf
@@ -84,8 +84,8 @@ for(_, $$list(_)) { # just a way to break easily
else: \
CLANG_LIBS += -lclang
- !versionIsAtLeast($$CLANG_VERSION, "3.6.2") {
- log("LLVM/Clang version >= 3.6.2 required, version provided: $$CLANG_VERSION.$$escape_expand(\\n)")
+ !versionIsAtLeast($$CLANG_VERSION, "3.9.0") {
+ log("LLVM/Clang version >= 3.9.0 required, version provided: $$CLANG_VERSION.$$escape_expand(\\n)")
log("Clang was found in $$CLANG_INSTALL_DIR. Set the CLANG_INSTALL_DIR environment variable to override.$$escape_expand(\\n)")
break()
}
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 3e76a9ff8..ee7897060 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -721,7 +721,9 @@ ClangCodeParser::~ClangCodeParser()
}
/*!
-
+ Get the include paths from the qdoc configuration database
+ \a config. Call the initializeParser() in the base class.
+ Get the defines list from the qdocconf database.
*/
void ClangCodeParser::initializeParser(const Config &config)
{
@@ -733,6 +735,30 @@ void ClangCodeParser::initializeParser(const Config &config)
pchFileDir_.reset(nullptr);
allHeaders_.clear();
pchName_.clear();
+ defines_.clear();
+ QSet<QString> accepted;
+ {
+ const QStringList tmpDefines = config.getStringList(CONFIG_CLANGDEFINES);
+ for (const QString &def : tmpDefines) {
+ if (!accepted.contains(def)) {
+ QByteArray tmp("-D");
+ tmp.append(def.toUtf8());
+ defines_.append(tmp.constData());
+ accepted.insert(def);
+ }
+ }
+ }
+ {
+ const QStringList tmpDefines = config.getStringList(CONFIG_DEFINES);
+ for (const QString &def : tmpDefines) {
+ if (!accepted.contains(def) && !def.contains(QChar('*'))) {
+ QByteArray tmp("-D");
+ tmp.append(def.toUtf8());
+ defines_.append(tmp.constData());
+ accepted.insert(def);
+ }
+ }
+ }
}
/*!
@@ -803,6 +829,9 @@ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QStrin
"-I" CLANG_RESOURCE_DIR
};
std::vector<const char *> args(std::begin(defaultArgs), std::end(defaultArgs));
+ // Add the defines from the qdocconf file.
+ for (const auto &p : qAsConst(defines_))
+ args.push_back(p.constData());
auto moreArgs = includePaths_;
if (moreArgs.isEmpty()) {
@@ -824,8 +853,9 @@ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QStrin
for (const auto &p : qAsConst(moreArgs))
args.push_back(p.constData());
- auto flags = CXTranslationUnit_Incomplete | CXTranslationUnit_SkipFunctionBodies;
- CXIndex index = clang_createIndex(1, 1);
+ auto flags = CXTranslationUnit_Incomplete | CXTranslationUnit_SkipFunctionBodies |
+ CXTranslationUnit_KeepGoing;
+ CXIndex index = clang_createIndex(1, 0);
if (!pchFileDir_) {
pchFileDir_.reset(new QTemporaryDir(QDir::tempPath() + QLatin1String("/qdoc_pch")));
@@ -930,10 +960,18 @@ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QStrin
}
}
}
+ args.clear();
+ args.insert(args.begin(), std::begin(defaultArgs), std::end(defaultArgs));
+ // Add the defines from the qdocconf file.
+ for (const auto &p : qAsConst(defines_))
+ args.push_back(p.constData());
if (!pchName_.isEmpty() && !filePath.endsWith(".mm")) {
+ args.push_back("-w");
args.push_back("-include-pch");
args.push_back(pchName_.constData());
}
+ for (const auto &p : qAsConst(moreArgs))
+ args.push_back(p.constData());
CXTranslationUnit tu;
CXErrorCode err = clang_parseTranslationUnit2(index, filePath.toLocal8Bit(), args.data(),
diff --git a/src/qdoc/clangcodeparser.h b/src/qdoc/clangcodeparser.h
index e0359e400..ce6a7f260 100644
--- a/src/qdoc/clangcodeparser.h
+++ b/src/qdoc/clangcodeparser.h
@@ -59,6 +59,7 @@ private:
QVector<QByteArray> includePaths_;
QScopedPointer<QTemporaryDir> pchFileDir_;
QByteArray pchName_;
+ QVector<QByteArray> defines_;
};
QT_END_NAMESPACE
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 76c615046..105bb400c 100644
--- a/src/qdoc/config.cpp
+++ b/src/qdoc/config.cpp
@@ -47,6 +47,7 @@ QString ConfigStrings::AUTOLINKERRORS = QStringLiteral("autolinkerrors");
QString ConfigStrings::BASE = QStringLiteral("base");
QString ConfigStrings::BASEDIR = QStringLiteral("basedir");
QString ConfigStrings::BUILDVERSION = QStringLiteral("buildversion");
+QString ConfigStrings::CLANGDEFINES = QStringLiteral("clangdefines");
QString ConfigStrings::CODEINDENT = QStringLiteral("codeindent");
QString ConfigStrings::CODEPREFIX = QStringLiteral("codeprefix");
QString ConfigStrings::CODESUFFIX = QStringLiteral("codesuffix");
diff --git a/src/qdoc/config.h b/src/qdoc/config.h
index 588e0e0a9..576f7375d 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -160,6 +160,7 @@ struct ConfigStrings
static QString BASE;
static QString BASEDIR;
static QString BUILDVERSION;
+ static QString CLANGDEFINES;
static QString CODEINDENT;
static QString CODEPREFIX;
static QString CODESUFFIX;
@@ -241,6 +242,7 @@ struct ConfigStrings
#define CONFIG_BASE ConfigStrings::BASE
#define CONFIG_BASEDIR ConfigStrings::BASEDIR
#define CONFIG_BUILDVERSION ConfigStrings::BUILDVERSION
+#define CONFIG_CLANGDEFINES ConfigStrings::CLANGDEFINES
#define CONFIG_CODEINDENT ConfigStrings::CODEINDENT
#define CONFIG_CODEPREFIX ConfigStrings::CODEPREFIX
#define CONFIG_CODESUFFIX ConfigStrings::CODESUFFIX