summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
Commit message (Collapse)AuthorAgeFilesLines
* C++: Fix nullptr references in preprocessorNikolai Kosjar2019-02-141-6/+8
| | | | | | Fixes: QTCREATORBUG-21981 Change-Id: Iaded998eb793fb4284a9f8b22b2fa7a7443a1585 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* CPlusPlus: Block function-like macro name for arguments expansionIvan Donchevskii2019-01-172-11/+26
| | | | | | | | | | | | | | 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>
* CPlusPlus: Do not handle extremely long function-like macrosIvan Donchevskii2018-09-131-0/+4
| | | | | | | | | 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>
* Clang: Treat brace initialization as constructor completionIvan Donchevskii2018-08-211-1/+1
| | | | | | | | | 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>
* Utils: move code model icons to utilsDavid Schulz2018-08-0645-295/+28
| | | | | | | In preperation for the language server protocol support. Change-Id: Iee4ccd53a86d9afdb357972ea62b75ace2edcb1d Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Prefer using 'override' instead of 'virtual'Alessandro Portale2018-07-114-81/+81
| | | | | | | | warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override] Change-Id: I6dac7a62b627fa1353b4455e1af92f869c2571cc Reviewed-by: Marco Benelli <marco.benelli@qt.io>
* TextEditor: Highlight punctuators as TextHugo Holgersson2018-05-032-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* C++: Fix unit-tests for MatchingTextIvan Donchevskii2018-02-223-2/+8
| | | | | | | | BackwardScanner required more investigation and this is the better fix than 413c66ec. Change-Id: I651a7b416b549cc4a0e086873262d04409a7448e Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* C++: Fix crash on '{' pressIvan Donchevskii2018-02-201-1/+1
| | | | | | | | | | | 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>
* CPlusPlus: CppEditor: refactor overview modelIvan Donchevskii2018-02-094-360/+2
| | | | | | | | | | 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>
* C++: Do not auto-insert '}' after class/struct/enum/unionNikolai Kosjar2018-02-081-1/+48
| | | | | | | | | | | | ...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>
* C++: Check previous lines for auto insertion of closing braceNikolai Kosjar2018-02-071-65/+64
| | | | | | | | | | | | | 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>
* C++: Limit number of nested class instantiationsNikolai Kosjar2017-08-081-0/+2
| | | | | | | | | ...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>
* C++: Do not insert matching } within stringNikolai Kosjar2017-08-071-0/+5
| | | | | | | | | | | Regression from commit a6aa287720112c70c1363bcb46d55d438fe57eac 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>
* C++: Delete empty source fileOrgad Shaneh2017-07-261-1/+0
| | | | | Change-Id: Ib86e09d6d516b175e715725fa9b60d7ae2626ff8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* C++: Fine-tune auto insertion of '}'Nikolai Kosjar2017-07-212-22/+211
| | | | | | | | | | | | | | 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>
* CppEditor: Avoid auto insertion of '}' in empty lineNikolai Kosjar2017-07-171-1/+5
| | | | | | | ...when typing '{'. Change-Id: Ia1d3bcd7440c96ed3c8c1479148dd74d3d291689 Reviewed-by: David Schulz <david.schulz@qt.io>
* Merge remote-tracking branch 'origin/4.3' into 4.4Eike Ziller2017-07-102-9/+14
|\ | | | | | | | | | | | | Conflicts: qtcreator.qbs Change-Id: Ic5e268326d93172208de291d31a716e437b9cedf
| * C++: Fix crash for invalid codeNikolai Kosjar2017-07-062-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...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>
* | C++: fix code completion of stl containers in internal code modelPrzemyslaw Gorszkowski2017-06-151-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | CPlusPlus: Add a property iconAlessandro Portale2017-06-137-0/+17
| | | | | | | | | | | | | | | | | | 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>
* | C++: Fix uninitialized value warningsNikolai Kosjar2017-06-011-1/+1
| | | | | | | | | | | | | | ...from coverity scan. Change-Id: I44663354b3ee4854dd6335121a0160e35f14976c Reviewed-by: Robert Loehning <robert.loehning@qt.io>
* | C++: Handle curly braces like other brace typesNikolai Kosjar2017-05-231-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge remote-tracking branch 'origin/4.3'Eike Ziller2017-05-151-1/+1
|\ \ | |/ | | | | | | | | | | | | Conflicts: qbs/modules/qtc/qtc.qbs qtcreator.pri Change-Id: I6d89ea588de955f5d878500b59285d3adde6c77d
| * C++: Fix invalid read in isQtReservedWord()Nikolai Kosjar2017-05-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The change CPlusPlus: Fix isQtReservedWord commit 7d76dd007954ee48182beb2adf17dab5df5fbea8 enabled the problematic code path. Change-Id: Ic89e3976b07ad55976c474f9c4b6d6f6cf64d29e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* | C++: Use Utils::FileName for Usage::pathOrgad Shaneh2017-04-272-3/+4
| | | | | | | | | | Change-Id: I1d22333ad60d229202db5d372d00019b5870e60f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | C++: Use direct member initialization in FindUsagesOrgad Shaneh2017-04-272-17/+9
| | | | | | | | | | Change-Id: Ibe717dc587d817d53356771507b4aa3072554cb1 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Remove workarounds for unsupported compilersOrgad Shaneh2017-04-261-6/+0
| | | | | | | | | | Change-Id: Ie28ff761b0bae13c6ebdf7dd649cfbba28e0fc2c Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Merge remote-tracking branch 'origin/4.3'Eike Ziller2017-04-213-8/+9
|\ \ | |/ | | | | Change-Id: I44511e06986b7df6007be7daf7051c895a10794b
| * Use qEnvironmentVariableIsEmpty or qEnvironmentVariableIsSet directlyMontel Laurent2017-04-192-2/+2
| | | | | | | | | | | | | | | | Change-Id: I4f2e61e4bade9e7b4518d144db8163e596ab6264 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
| * C++: Use Utils::transform() in BackwardsScannerOrgad Shaneh2017-04-191-6/+7
| | | | | | | | | | | | Change-Id: Iec2c2db7afd8e5fe463a32c6b5167592cdd7617c Reviewed-by: Laurent Montel <laurent.montel@kdab.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Use const'ref in theses methodsMontel Laurent2017-04-211-1/+1
|/ | | | | Change-Id: Idfa5ffdcf23d1ef80442276690b8082b8279dbfa Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Reserve some elementsMontel Laurent2017-04-141-0/+1
| | | | | Change-Id: Iceef4e9a6f213a747045db3b06a5608d77652f98 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* C++: De-slotOrgad Shaneh2017-03-201-2/+1
| | | | | Change-Id: If4562fff4271dd8be3ec2b3394fdcbe5a9cb4e50 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Merge remote-tracking branch 'origin/4.2'Eike Ziller2017-02-271-2/+37
|\ | | | | | | Change-Id: I9006dd493707ae626ae3502541599c8789e1aab0
| * C++: Avoid inline namespaces in generated codeNikolai Kosjar2017-02-231-2/+37
| | | | | | | | | | | | | | Task-number: QTCREATORBUG-16086 Change-Id: Ic2f3fd38ae6cc93725bc214c24320f40a0a519a8 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* | Remove spaces in initializer listsTim Jenssen2017-02-222-2/+2
| | | | | | | | | | | | | | Format initializer lists code style like. Change-Id: Ib82c235e4ba7dc75ee96a7abc0c47eff7b0a9013 Reviewed-by: hjk <hjk@qt.io>
* | C++: Do not add double quotes when splitting raw string litteralsDavid Schulz2017-02-222-5/+7
| | | | | | | | | | | | Task-number: QTCREATORBUG-17717 Change-Id: Iffb34a3d77ada624dc13b8ab050ac08731d25863 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | Fix exports for shared librariesMarco Bubke2017-01-161-1/+1
| | | | | | | | | | | | | | | | We use "shared" to define a shared library and not dll. Change-Id: Ia97ebd0042a7ef0f33eadaa448d9a44b42331ad1 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Merge remote-tracking branch 'origin/4.2'Eike Ziller2017-01-113-6/+54
|\ \ | |/ | | | | | | | | | | | | Conflicts: src/plugins/android/androidbuildapkstep.cpp src/plugins/genericprojectmanager/genericproject.cpp Change-Id: I3484b668f9323ed0c05de99f8dfed07c9e65ab98
| * C++: Fix use-after-free crash when handling auto expressionsNikolai Kosjar2017-01-093-6/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | The Control of the Document "exprDoc" in ResolveExpression::visit( SimpleNameAST*ast) owns names that are passed on further as part of the LookupItems. However, the life time of that Document and thus the Control ends in that function. Fix by using the appropriate Control object. Task-number: QTCREATORBUG-16731 Change-Id: I5a7af0a67613fff79f7e07865801585c13bb9b45 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* | C++: Fix handling of Objective-C/C++Francois Ferrand2016-12-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | - Objective C/C++ was not enabled in highlighter. - QMake project part for Objective C/C++ did not have ObjectiveC extension enabled. - As languageFeatures.objCEnabled is a bitfield, it was actually always set to 0. - Highlight ObjC class & protocol declarations. - Highlight ObjC message passing. Change-Id: I64d12c9509058d05f7adce94598cb7ce91727ac8 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* | CPlusPlus: Fix isQtReservedWordTobias Hunger2016-11-301-1/+1
|/ | | | | | | checking for size >= 4 masks Q_D and Q_Q. Change-Id: If9ab7d3b2c2c571e73b98e89908e492fc6241296 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* C++: Remove concurrent access to TemplateNameIdNikolai Kosjar2016-11-041-7/+8
| | | | | | | | | | | | | | | | | | | The modification of the TemplateNameId changed "global state" because the TemplateNameId is potentially accessed by multiple threads doing lookup (access to same document and thus same symbol names). Depending on the thread scheduling and access to ClassOrNamespace::_specializations, the changed TemplateNameId "suddenly" led to inconsistent results of TemplateNameId::Compare and thus broke the std::map assertions. Get rid of the const_cast, the setter and simply construct a temporary TemplateNameId with isSpecializaton = true. Task-number: QTCREATORBUG-14911 Change-Id: Ie381d132cc0d06af351ace4257773637d1ebee4e Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
* CPlusPlus, Utils: Move namespace icon from CPlusPlus to UtilsAlessandro Portale2016-10-264-3/+1
| | | | | | | ...so that it can be used in the ScxmlEditor plugin Change-Id: I0e0ed050f7765bcc901db3bb2c3273456a228b5e Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* C++: Enable showEnclosingTemplate also for function typeOrgad Shaneh2016-09-061-17/+21
| | | | | | | Do not require directly passing the enclosing template. Change-Id: Ie03bc58338fe003677a5f5311d86d70f499373ee Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* C++: Disable C++ keywords in C filesFrancois Ferrand2016-08-231-0/+1
| | | | | | | | | | | | In some (legacy) C files, new and delete may be used for regular identifier. There are some limitations: * Header files have no 'implicit' type, and may be parsed as C++ or ObjC depending on the other files in the project. * QMakeProject use a single ProjectPart for C and C++ files, so there will still be the issue. Change-Id: Iec11687b35f7ccf1e7c0d091b143ae90d950e440 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* C++: Support pretty printing of template enclosing scopeOrgad Shaneh2016-08-193-2/+22
| | | | | Change-Id: Ib228184e1259585eeac61b9196195c39a9550cb9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* CppTools: Cancel parsing if editor is closedNikolai Kosjar2016-07-292-0/+14
| | | | | | | | | | | | The m_parserFuture.cancel() in ~BuiltinEditorDocumentProcessor() did not cancel anything. Thus, closing a document while the parser was running led to a blocking UI thread. Now it cancels at the next include directive it encounters. Change-Id: I092fddbbd747e0bc95265b6e9b4fcc26b3f76cb3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
* C++: Add support of ref-qualifier for functions.Dmitry Ashkadov2016-06-222-0/+12
| | | | | | | | | | Now the ref-qualifier (& or &&) of the function declaration is propagated to GUI. For example, 'Refactor' -> 'Add Definition' preserves the ref-qualifier. Change-Id: I8ac4e1cad4e44985e94230aabbd9858a7e929fee Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>