Commit Graph

1279 Commits

Author SHA1 Message Date
hjk
cc85cdf8d1 CPlusPlus: Use a namespace instead a dummy class for functions
Change-Id: Iaa364ef5fcd6f635fa07f0c43719b7b8feb1a428
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-11-18 13:07:58 +00:00
Nikolai Kosjar
54fefd89b8 C++: Transfer noexcept specifier for refactoring actions
This applies for e.g.

* "Add Definition..." (on function decl)
* "Move Definition..." (on function decl)
* "Insert Virtual Functions of Base Class" (on class specifier)

Fixes: QTCREATORBUG-11849
Fixes: QTCREATORBUG-19699
Change-Id: I0d259bc1782470f3b3f19617230005a5594a5cca
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-10-08 09:20:10 +00:00
hjk
2e14df7561 Some clang-tidy -use-modernize-nullptr
Change-Id: I1bed5e85a5b7948d08502a72a10f80baa075c204
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-08-01 13:20:26 +00:00
hjk
e3b1106afa Compile fix with recent Qt dev
The reasoning in 1b4766e26c did not take into account that the scope
of QT_NO_JAVA_STYLE_ITERATORS may change over time, as done with
f70905448f6 in Qt base.

Change-Id: Ib1966ff26c4d36d5f62e149d6b45baa4aecf825d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-29 08:54:18 +00:00
The Qt Project
9ebe05fd4e Merge "Merge remote-tracking branch 'origin/4.10'" 2019-07-26 09:34:33 +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
Eike Ziller
3ab3e68a7b Merge remote-tracking branch 'origin/4.10'
Change-Id: I427280fdb207b878000697dfd37595ffdb26f4e7
2019-07-26 10:30:03 +02:00
Cristian Adam
8ae9cfe39d CMake build: Add "Devel" package
The "Devel" package will contain headers, libraries, documentation
needed by the 3rd parties to build Qt Creator plugins.

Fixes: QTCREATORBUG-22514
Change-Id: If54929f823982b921b98a63ff6085d53618a3a49
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-25 14:06:46 +00:00
hjk
251287f0d3 Avoid warning on empty expressions
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.

Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 11:55:59 +00:00
Joel Smith
8c437362bc C++: Support single quote digit separator in integer literals
C++14 supports the use of single quotes inserted between integer digits
as a separator.  Updates the built-in C++ code model to recognize such
quotes.  This fixes highlighting and indentation issues.

Change-Id: Ic35ce93060b96700a11d108dce1f3cf6c4543632
Fixes: QTCREATORBUG-14939
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-09 08:59:23 +00:00
hjk
6a58666f44 More Utils::toSet/toList
... and unrelated cosmetic changes.

Change-Id: I591b17fd5289831e701b683f8fb47816efd1fa67
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-04 12:28:38 +00:00
hjk
2f7ca2ce44 CPlusPlus: Avoid a few deprecation warnings
The alternatives have been around since 2012.

Change-Id: I0aa15d59efe8a547e2ad622ffda689746960d48c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-06-05 05:43:34 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
Nikolai Kosjar
0bac3ad279 C++: Do not auto-insert '}' after control flow constructs
...as this rather gets in the way.

As before, pressing ENTER after { will still auto insert } on the next
line.

Fixes: QTCREATORBUG-18872
Change-Id: I8ee082962b5ee82781e51c3e5ee146343f808332
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2019-05-28 07:36:09 +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
Ivan Donchevskii
82d6d20acb Clang: Do not show completions after comma in initializer list
Appends 0852f889d1.

Do not automatically show global completion when initializer list
does not have a type, e.g. auto foo = {{},<cursor>};

Change-Id: I233fef71c60bb79211000df70bf5b04fa2d9df37
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 14:20:36 +00:00
Eike Ziller
eeaa02bc27 Merge remote-tracking branch 'origin/4.8' into 4.9
Conflicts:
	src/plugins/android/androidbuildapkstep.cpp

Change-Id: Id6dfda480c23706089ab38aa6277cd37599b5167
2019-02-28 12:39:09 +01:00
Nikolai Kosjar
25487daffd C++: Fix nullptr references in preprocessor
Fixes: QTCREATORBUG-21981
Change-Id: Iaded998eb793fb4284a9f8b22b2fa7a7443a1585
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-14 10:00:23 +00:00
Xiaofeng Wang
4dd4d088c5 C++: fix StarBindFlags behavior
Without Overview::BindToIdentifier, a space between
return type(endsWithPtrOrRef) and identifier should be added.

Change-Id: I3cd2d053bf137b35a58e7422f45cbd5b96eeb151
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-30 04:42:03 +00:00
Alessandro Portale
f5974ad993 Fix warning: "Don't call QVector::first() on temporary QList/QVector"
[-Wclazy-detaching-temporary]

Change-Id: I23f5cbd80bb92d3f9f1bfb5ae07493818958c5b0
Reviewed-by: hjk <hjk@qt.io>
2019-01-28 11:03:39 +00:00
Eike Ziller
413c5c3b8a Merge remote-tracking branch 'origin/4.8'
Change-Id: I400217ba1c8a531e0450c3012a07db3fc93638cf
2019-01-17 12:04:35 +01:00
Ivan Donchevskii
645bbf5dd6 CPlusPlus: Block function-like macro name for arguments expansion
Arguments of funstion-like macro may contain the name of this
macro. The attempt to expand it results into infinite recursion.

Patch solves that by saving the macro name until the arguments
are collected to determine that it should not be expanded.

Fixes: QTCREATORBUG-21642
Change-Id: Iafb404ecd3959a2f1011c12c1c3f1c0c54ed3547
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2019-01-17 08:52:40 +00:00
Alessandro Portale
7f641d3c08 Fix warning: "Mixing iterators with const_iterators"
[-Wclazy-strict-iterators]

Change-Id: Ibc7e07a0f8390297589656c3c2ddfdd4c0151887
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-16 17:15:19 +00:00
Ivan Donchevskii
4b852b4e04 CPlusPlus: Do not handle extremely long function-like macros
Qt Creator almost hangs and consumes a lot of memory if that happens.
Just ignore such cases in preprocessor.

Task-number: QTCREATORBUG-18995
Change-Id: Ib81cc18738696b02f98e5064d06c719a44ebdaa3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-13 13:25:55 +00:00
Ivan Donchevskii
8d0391a4f9 Clang: Treat brace initialization as constructor completion
Try to complete constructor after left brace with fallback
to normal completion.

Task-number: QTCREATORBUG-20957
Change-Id: I6c33790a3ee1e623a3d8abe9a44cfd821b6f3106
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-21 10:40:04 +00:00
David Schulz
141f19a652 Utils: move code model icons to utils
In preperation for the language server protocol support.

Change-Id: Iee4ccd53a86d9afdb357972ea62b75ace2edcb1d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-08-06 13:22:47 +00:00
Alessandro Portale
3d3f14e3fe Prefer using 'override' instead of 'virtual'
warning: prefer using 'override' or (rarely) 'final' instead of
'virtual' [modernize-use-override]

Change-Id: I6dac7a62b627fa1353b4455e1af92f869c2571cc
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-07-11 16:31:35 +00:00
Hugo Holgersson
86aab16ea4 TextEditor: Highlight punctuators as Text
This change limits the set of tokens that fall under
Token::isOperator(). That allows cpphighlighter.cpp to
distinguish operator tokens from punctuator tokens
(without changing any logic in cpphighlighter.cpp).

This change moves punctuators from "Operator"
to the "Text" style category where they belong.
Punctuators are not operators. Punctuators are
dumb text tokens.

Why don't we let the clang backend alone separate
these tokens for us?

1. Clang is slow on big files. Sometimes the
   highlighting dictated by clang is painted _seconds_
   after cpphighlighter.cpp runs. CppHighlighter is way
   faster so we use it to "prepaint" code while clang is
   busy in the background.

2. Secondly, clang cannot yet handle all operator types.
   In particular, none if its "operator cursors"
     CXCursor_UnaryOperator:
     CXCursor_BinaryOperator:
     CXCursor_CompoundAssignOperator:
     CXCursor_ConditionalOperator:
   includes the -> and . operators.
   We still need CppHighlighter to paint those tokens.

However, once clang has finished processing the file some
operator tokens will be repainted. We need clang to get
all operators' semantics. In particular, we need clang to
tell us if < is a "smaller than"-operator or part of a
template parameter like set<int>.

Task-number: QTCREATORBUG-19659
Change-Id: I952cb58f7c79134b3281e2a8221425cc1d0ad263
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-03 13:43:16 +00:00
Ivan Donchevskii
1d2b27081a C++: Fix unit-tests for MatchingText
BackwardScanner required more investigation and this is
the better fix than 413c66ec.

Change-Id: I651a7b416b549cc4a0e086873262d04409a7448e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-02-22 13:21:38 +00:00
Ivan Donchevskii
413c66ec88 C++: Fix crash on '{' press
Introduced by 0629400.
Sometimes typing '{' after class crashes QtC.

Task-number: QTCREATORBUG-19726
Change-Id: Idbbfaaa21837ec4afbe7debbd80ddaa484120f09
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-02-20 08:27:31 +00:00
Ivan Donchevskii
c6d4308ccd CPlusPlus: CppEditor: refactor overview model
Introduce abstract model to be able to use clang
based version of it in follow up patches.
Fix warnings and modernize source code a little.
Move OverviewModel to CppTools.

Change-Id: Idcc9bf03cad047026a456bd01063597a1eb95147
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-09 12:03:18 +00:00
Nikolai Kosjar
0629400288 C++: Do not auto-insert '}' after class/struct/enum/union
...when typing the opening brace. This restores the initial behavior
from version 4.3.

Not auto-inserting the closing brace allows the user to press Enter to
get "};" completed.

Change-Id: I8c62a08433a947e28f0555338a5fb8eeeae11bea
Task-number: QTCREATORBUG-18872
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-08 14:45:20 +00:00
Nikolai Kosjar
e48d8afedd C++: Check previous lines for auto insertion of closing brace
If '{' is typed, we check whether '}' should be auto-inserted.
Previously, we did this by only looking at the tokens of the current
line. By using the BackwardsScanner we can easily look also at the
previous lines, which fixes e.g.

  namespace N
  <CURSOR> // type '{' - no '}' should be inserted.

Change-Id: Ib2c2989c33f87464431d45facf986bcbb2eff2f8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-07 14:22:38 +00:00
Nikolai Kosjar
63e16d6346 C++: Limit number of nested class instantiations
...to avoid out of memory crashes.

Task-number: QTCREATORBUG-18649
Change-Id: I5e121bf4be0fd0c01a97a182ed07ee7552fb68ac
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-08-08 07:03:59 +00:00
Nikolai Kosjar
9092ef7992 C++: Do not insert matching } within string
Regression from

    commit a6aa287720
    C++: Fine-tune auto insertion of '}'

Change-Id: I3ede8c7a1e3c73708d5d5a59c314e4b4596976b2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-08-07 13:01:30 +00:00
Orgad Shaneh
e6fb1fea65 C++: Delete empty source file
Change-Id: Ib86e09d6d516b175e715725fa9b60d7ae2626ff8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-07-26 07:57:20 +00:00
Nikolai Kosjar
a6aa287720 C++: Fine-tune auto insertion of '}'
Do not insert for these cases:
 * <Cursor>{
 * namespace X <Cursor>
 * if the next block is indented, like e.g.:
     if (e) <Cursor>
        g();
 * on empty line if text before looks like a finished statement or
   scope opening/end

Change-Id: Id9decc1e964a775724a929c2a3e79b5283105560
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-07-21 11:42:46 +00:00
Nikolai Kosjar
be3e12c8af CppEditor: Avoid auto insertion of '}' in empty line
...when typing '{'.

Change-Id: Ia1d3bcd7440c96ed3c8c1479148dd74d3d291689
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-07-17 07:58:24 +00:00
Eike Ziller
345ea0307c Merge remote-tracking branch 'origin/4.3' into 4.4
Conflicts:
	qtcreator.qbs

Change-Id: Ic5e268326d93172208de291d31a716e437b9cedf
2017-07-10 09:54:52 +02:00
Nikolai Kosjar
f51d7a2314 C++: Fix crash for invalid code
...due to indirect recursion:

  ...
  CPlusPlus::ClassOrNamespace::lookupType        LookupContext.cpp 833  0x7fffd6c954cc
  CPlusPlus::ClassOrNamespace::nestedType        LookupContext.cpp 1364 0x7fffd6c94bc6
  CPlusPlus::ClassOrNamespace::lookupType_helper LookupContext.cpp 955  0x7fffd6c9517f
  CPlusPlus::ClassOrNamespace::lookupType_helper LookupContext.cpp 983  0x7fffd6c952ad
  CPlusPlus::ClassOrNamespace::lookupType        LookupContext.cpp 833  0x7fffd6c954cc
  CPlusPlus::ClassOrNamespace::nestedType        LookupContext.cpp 1364 0x7fffd6c94bc6
  CPlusPlus::ClassOrNamespace::lookupType_helper LookupContext.cpp 955  0x7fffd6c9517f
  CPlusPlus::ClassOrNamespace::lookupType_helper LookupContext.cpp 983  0x7fffd6c952ad
  CPlusPlus::ClassOrNamespace::lookupType        LookupContext.cpp 833  0x7fffd6c954cc
  ...

ClassOrNamespace::lookupType(const Name *) already guards with a list of
entries already processed, but some calls deeper the list is not passed
on and lookupType() starts again with an empty list. Handle that case,
too.

Task-number: QTCREATORBUG-18499
Change-Id: Iab8978f6ac1d0aea16f49b3547415f43de887b07
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-07-06 09:18:39 +00:00
Przemyslaw Gorszkowski
7bcf483189 C++: fix code completion of stl containers in internal code model
This fix makes some trick and replaces existing typedef of 'pointer'
to the simplest one(only in class unique_ptr), e.g.:
template <class _Tp>
class unique_ptr
{
  typedef some_strange_things pointer;
  pointer operator->();
}
is replace with
template <class _Tp>
class unique_ptr
{
  typedef _Tp* pointer;
  pointer operator->();
}

In most of the implementation of unique_ptr it should work.

Similar approach is done for std::list, std::vector, std::queue, std::set,
std::multiset, std::unordered_set.

It is done in this hacky way to omit problems with cyclic and complex
resolving of typedefs.

Change-Id: I1363dfc5e23d3cd2fa7af7fc27423bfbac2d894d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-15 17:18:20 +00:00
Alessandro Portale
a1d4b63f8d CPlusPlus: Add a property icon
Properties have been so useful in Qt for Years, and they will
continue being so. Properties deserve a proper icon.

Change-Id: Ifd19c97470a48a033bbe4017855f7b150befb365
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2017-06-13 09:53:28 +00:00
Nikolai Kosjar
461ffae871 C++: Fix uninitialized value warnings
...from coverity scan.

Change-Id: I44663354b3ee4854dd6335121a0160e35f14976c
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2017-06-01 13:33:34 +00:00
Nikolai Kosjar
986a518c17 C++: Handle curly braces like other brace types
Unless it balances the curly braces
 * typing '{' leads to auto insertion of '}'.
 * typing '}' skips already present '}'.
 * removing '{' leads to auto removal of '}'.

This prevents unbalanced curly braces, which are problematic for clang.
Concrete use cases are: typing of initializer lists, lambdas, function
definitions.

Task-number: QTCREATORBUG-15073
Change-Id: Iec8c6aa5aca054455c1e1bfde3a65c4fd1f579c3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-23 07:43:39 +00:00
Eike Ziller
64b19af7dd Merge remote-tracking branch 'origin/4.3'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri

Change-Id: I6d89ea588de955f5d878500b59285d3adde6c77d
2017-05-15 15:31:55 +02:00
Nikolai Kosjar
3c02b9b968 C++: Fix invalid read in isQtReservedWord()
The change

    CPlusPlus: Fix isQtReservedWord
    commit 7d76dd0079

enabled the problematic code path.

Change-Id: Ic89e3976b07ad55976c474f9c4b6d6f6cf64d29e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-05-12 13:18:46 +00:00
Orgad Shaneh
edbaea4f60 C++: Use Utils::FileName for Usage::path
Change-Id: I1d22333ad60d229202db5d372d00019b5870e60f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-04-27 08:34:59 +00:00
Orgad Shaneh
2f7384dd27 C++: Use direct member initialization in FindUsages
Change-Id: Ibe717dc587d817d53356771507b4aa3072554cb1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-04-27 08:34:51 +00:00
Orgad Shaneh
e1660a18cf Remove workarounds for unsupported compilers
Change-Id: Ie28ff761b0bae13c6ebdf7dd649cfbba28e0fc2c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-04-26 08:27:31 +00:00
Eike Ziller
dae2556d2f Merge remote-tracking branch 'origin/4.3'
Change-Id: I44511e06986b7df6007be7daf7051c895a10794b
2017-04-21 15:30:00 +02:00