Commit 79fbb0db authored by Eike Ziller's avatar Eike Ziller

Merge remote-tracking branch 'origin/2.8' into HEAD

Conflicts:
	src/libs/cplusplus/FindUsages.cpp
	tests/auto/cplusplus/findusages/tst_findusages.cpp
	tests/auto/debugger/tst_dumpers.cpp

Change-Id: I20e2002c7b25cc25d8120922fa9b52e59db498e3
parents 0d92b468 79c8a8fb
import qbs.base 1.0
import qbs.TextFile
import qbs.fileinfo as FileInfo
Module {
......
......@@ -1102,7 +1102,6 @@ class Dumper:
# Normal value
#numchild = 1 if value.MightHaveChildren() else 0
numchild = value.GetNumChildren()
self.put('iname="%s",' % self.currentIName)
self.putType(typeName)
if typeClass == lldb.eTypeClassStruct or typeClass == lldb.eTypeClassClass:
if self.isQObject(value):
......@@ -1129,7 +1128,7 @@ class Dumper:
if value.GetType().GetTypeClass() == lldb.eTypeClassArray:
for i in xrange(value.GetNumChildren()):
child = value.GetChildAtIndex(i)
with UnnamedSubItem(self, "%d" % (i + 1)):
with UnnamedSubItem(self, str(i)):
self.putItem(child)
return
......@@ -1156,7 +1155,7 @@ class Dumper:
frame = self.currentThread().GetSelectedFrame()
self.currentIName = 'local'
self.put('data=[')
self.anonNumber = -1
self.anonNumber = 0
for value in frame.GetVariables(True, True, False, False):
if self.dummyValue is None:
self.dummyValue = value
......
......@@ -2452,6 +2452,24 @@ def qdump__std__shared_ptr(d, value):
d.putIntItem("usecount", refcount["_M_use_count"])
d.putIntItem("weakcount", refcount["_M_weak_count"])
def qdump__std____1__shared_ptr(d, value):
i = value["__ptr_"]
if isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference().value, pointerValue(i)))
else:
d.putValue("@0x%x" % pointerValue(i))
d.putNumChild(3)
with Children(d, 3):
d.putSubItem("data", i.dereference())
d.putFields(value["__cntrl_"].dereference())
#d.putIntItem("usecount", refcount["_M_use_count"])
#d.putIntItem("weakcount", refcount["_M_weak_count"])
def qdump__std__unique_ptr(d, value):
i = value["_M_t"]["_M_head_impl"]
......@@ -2470,6 +2488,23 @@ def qdump__std__unique_ptr(d, value):
with Children(d, 1):
d.putSubItem("data", i)
def qdump__std____1__unique_ptr(d, value):
i = childAt(childAt(value["__ptr_"], 0), 0)
if isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if isSimpleType(d.templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference().value, pointerValue(i)))
else:
d.putValue("@0x%x" % pointerValue(i))
d.putNumChild(1)
with Children(d, 1):
d.putSubItem("data", i.dereference())
def qedit__std__vector(expr, value):
values = value.split(',')
......
import qbs
import qbs.TextFile
Product {
name: "app_version_header"
......
......@@ -233,7 +233,15 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
if (scopeOfTemplEnclosingCandidateSymbol != scopeOfTemplEnclosingDeclSymbol)
return false;
} else if (s->enclosingScope()->isTemplate() && ! _declSymbol->isTypenameArgument()) {
if (s->enclosingScope()->enclosingScope() != _declSymbol->enclosingScope())
if (_declSymbol->enclosingScope()->isTemplate()) {
if (s->enclosingScope()->enclosingScope() != _declSymbol->enclosingScope()->enclosingScope())
return false;
} else {
if (s->enclosingScope()->enclosingScope() != _declSymbol->enclosingScope())
return false;
}
} else if (_declSymbol->enclosingScope()->isTemplate() && s->isTemplate()) {
if (_declSymbol->enclosingScope()->enclosingScope() != s->enclosingScope())
return false;
} else if (! s->isUsingDeclaration()
&& s->enclosingScope() != _declSymbol->enclosingScope()) {
......
......@@ -485,7 +485,7 @@ void QbsProductNode::setQbsProductData(const qbs::ProductData prd)
if (m_qbsProductData == prd)
return;
bool productWasEnabled = m_qbsProductData.isEnabled();
bool productWasEnabled = m_qbsProductData.isValid() && m_qbsProductData.isEnabled();
bool productIsEnabled = prd.isEnabled();
bool updateExisting = productWasEnabled != productIsEnabled;
......
......@@ -39,7 +39,7 @@
namespace QbsProjectManager {
namespace Internal {
class QBSPROJECTMANAGER_EXPORT QbsParser : public ProjectExplorer::IOutputParser
class QbsParser : public ProjectExplorer::IOutputParser
{
Q_OBJECT
......
......@@ -52,7 +52,7 @@ class QbsProject;
class QbsProjectManagerPlugin;
} // namespace Internal
class QBSPROJECTMANAGER_EXPORT QbsManager : public ProjectExplorer::IProjectManager
class QbsManager : public ProjectExplorer::IProjectManager
{
Q_OBJECT
......
......@@ -196,7 +196,7 @@ QString QbsRunConfiguration::executable() const
QbsProject *pro = static_cast<QbsProject *>(target()->project());
const qbs::ProductData product = findProduct(pro->qbsProjectData(), m_qbsProduct);
if (product.isValid() || !pro->qbsProject())
if (!product.isValid() || !pro->qbsProject())
return QString();
return pro->qbsProject()->targetExecutable(product, installOptions());
......@@ -518,7 +518,7 @@ bool QbsRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, cons
return false;
QbsProject *project = static_cast<QbsProject *>(parent->project());
return !findProduct(project->qbsProjectData(), productFromId(id)).isValid();
return findProduct(project->qbsProjectData(), productFromId(id)).isValid();
}
ProjectExplorer::RunConfiguration *QbsRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id)
......
Subproject commit 604aa765a8389bfaf3c97465d4903f709c4e09cd
Subproject commit 6e432eef926e40278bca6c0281a6f36c56b099af
......@@ -104,6 +104,7 @@ private Q_SLOTS:
void using_insideGlobalNamespace();
void using_insideNamespace();
void using_insideFunction();
void templatedFunction_QTCREATORBUG9749();
};
void tst_FindUsages::inlineMethod()
......@@ -818,5 +819,35 @@ void tst_FindUsages::templateFunctionParameters()
QCOMPARE(findUsages.usages().size(), 4);
}
void tst_FindUsages::templatedFunction_QTCREATORBUG9749()
{
const QByteArray src = "\n"
"template <class IntType> char *reformatInteger(IntType value, int format) {}\n"
"void func(int code, int format) {\n"
" reformatInteger(code, format);"
"}\n"
;
Document::Ptr doc = Document::create("templatedFunction_QTCREATORBUG9749");
doc->setUtf8Source(src);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 2U);
Snapshot snapshot;
snapshot.insert(doc);
Template *funcTempl = doc->globalSymbolAt(0)->asTemplate();
QVERIFY(funcTempl);
QCOMPARE(funcTempl->memberCount(), 2U);
Function *func = funcTempl->memberAt(1)->asFunction();
FindUsages findUsages(src, doc, snapshot);
findUsages(func);
QCOMPARE(findUsages.usages().size(), 2);
}
QTEST_APPLESS_MAIN(tst_FindUsages)
#include "tst_findusages.moc"
......@@ -40,6 +40,7 @@
#include "temporarydir.h"
#include <QtTest>
#include <math.h>
#if QT_VERSION >= 0x050000
#define MSKIP_SINGLE(x) QSKIP(x)
......@@ -195,9 +196,10 @@ static QByteArray parentIName(const QByteArray &iname)
struct ValueBase
{
ValueBase() : hasPtrSuffix(false), version(0) {}
ValueBase() : hasPtrSuffix(false), isFloatValue(false), version(0) {}
bool hasPtrSuffix;
bool isFloatValue;
int version;
};
......@@ -235,6 +237,18 @@ struct Value : public ValueBase
if (hasPtrSuffix)
return actualValue.startsWith(expectedValue + QLatin1String(" @0x"))
|| actualValue.startsWith(expectedValue + QLatin1String("@0x"));
if (isFloatValue) {
double f1 = fabs(expectedValue.toDouble());
double f2 = fabs(actualValue.toDouble());
//qDebug() << "expected float: " << qPrintable(expectedValue) << f1;
//qDebug() << "actual float: " << qPrintable(actualValue) << f2;
if (f1 < f2)
std::swap(f1, f2);
return f1 - f2 <= 0.01 * f2;
}
return actualValue == expectedValue;
}
......@@ -247,6 +261,12 @@ struct Pointer : Value
Pointer(const QByteArray &value) : Value(value) { hasPtrSuffix = true; }
};
struct FloatValue : Value
{
FloatValue() { isFloatValue = true; }
FloatValue(const QByteArray &value) : Value(value) { isFloatValue = true; }
};
struct Value4 : Value
{
Value4(const QByteArray &value) : Value(value) { version = 4; }
......@@ -311,15 +331,6 @@ struct CheckType : public Check
{}
};
struct CheckPlain : public Check
{
CheckPlain(const QByteArray &iname, const Name &name,
const Type &type)
: Check(iname, name, noValue, type)
{}
};
struct Profile
{
Profile(const QByteArray &contents) : contents(contents) {}
......@@ -336,9 +347,9 @@ struct Cxx11Profile : public Profile
{}
};
struct MacLibStdCppProfile : public Profile
struct MacLibCppProfile : public Profile
{
MacLibStdCppProfile()
MacLibCppProfile()
: Profile("macx {\n"
"QMAKE_CXXFLAGS += -stdlib=libc++\n"
"LIBS += -stdlib=libc++\n"
......@@ -401,9 +412,13 @@ struct GuiProfile {};
struct DataBase
{
DataBase() : useQt(false), forceC(false), gdbOnly(false), lldbOnly(false) {}
DataBase()
: useQt(false), useQHash(false),
forceC(false), gdbOnly(false), lldbOnly(false)
{}
mutable bool useQt;
mutable bool useQHash;
mutable bool forceC;
mutable bool gdbOnly;
mutable bool lldbOnly;
......@@ -461,34 +476,33 @@ public:
{
profileExtra +=
"CONFIG += QT\n"
"QT += gui\n"
"greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets\n";
"QT += core\n";
useQt = true;
useQHash = true;
return *this;
}
const Data &operator%(const GuiProfile &) const
{
this->operator%(CoreProfile());
profileExtra +=
"CONFIG += QT\n"
"QT += gui\n"
"greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets\n";
useQt = true;
return *this;
}
const Data &operator%(const CorePrivateProfile &) const
{
this->operator%(CoreProfile());
profileExtra +=
"CONFIG += QT\n"
"greaterThan(QT_MAJOR_VERSION, 4) {\n"
" QT += core core-private\n"
" QT += core-private\n"
" CONFIG += no_private_qt_headers_warning\n"
"}";
useQt = true;
return *this;
}
......@@ -500,8 +514,8 @@ public:
public:
mutable QByteArray profileExtra;
QByteArray includes;
QByteArray code;
mutable QByteArray includes;
mutable QByteArray code;
mutable QMap<QByteArray, Check> checks; // IName -> Action
};
......@@ -586,7 +600,6 @@ void tst_Dumpers::initTestCase()
qDebug() << "QMake : " << m_qmakeBinary.constData();
Environment utilsEnv = Environment::systemEnvironment();
utilsEnv.appendOrSet(QLatin1String("QT_HASH_SEED"), QLatin1String("0"));
if (m_debuggerEngine == DumpTestGdbEngine) {
QProcess debugger;
......@@ -717,9 +730,20 @@ void tst_Dumpers::dumper()
"\n\nvoid unused(const void *first,...) { (void) first; }"
"\n\nvoid breakHere() {}"
"\n\n" + data.includes +
"\n\n" + (data.useQHash ?
"\n#include <QByteArray>"
"\n#if QT_VERSION >= 0x050000"
"\nQT_BEGIN_NAMESPACE"
"\nQ_CORE_EXPORT extern QBasicAtomicInt qt_qhash_seed; // from qhash.cpp"
"\nQT_END_NAMESPACE"
"\n#endif" : "") +
"\n\nint main(int argc, char *argv[])"
"\n{"
"\n int qtversion = " + (data.useQt ? "QT_VERSION" : "0") + ";\n"
"\n int qtversion = " + (data.useQt ? "QT_VERSION" : "0") + ";"
"\n" + (data.useQHash ?
"\n#if QT_VERSION >= 0x050000"
"\nqt_qhash_seed.testAndSetRelaxed(-1, 0);"
"\n#endif\n" : "") +
"\n unused(&argc, &argv, &qtversion);\n"
"\n" + data.code +
"\n breakHere();"
......@@ -1033,16 +1057,17 @@ void tst_Dumpers::dumper_data()
" } // namespace nsB\n"
" } // namespace nsA\n";
QTest::newRow("AnonymousStruct")
QTest::newRow("AnonymousStructGdb")
<< Data("union {\n"
" struct { int i; int b; };\n"
" struct { float f; };\n"
" double d;\n"
" } a = { { 42, 43 } };\n (void)a;")
% GdbOnly()
% CheckType("a", "a", "union {...}")
% Check("a.b", "43", "int")
% Check("a.d", "9.1245819032257467e-313", "double")
% Check("a.f", "5.88545355e-44", "float")
% Check("a.d", FloatValue("9.1245819032257467e-313"), "double")
% Check("a.f", FloatValue("5.88545355e-44"), "float")
% Check("a.i", "42", "int");
QTest::newRow("QByteArrayData")
......@@ -1052,6 +1077,20 @@ void tst_Dumpers::dumper_data()
% Check("ba", Value4(""), "@QByteArrayData")
% Check("ba", Value5(""), "@QByteArrayData");
// FIXME: Merge with GDB case
QTest::newRow("AnonymousStructLldb")
<< Data("union {\n"
" struct { int i; int b; };\n"
" struct { float f; };\n"
" double d;\n"
" } a = { { 42, 43 } };\n (void)a;")
//% CheckType("a", "a", "union {...}")
% LldbOnly()
% Check("a.#1.b", "43", "int")
% Check("a.d", FloatValue("9.1245819032257467e-313"), "double")
% Check("a.#2.f", FloatValue("5.88545355e-44"), "float")
% Check("a.#1.i", "42", "int");
QTest::newRow("QByteArray0")
<< Data("#include <QByteArray>\n",
"QByteArray ba;")
......@@ -2347,7 +2386,7 @@ void tst_Dumpers::dumper_data()
"unused(&a, &b);\n")
% CoreProfile()
% Cxx11Profile()
% MacLibStdCppProfile()
% MacLibCppProfile()
% Check("a", "<4 items>", "std::array<int, 4u>")
% Check("b", "<4 items>", "std::array<@QString, 4u>");
......@@ -2356,16 +2395,28 @@ void tst_Dumpers::dumper_data()
"std::complex<double> c(1, 2);\n")
% Check("c", "(1.000000, 2.000000)", "std::complex<double>");
QTest::newRow("CComplex")
QTest::newRow("CComplexGdb")
<< Data("#include <complex.h>\n",
"// Doesn't work when compiled as C++.\n"
"double complex a = 0;\n"
"double _Complex b = 0;\n"
"unused(&a, &b);\n")
% ForceC()
% GdbOnly()
% Check("a", "0 + 0 * I", "complex double")
% Check("b", "0 + 0 * I", "complex double");
QTest::newRow("CComplexLldb")
<< Data("#include <complex.h>\n",
"// Doesn't work when compiled as C++.\n"
"double complex a = 0;\n"
"double _Complex b = 0;\n"
"unused(&a, &b);\n")
% ForceC()
% LldbOnly()
% Check("a", "0 + 0i", "_Complex double")
% Check("b", "0 + 0i", "_Complex double");
QTest::newRow("StdDequeInt")
<< Data("#include <deque>\n",
"std::deque<int> deque;\n"
......@@ -2638,6 +2689,7 @@ void tst_Dumpers::dumper_data()
"std::unique_ptr<int> pi(new int(32));\n"
"std::unique_ptr<Foo> pf(new Foo);\n")
% Cxx11Profile()
% MacLibCppProfile()
% Check("pi", Pointer("32"), "std::unique_ptr<int, std::default_delete<int> >")
% Check("pf", Pointer(), "std::unique_ptr<Foo, std::default_delete<Foo> >");
......@@ -2646,6 +2698,7 @@ void tst_Dumpers::dumper_data()
"std::shared_ptr<int> pi(new int(32));\n"
"std::shared_ptr<Foo> pf(new Foo);\n")
% Cxx11Profile()
% MacLibCppProfile()
% Check("pi", Pointer("32"), "std::shared_ptr<int>")
% Check("pf", Pointer(), "std::shared_ptr<Foo>");
......
......@@ -642,10 +642,11 @@ def checkIfObjectExists(name, shouldExist = True, timeout = 3000, verboseOnFail
return result
# wait for progress bar(s) to appear and disappear
def progressBarWait(timeout=60000):
def progressBarWait(timeout=60000, warn=True):
if not checkIfObjectExists(":Qt Creator_Core::Internal::ProgressBar", True, 6000):
test.warning("progressBarWait() timed out when waiting for ProgressBar.",
"This may lead to unforeseen behavior. Consider increasing the timeout.")
if warn:
test.warning("progressBarWait() timed out when waiting for ProgressBar.",
"This may lead to unforeseen behavior. Consider increasing the timeout.")
checkIfObjectExists(":Qt Creator_Core::Internal::ProgressBar", False, timeout)
def readFile(filename):
......
......@@ -93,7 +93,7 @@ def main():
mouseClick(waitForObject(":Qt Creator.Help_Search for:_QLineEdit"))
replaceEditorContent(":Qt Creator.Help_Search for:_QLineEdit", searchKeyword)
type(waitForObject(":Qt Creator.Help_Search for:_QLineEdit"), "<Return>")
progressBarWait()
progressBarWait(warn=False)
if shouldFind:
test.verify(waitFor("re.match('[1-9]\d* - [1-9]\d* of [1-9]\d* Hits',"
"str(findObject(':Hits_QLabel').text))", 2000),
......@@ -129,7 +129,7 @@ def main():
# advanced search - do search
clickButton(waitForObject("{text='Search' type='QPushButton' unnamed='1' visible='1' "
"window=':Qt Creator_Core::Internal::MainWindow'}"))
progressBarWait()
progressBarWait(warn=False)
# verify that advanced search results found
test.verify(waitFor("re.search('1 - 2 of 2 Hits',"
"str(findObject(':Hits_QLabel').text))", 3000),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment