summaryrefslogtreecommitdiff
path: root/src/qdoc/clangcodeparser.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-01-26 11:12:47 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-01-31 07:54:16 +0000
commit5b205769a6f898093fd9f04d33856e5686414303 (patch)
treeb0c0daa600c4e5e9a58857263e88488c4fa6de1f /src/qdoc/clangcodeparser.cpp
parenta419399cbf631b78768eb159775004ddc4e46370 (diff)
downloadqttools-5b205769a6f898093fd9f04d33856e5686414303.tar.gz
qdoc: Add a logging category
Remove the debug functionality from the Generator class and add a logging category instead. Add some debug statements outputting the command line arguments and clang arguments. This makes it possible to obtain logging output by setting for example QT_LOGGING_RULES=qt.qdoc.debug=true . Task-number: PYSIDE-363 Change-Id: I3ecfe548e14aa3e2d03f19d07fc61a2647b75111 Reviewed-by: Martin Smith <martin.smith@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r--src/qdoc/clangcodeparser.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 3c5d615c2..ea4ffb18e 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -47,6 +47,7 @@
#include "codechunk.h"
#include "config.h"
#include "clangcodeparser.h"
+#include "loggingcategory.h"
#include "qdocdatabase.h"
#include <qdebug.h>
#include <qscopedvaluerollback.h>
@@ -61,6 +62,25 @@ QT_BEGIN_NAMESPACE
static CXTranslationUnit_Flags flags_ = (CXTranslationUnit_Flags)0;
static CXIndex index_ = 0;
+#ifndef QT_NO_DEBUG_STREAM
+template <class T>
+static QDebug operator<<(QDebug debug, const std::vector<T> &v)
+{
+ QDebugStateSaver saver(debug);
+ debug.noquote();
+ debug.nospace();
+ const size_t size = v.size();
+ debug << "std::vector<>[" << size << "](";
+ for (size_t i = 0; i < size; ++i) {
+ if (i)
+ debug << ", ";
+ debug << v[i];
+ }
+ debug << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
/*!
Call clang_visitChildren on the given cursor with the lambda as a callback
T can be any functor that is callable with a CXCursor parameter and returns a CXChildVisitResult
@@ -975,6 +995,8 @@ void ClangCodeParser::initializeParser(const Config &config)
}
}
}
+ qCDebug(lcQdoc).nospace() << __FUNCTION__ << " Clang v" << CINDEX_VERSION_MAJOR
+ << '.' << CINDEX_VERSION_MINOR;
}
/*!
@@ -1170,6 +1192,8 @@ void ClangCodeParser::buildPCH()
tmpHeader.toLatin1().data(),
args_.data(), static_cast<int>(args_.size()), nullptr, 0,
flags_ | CXTranslationUnit_ForSerialization, &tu);
+ qCDebug(lcQdoc) << __FUNCTION__ << "clang_parseTranslationUnit2("
+ << tmpHeader << args_ << ") returns" << err;
if (!err && tu) {
pchName_ = pchFileDir_->path().toUtf8() + "/" + module + ".pch";
auto error = clang_saveTranslationUnit(tu, pchName_.constData(), clang_defaultSaveOptions(tu));
@@ -1238,6 +1262,8 @@ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QStrin
CXTranslationUnit tu;
CXErrorCode err = clang_parseTranslationUnit2(index_, filePath.toLocal8Bit(), args_.data(),
static_cast<int>(args_.size()), nullptr, 0, flags_, &tu);
+ qCDebug(lcQdoc) << __FUNCTION__ << "clang_parseTranslationUnit2("
+ << filePath << args_ << ") returns" << err;
if (err || !tu) {
qWarning() << "(qdoc) Could not parse source file" << filePath << " error code:" << err;
clang_disposeIndex(index_);
@@ -1397,7 +1423,8 @@ Node* ClangCodeParser::parseFnArg(const Location& location, const QString& fnArg
1,
flags,
&tu);
-
+ qCDebug(lcQdoc) << __FUNCTION__ << "clang_parseTranslationUnit2("
+ << dummyFileName << args_ << ") returns" << err;
if (err || !tu) {
location.error(ClangCodeParser::tr("clang could not parse \\fn %1").arg(fnArg));
clang_disposeTranslationUnit(tu);