Commit Graph

73 Commits

Author SHA1 Message Date
Christian Kandeler
a995a4633f CPlusPlus: Do not mis-classify bitfield declarations as initializations
Fixes: QTCREATORBUG-25390
Change-Id: I1976b7db2996f5a09db73adbd127aac9ab92d57d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-25 15:55:54 +00:00
Eike Ziller
1e78fdb71f Merge remote-tracking branch 'origin/4.14'
Change-Id: Id4c4c06b086dfe38960f4d68694ae23f3e00109f
2020-12-03 11:57:42 +01:00
Christian Kandeler
ff2322ac0b CPlusPlus: Fix mis-classification of pure virtuals
Syntactically, they do have an initializer, but they are not
initializations.

Change-Id: I0556b279ce2d173868585cbce085b803c1cff285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-12-03 09:09:52 +00:00
Christian Kandeler
59f8bd4702 CPlusPlus: Expose "static" specifier also for function declarations
To be able to do this, the parser needs to store the decl specifier list
in FunctionDeclaratorAST objects, the same way it is done for
FunctionDefinitionAST.

Task-number: QTCREATORBUG-24894
Change-Id: I475fb08b1f14c63f3050d72dff200c1b08df5789
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-11 15:41:27 +00:00
Christian Kandeler
e41f3eb607 CPlusPlus: Fix "find usages" categorization for sizeof and array access
Task-number: QTCREATORBUG-24894
Change-Id: I65fa097785b19e181f15178ad6d30608899316c0
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-09 12:50:07 +00:00
Christian Kandeler
42d34015e2 CPlusPlus: Provide information about the "static" specifier
... to the function type.
This fixes the issue for function *definitions*. For function
*declarations*, we need to amend the parser.

Task-number: QTCREATORBUG-24894
Change-Id: I02043d8b974c2c64dcd739c7e05ce44fd277b5d3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-09 10:55:38 +00:00
Christian Kandeler
1988d89198 CPlusPlus: Check for static member functions in FindUsages
Static member functions cannot modify the object and therefore must not
be reported as writable references.
Note that this does not have an effect yet, as the function type lacks
information about the "static" specifier.

Task-number: QTCREATORBUG-24894
Change-Id: Ib04a17864a0ca5b7610579a2f5efbcfde257e08a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-09 09:51:08 +00:00
Christian Kandeler
de1e12f3af CPlusPlus: Correctly categorize post-increment and -decrement accesses
Change-Id: Id21c13ea58f6747c226d91aff2b00c3409faa880
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-04 13:24:33 +00:00
Christian Kandeler
a88266798f CPlusPlus: Differentiate declarations with an initializer
... from those without one, and display the former like write accesses.

Task-number: QTCREATORBUG-24894
Change-Id: I5e2d83b2a3ec4735054441c346687f97eeb039fb
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-04 13:02:52 +00:00
Christian Kandeler
cf6757406d CPlusPlus: Properly categorize usages in if statements
Change-Id: I5f6e5fa14ea51cd9e61a9e2e96c110ca618be429
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-11-04 13:02:34 +00:00
Christian Kandeler
89644e4a06 CPlusPlus: Properly categorize usages in switch and case statements
Change-Id: Iafbbdcca23db38d82bbc5bb24a39dac2a6d0a764
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-02 16:03:28 +00:00
Eike Ziller
d54f7b0eb2 Fix building tests with Qt6
Task-number: QTCREATORBUG-24098
Change-Id: I192245125f04f8350597bbe481d80d3f8ba0cae0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-30 15:15:25 +00:00
Christian Kandeler
b58ca33ff6 CppTools: Categorize the delete operator as a write access
... in the "Find Usages" results.

Change-Id: Ib399bf762c717b7d4439be26b9180574aefce7e3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-21 09:12:33 +00:00
Christian Kandeler
f244a7ea4c CPlusPlus: Consider member initializations
... when checking usage types.

Change-Id: Ic875f3bcae9cf045dbb062670e8cf941de533404
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-18 11:01:47 +00:00
Christian Kandeler
ee8e102cbc CPlusPlus: Look at all overloads
... when trying to find out the usage type of a function argument.
Otherwise, we potentially ignore functions which have additional
overloads with a shorter parameter list than is required for the call.

Change-Id: I02bf2cb359ea9d506e2644388234dc28fa072445
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-15 09:23:48 +00:00
Christian Kandeler
45dd074441 CPlusPlus: Categorize "Find Usages" results
That is, find out whether a certain access was a read, a write, a
declaration or something else, and report the result to upper layers.
Follow-up patches can make this information visible to users.

Task-number: QTCREATORBUG-12734
Task-number: QTCREATORBUG-19373
Change-Id: Iee79e39dd1eb5a986a7e27846991e0e01b2c3a2f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-03 14:32:47 +00:00
Volodymyr Zibarov
40173ad4ab C++: Fix auto variable resolving for template class constructor call
Code snippet:
template<class T> struct MyStruct { int value; };
int main() {
    auto s = MyStruct<int>();
    s.value;  // "value" is not found
}

This fixes find usages for unique_ptr declared as auto like this:
auto ptr = std::unique_ptr<MyStruct>(new MyStruct());
ptr->value;

Also fixes in-place constructors:
std::unique_ptr<MyStruct>(new MyStruct())->value;

Fixes: QTCREATORBUG-15364
Change-Id: I8d452a77fe85e63665ec8d4c4afbcf8aad063121
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-22 14:27:49 +00:00
Volodymyr Zibarov
9be4a5f839 C++: Fix Find Usages false positive results for function arguments
Code snippet:
void bar();         // call find usages for bar from here
void foo(int bar);  // bar from here should not be in results

Add test for member function false positives, that is part of
QTCREATORBUG-2176. That was already fixed before.

Fixes: QTCREATORBUG-2176
Change-Id: I9a079caa83bbaea1edb7ba6aeb151d4d4c77952f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-15 13:19:51 +00:00
Volodymyr Zibarov
7d82741602 C++: Fix find usage to see Catch test functions bodies
Catch test functions defined with function-like macros.
To speed-up semantic analysis, find usages does not expand function-like
macros.
Semantic fails with "expected a function declarator" on such functions
and skips function body.
To avoid that, we create dummy function type specifically for this case

Change-Id: Ie2f2464ee57aa4dc86eed07b8b699458f95c0266
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-15 10:16:06 +00:00
Volodymyr Zibarov
3ad203b56e C++: Fix variable template parsing in expression
Fix parser to not fail on TemplateId without parentheses, for example:
int i = foo<int> + foo<char>;

This fixes std::pair structure parsing in MSVC headers and find Usages
to work with pair->first and pair->second.

Change-Id: Ic300ea99d44a749705430d5eb47b2744715af995
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-06-04 08:18:40 +00:00
Volodymyr Zibarov
9ee693ee22 C++: fix built-in code model to work with shared_ptr on MSVC 2017
These changes target Find Usages feature to work with shared_ptr.
Improve libs/3rdparty/cplusplus and plugins/cplusplus:
parse __declspec() attribute,
call to variadic function template without specified template arguments,
if constexpr,
c++11 attributes [[value]],
function templates with default parameters,
resolve order for function vs template with default parameter,
template operator->() with default arguments,
template specialization with numeric values,
find best partial specialization,
fix partial specialization for non-first specialized argument

Fixes: QTCREATORBUG-7866
Fixes: QTCREATORBUG-20781
Fixes: QTCREATORBUG-22857
Fixes: QTCREATORBUG-17825
Change-Id: I31a080f7729edfb2ee9650f1aff48daeba5a673b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Nikolai Kosjar <pinaceae.pinus@gmail.com>
2020-05-29 12:39:28 +00:00
hjk
7ab6783e24 Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-26 09:23:48 +00:00
Cristian Adam
d855b84c5d Qt Creator CMake port
Based on Tobias Hunger's work from a few months ago.

The CMake configuration needs libclang and Qt paths specified as
CMAKE_PREFIX_PATH.

Auto tests are run with "ctest". At the moment the pass rate is 87%.

Change-Id: Iba98e39bf22077d52706dce6c85986be67a6eab0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-17 13:33:28 +00:00
Tobias Hunger
954569387c Update License according to agreement with Free Qt Foundation
* Update license information in tests directory

Change-Id: I311441dd37d053ca3175e44b284258e232ee93e0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 16:01:06 +00:00
kai666_73
b30b69bbf3 C++: Find template member access in find usages
Example:
struct Foo {};
struct Bar {
  template <typename T>
  T *templateFunc() { return 0; }
};
struct Test {
  Bar member;
  void testFunc();
};
void Test::testFunc() {
  member.templateFunc<Foo>();   // "templateFunc" and "Foo" outside of FindUsages
}

Change-Id: I0c5109d00c67054fe15b3fb98cf8cbca69123d8b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-04-22 13:17:15 +00:00
Eike Ziller
3c85058694 Update License
Change-Id: I711d5fb475ef814a1dc9d2822740e827f3f67125
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2015-01-16 12:37:56 +01:00
Eike Ziller
8295b503be License update
Change-Id: I3c22ef2685d7aa589f5d0ab74d693653a4c32082
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2014-10-09 11:41:44 +02:00
Erik Verbruggen
45b1169d06 C++: Support alignas in C++11 mode.
Change-Id: Ifa81a481bf92b5b71495a105ae292f3e9895f704
Task-number: QTCREATORBUG-9279
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-07-22 16:43:51 +02:00
Nikolai Kosjar
655470cc0c C++: Tests: Fix unicode tests with MSVC
Change-Id: I5575826558bf60982ecc964e4dd85a3f4e920197
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
2014-06-05 08:14:57 +02:00
Nikolai Kosjar
bea8fc8e6a Cpp{Tools,Editor}: Expect UTF-8 encoded literals
Change-Id: I9843c4163aad3fa3f1bfa33060c76328fc2dc25a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:24:23 +02:00
Przemyslaw Gorszkowski
5416557a0b C++: fix findusage for member of typedefed anonymous struct
Task-number: QTCREATORBUG-11859
Task-number: QTCREATORBUG-11860
Change-Id: I7484b3b88daefbb3c76bb86a9b573e8291072872
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-31 18:16:52 +02:00
Robert Loehning
746c5d8863 Incremented year in copyright info
Change-Id: Ib5423fdd064e4546f848c0b640b0ed0514c26d3a
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2014-01-08 08:29:47 +01:00
Christian Kandeler
698144e32e Add qbs project files for autotests.
Note: Since not all autotests are able to run from an installed location,
we need to be able to start them from the build directory, which
in turn forces us to set a destination directory for libraries and plugins,
so they will be found at run-time.

Change-Id: Idcf7e1333dfa6e9dbf745391b78c035f842ccc5a
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
2013-09-09 12:16:09 +02:00
Przemyslaw Gorszkowski
3256b7b2ef C++: fix matching type with using from other namespace
example code:
struct S { int s; };

namespace std
{
    template <typename T>
    struct shared_ptr
    {
        T* operator->();
    };
}

namespace NS
{
    using std::shared_ptr;
}

int main()
{
    NS::shared_ptr<S> p;// for this shared_ptr
    return 0;
}

Fixes:
* find usages
* follow symbol
* highlighting
* marking

Task-number: QTCREATORBUG-7978
Change-Id: I28994c960b87ddd400e1d7b860fca6c6683bbb5a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-08-20 14:13:19 +02:00
Erik Verbruggen
fa1647d880 C++: add utility method to dump usages.
Change-Id: Icff6e9310a45e66b573fb2a6623a10e025c43539
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-07-11 14:09:03 +02:00
Erik Verbruggen
3563b4167f C++: Fix test failure after merging 2.8.
Change-Id: Iac4156b872fe81c1714857c24363bf171e7d61cd
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-07-11 13:58:16 +02:00
Eike Ziller
79fbb0db04 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
2013-07-09 11:04:59 +02:00
Erik Verbruggen
d70a33c0d0 C++: fix scope matching for templates in FindUsages
When the cursor is on the name of declaration of a templated function,
then since f93758b8e1 the scope returned
by Document::findScopeAt is the scope of the template declaration.
Before it was the parent scope of the template declaration.

The check in FindUsages::checkCandidates did not check all combinations
of template(-child symbol) scopes for the searched symbol and its
occurrences.

Task-number: QTCREATORBUG-9749

Change-Id: Idc84a2ba718721ce54683a67635a93352784ddd1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-07-08 15:05:10 +02:00
Przemyslaw Gorszkowski
94dd4e740a C++: fix 'find usages' for templates
Fix find usages for template class(class name and template parameters)
or template function(template parameters).

Fixed:
* marking
* find usages
* follow symbol

Change-Id: I22fdbc11260cbd8ee9aafdd76aaeee0f4f49f9fd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-06-17 11:04:47 +02:00
Przemyslaw Gorszkowski
d14767a6af C++: fix highlighting type when there is using Namespace::Class
If type is not found we try to find 'using' declaration for this type.

Task-number: QTCREATORBUG-7903

Change-Id: I569db9e1a8504a5da3115ebbed2e823d5924f6ca
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-05-02 15:17:27 +02:00
Przemyslaw Gorszkowski
080bf4ecb8 C++: improve support for anonymous classes
Fix:
* highlighting
* find usages
* follow symbol
* code completion

Task-number: QTCREATORBUG-6497
Task-number: QTCREATORBUG-8963
Task-number: QTCREATORBUG-3610
Task-number: QTCREATORBUG-7579

Change-Id: I3dcaf1c515d0199c3e6bee72284fbb40064686ee
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-19 12:14:56 +02:00
Eike Ziller
9ff8979da3 Merge remote-tracking branch 'origin/2.7'
Conflicts:
	src/plugins/cpptools/cppchecksymbols.h
	src/plugins/qmldesigner/components/formeditor/resizecontroller.cpp

Change-Id: I887ba071fa637ad44e39bcae581738fa078a6612
2013-04-11 18:27:52 +02:00
Przemyslaw Gorszkowski
9c2a352027 C++: fixed operator arrow of nested class of enclosing template
Fixed:
* code completion
* highlighting
* find usage
* follow symbol

Task-number: QTCREATORBUG-9005
Change-Id: I3fcc2638482ca1071c1aa7b6aab0d4dd128595bb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-10 14:52:20 +02:00
Przemyslaw Gorszkowski
7c74482ad3 C++: fixed operator* for nested class of enclosing template class
Fixed:
* highlighting
* follow symbol
* find usage

Task-number: QTCREATORBUG-9006

Change-Id: I34a42f8665335857f41290217e7265e8a752455b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Sergey Shambir <sergey.shambir.auto@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-09 11:23:14 +02:00
Oswald Buddenhagen
7923032022 fix include style relating to cplusplus libraries
... and adjust INCLUDEPATH accordingly.

while i'm at messing with include statements, also re-order the include
blocks according to policy and sort them within bigger blocks.

Change-Id: I7762abfd7c4ecf59432b99db2f424e4fa25733a5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-04-03 13:40:39 +02:00
Oswald Buddenhagen
001a26a4bb include qttest.pri centrally
Change-Id: I05e85dac15e7de52ad04bde899dcc3cb8e603d3e
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-04-02 17:11:37 +02:00
Oswald Buddenhagen
1fda2111d4 Merge remote-tracking branch 'origin/2.6'
Conflicts:
	src/plugins/autotoolsprojectmanager/AutotoolsProjectManager.pluginspec.in
	src/plugins/debugger/qtmessageloghandler.cpp
	src/plugins/debugger/qtmessagelogwindow.cpp
	src/plugins/madde/maemodeployconfigurationwidget.cpp
	src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
	src/plugins/qmldesigner/designercore/include/widgetqueryview.h
	src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp
	src/plugins/qmldesigner/designercore/model/modelnodecontextmenu.cpp
	src/plugins/qmldesigner/designercore/model/modelnodecontextmenu.h
	src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp
	src/plugins/qnx/bardescriptormagicmatcher.h
	src/plugins/qt4projectmanager/profilekeywords.cpp
	src/plugins/remotelinux/deployablefilesperprofile.cpp
	src/plugins/remotelinux/deployablefilesperprofile.h
	src/plugins/remotelinux/deploymentinfo.cpp
	src/plugins/remotelinux/deploymentsettingsassistant.cpp
	src/plugins/remotelinux/profilesupdatedialog.cpp
	tests/auto/icheckbuild/ichecklib.cpp
	tests/auto/icheckbuild/parsemanager.cpp
	tests/auto/icheckbuild/parsemanager.h

Change-Id: Ie465a578446a089e1c502d1cb1096e84ca058104
2013-01-31 16:25:33 +01:00
Robert Loehning
298531e370 Incremented year in copyright info
Change-Id: Ic6a9ff0359625021ebc061d22db6811814534205
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2013-01-29 16:27:03 +01:00
Przemyslaw Gorszkowski
7fcc52bf47 C++ editor: Highlighting static variables
Fix highlighting, find usages, marking for static variables.

Task-number: QTCREATORBUG-6822
Change-Id: I0c97c93c6c1024550907eec3820496df22a94e85
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-01-29 14:01:11 +01:00
Przemyslaw Gorszkowski
23844410fd C++ editor: support nested class of enclosing template
Fixing:
* highlighting
* tooltips
* find usage
* selecting

Task-number: QTCREATORBUG-8245
Change-Id: I6e900799e43126706125b7e424567fca2b2c223e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-01-22 11:35:25 +01:00