diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-12-21 16:53:21 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-12-24 07:53:46 +0000 |
commit | 7b251d37246a0821291ed3bb4f5557dbf39372ba (patch) | |
tree | 6b2e23e1c7eb337e88d9683348e4fee5eb0e8b34 /tools/qmltc | |
parent | bd0695e2efab5ad65a7fbcb4f8b802ea81ddc312 (diff) |
qmltc: Use special name for a special url-returning generated function
We can in fact get ambiguity problem (which for some reason only results
in an unused-function warning with clang 10) which practically results
in UB in the user code relying on qmltc output (due to C++ compiler
choosing the wrong function to call)
Consider the following:
// MyType.qml
Component { QtObject{} }
is compiled (by qmltc) into
// mytype.h
class MyType : public QQmlComponent {};
// mytype.cpp
static const QUrl &url() { /* return this doc url */ }
// ^ warning: unused-function
MyType::MyType(/* ... */) {
// ...
auto compilationUnitUrl = url(); // oops! QQmlComponent::url() is used
}
Change-Id: Ic754ce90b66e3f371a89e2d3395ca7d6b022c694
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
(cherry picked from commit 4355faedee5bb35854019cddfba516b61bd239e3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/qmltc')
-rw-r--r-- | tools/qmltc/prototype/codegenerator.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp index bb72fa69d7..06d3667c80 100644 --- a/tools/qmltc/prototype/codegenerator.cpp +++ b/tools/qmltc/prototype/codegenerator.cpp @@ -1875,7 +1875,7 @@ void CodeGenerator::compileScriptBindingOfComponent(QQmlJSAotObject ¤t, void CodeGenerator::compileUrlMethod() { m_urlMethod.returnType = u"const QUrl &"_qs; - m_urlMethod.name = u"url"_qs; + m_urlMethod.name = u"q_qmltc_docUrl"_qs; m_urlMethod.body << u"static QUrl docUrl = %1;"_qs.arg( CodeGeneratorUtility::toResourcePath(m_options.resourcePath)); m_urlMethod.body << u"return docUrl;"_qs; |