Commit Graph

80 Commits

Author SHA1 Message Date
Nikolai Kosjar
c2803b00be CppTools: Avoid self-include
...in CPlusPlus::Document due to cyclic includes.

Task-number: QTCREATORBUG-11457
Change-Id: I1ca19c901c26d9984d795a61879dd6b41c57096c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-02-24 14:08:11 +01:00
Orgad Shaneh
7febebc294 C++: Fix indentation in preprocessor tests
Easier to compare when indentation is aligned

Change-Id: I216073dc167c0ed785616ae308b566db7f910592
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-02-04 11:34:03 +01:00
Orgad Shaneh
06592b28ad C++: Consolidate with/without comments preprocessor tests
Change-Id: Ib08569d642da51f6d51bb0763fc95d5a5c13d28c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 16:27:49 +01:00
Orgad Shaneh
0a817c4ef5 C++: Cleanup preprocessor tests
Change-Id: Ia1b7dee24a3d7e20440dca5040cf9ffdaaf066e2
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 16:27:34 +01: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
Nikolai Kosjar
796fcaf1d2 Revert "C++: Fix highlighting for lines with predefined macros"
This takes too much memory. For qtcreator.pro the numbers are as
follows:

    Patch applied:  ~ 1600MB (RES)
    Patch reverted: ~  510MB (RES)

This reverts commit 4c2daa90ce.

Task-number: QTCREATORBUG-10973
Change-Id: I843bd7c1ea4a26a1ec55ddc14c2a34a98d040922
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-03 09:53:26 +01:00
Nikolai Kosjar
4c2daa90ce C++: Fix highlighting for lines with predefined macros
This adds definitions for the macros __FILE__, __LINE__, __DATE__ and
__TIME__ on demand.

As a side effect, this also introduces highlighting for the uses of
these macros.

Task-number: QTCREATORBUG-8036
Change-Id: Ib7546c7d45d2eecbc50c7883fc684e3497154405
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-11-29 15:11:27 +01:00
Nikolai Kosjar
4edfe87b58 Revert "Preprocessor Enginge: fix bug in pp-engine.cpp"
Breaks highlighting for macros using the predefined macros.

This reverts commit 1d834c1126.

Change-Id: Ic13c407e293a806a63ff30153864530df6a32e47
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-29 15:11:10 +01:00
Simon Schäfer
1d834c1126 Preprocessor Enginge: fix bug in pp-engine.cpp
Preprocessor variables __LINE__,__FILE__,__TIME__,__DATE__ where destroying
the following systems when affected variables were standing  within the
same line with those variables:
* highlighting
* refactoring
* local renaming

Task-number: QTCREATORBUG-8036
Change-Id: I1a4b919d15812872ca5a8e63b1031ec1ab144c22
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-28 11:40:37 +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
Christian Kandeler
eecacbfbfe CPlusPlus: Some compile fixes for autotests.
Change-Id: Id2ced5e41686387e67a7bb8419fe1547b23779c7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-08-26 17:45:54 +02:00
Nikolai Kosjar
8180f695f1 CppEditor: Check <include path>/QSomething
For the quick fix AddIncludeForUndefinedIdentifier, if no class is found
via the locator, check the "Qt include paths" for a header file with the
same name as the class name.

Task-number: QTCREATORBUG-9538
Change-Id: I13c86844c2ff653fa479dc91eb109af2a6d76fae
Reviewed-by: Lorenz Haas <lykurg@gmail.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-06-17 08:16:43 +02:00
Erik Verbruggen
271c3f45a4 C++: Fix preprocessor blocked macro bug.
By lexing the first token after a macro call (meaning: the token after
the closing parenthesis (which was passed to handleFunctionLikeMacro
which in turn pushed it back into the token buffer)), a token buffer
might be popped, which unblocks the macro that generated the actual
param pack. The effect was that if this happens in the expansion of a
recursive macro (with parameters!), the preprocessor ended up in an
infinite loop.

Task-number: QTCREATORBUG-9015
Task-number: QTCREATORBUG-9447

Change-Id: I0d83c59188ec15c4a948970e9fa944a17d765475
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-06-11 16:57:07 +02:00
Nikolai Kosjar
f3186690bd CppEditor: Improve finding position for new includes
...by detecting include groups (separated by new lines, include types
and same dir prefix).

Task-number: QTCREATORBUG-9317
Change-Id: I73e80fdc715104901cb2d4f5b15b4cab5d04d305
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-06-11 15:57:10 +02:00
Erik Verbruggen
f2631ad031 C++: do not strip trailing newlines in the preprocessor output.
Doing so resulted in an incorrect position for the EOF token when the
preprocessed output would be parsed. That in turn leads to incorrect
insertion positions for refactoring actions.

This is especially true when a file contains only preprocessor
directives: the EOF token would point to line 1 column 1, which is
usually not the place where code should be inserted.

Change-Id: I7d359aa7a6c04bc52c8b873fd49ad6afc3a77319
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-05-30 16:42:29 +02:00
Erik Verbruggen
aa3aa7c455 C++: Fix unused field warnings in test.
Change-Id: I898668a91eb7d3fa18c0a8d3e7e7507f0fb5a917
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-15 12:35:59 +02:00
Eike Ziller
bedc477943 Merge remote-tracking branch 'origin/2.7'
Conflicts:
	src/plugins/qmldesigner/components/formeditor/abstractcustomtool.cpp

Change-Id: I4e0a85795e7f4bfcdc21d106517517b527f85104
2013-04-30 11:43:33 +02:00
Francois Ferrand
4d18710f46 C++: fix handling of empty va_args macro arguments.
Preprocessor did not correctly handle when variadic macro arguments were not
provided at all, if there were other arguments: macro was not expanded
in case only the non variadic arguments were given.

 #define MACRO(...)       used to work fine for 0 or more arguments.
 #define MACRO(ARG0, ...) used to work only for 2 or more arguments, now fixed.

Change-Id: I64e9199ceccae05618a49931c2adad8e4f9471ba
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-29 10:09:43 +02:00
Erik Verbruggen
82e347095c C++: Untangle include file resolving from loading.
Change-Id: Iacf8cb12dd623c908538d80ee2595297a9bdde71
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-09 11:56:02 +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
Erik Verbruggen
dada2614d5 C++: add include-guard tracking.
Track the typical #ifndef/#define/#endif usage in header files to see if
the macro is an include guard. If so, store it in the Document. No
behavioural change, just recording the name.

This can be used in the future to track if a file needs to be re-parsed
when a macro changes: if it was used in the file, and not defined in it
nor being the include-guard, a file should be re-preprocessed and
re-parsed.

It can also be used to check if two files have the same include guard.

Change-Id: I2715f529997a7b24a11bdbc6150652e2669f1a46
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-01-18 14:58:07 +01:00
Francois Ferrand
4c43655cec C++: fix macro calls with comment before arguments
When in 'keep comments' mode, the preprocessor does not properly handle macro calls with
comments between the macro name and the opening parenthesis: "FOO /*something to say*/
(45)".

Change-Id: I6fe733242e4d2ccff2985d17399d0a084917415a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-01-18 14:56:47 +01:00
Nikolai Kosjar
492ca1cbcf Tests: C++: Make tests run from shadow builds.
For shadow builds some tests couldn't find their test data. Solved by
using the same pattern as in Qt tests: Inject $$PWD as SRCDIR via a
DEFINES statement.

Note: It was considered to use QFINDTESTDATA for Qt5, but this was
rejected due to:
 1) It's Qt5 only (would mean to introduce some wrapper...)
 2) As the doc states, it will not work with QTEST_APPLESS_MAIN tests.

Change-Id: Ie6cf59570fe61725b7f6f83b7da650331ddb38fc
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-07 14:10:24 +01:00
hjk
386ca7c8dd Adjust license headers
Change-Id: Ice592c6de9951ee3b2c4cb52ed0bb3b6770e0825
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2012-10-05 17:12:56 +02:00
Leandro Melo
d1b65bbf83 C++: Discard comments in macro definitions
Task-number: QTCREATORBUG-7815

Change-Id: Id3e6b018bfd58b0f0072c637d69721a4bde1603a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2012-09-05 16:35:33 +02:00
Leandro Melo
d87835cc90 C++: Always skip unknown preprocessor "directives"
Task-number: QTCREATORBUG-7780

Change-Id: Ie93704feff17ad8229e50fb1133048f2c7598dea
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <qthjk@ovi.com>
2012-08-29 16:07:40 +02:00
Leandro Melo
009d6b1e2f C++: Handle C++ style comments in macro expansion
Notice that a similar problem still exists for which we
need to fix the lexer when there's a C style commend which
 ends with a backslash-newline.

Task-number: QTCREATORBUG-7713

Change-Id: I0f6d561703984f917fa5ed29de020ad0bdc5aaf0
Reviewed-by: David Schulz <david.schulz@nokia.com>
Reviewed-by: hjk <qthjk@ovi.com>
2012-08-23 15:00:53 +02:00
Leandro Melo
b53d562816 C++: Take multiline strings into account when preprocessing
It was creating extra line(s)...

Change-Id: If28a9ccf16195c71747479db838a5589ea6683a0
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-08-23 14:35:53 +02:00
Christian Kamm
41e140da04 C++: Fix line number information after multiline comments.
Task-number: QTCREATORBUG-7702
Change-Id: I0ec2e1eb9bf1c556b0a426d4405df1c48b5653ed
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-08-07 11:31:06 +02:00
Eike Ziller
e0e8cf3ada Contact -> qt-project.org
Change-Id: I7134d7de30bcf9f9dcfad42520dd45ee083a852d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-07-19 13:23:21 +02:00
Leandro Melo
d6ccffc06c C++: Core changes in preprocessing
Summary of most relevant items:

- Preprocessor output format change. No more gen true/false. Instead
  a more intuitive and natural expansion (like from a real compiler) is
  performed directly corresponding to the macro invocation. Notice that
  information about the generated tokens is not lost, because it's now
  embedded in the expansion section header (in terms of lines and columns
  as explained in the code). In addition the location on where the macro
  expansion happens is also documented for future use.

- Fix line control directives and associated token line numbers.
  This was not detected in tests cases because some of them were
  actually wrong: Within expansions the line information was being
  considered as originally computed in the macro definition, while
  the desired and expected for Creator's reporting mechanism (just
  like regular compilers) is the line from the expanded version
  of the tokens.

- Do not allow for eager expansion. This was previously being done
  inside define directives. However, it's not allowed and might
  lead to incorrect results, since the argument substitution should
  only happen upon the macro invocation (and following nested ones).
  At least GCC and clang are consistent with that. See test case
  tst_Preprocessor:dont_eagerly_expand for a detailed explanation.

- Revive the 'expanded' token flag. This is used to mark every token
  that originates from a macro expansion. Notice, however, that
  expanded tokens are not necessarily generated tokens (although
  every generated token is a expanded token). Expanded tokens that
  are not generated are those which are still considered by our
  code model features, since they are visible on the editor. The
  translation unit is smart enough to calculate line/column position
  for such tokens based on the information from the expansion section
  header.

- How expansions are tracked has also changed. Now, we simply add
  two surrounding marker tokens to each "top-level" expansion
  sequence. There is an enumeration that control expansion states.
  Also, no "previous" token is kept around.

- Preprocessor client methods suffered a change in signature so
  they now receive the line number of the action in question as
  a paramater. Previously such line could be retrieved by the client
  implementation by accessing the environment line. However, this
  is not reliable because we try to avoid synchronization of the
  output/environment lines in order to avoid unnecessary output,
  while expanding macros or handling preprocessor directives.

- Although macros are not expanded during define directives (as
  mentioned above) the preprocessor client is now "notified"
  when it sees a macro. This is to allow usage tracking.

- Other small stuff.

This is all in one patch because the fixes are a consequence
of the change in preprocessing control.

Change-Id: I8f4c6e6366f37756ec65d0a93b79f72a3ac4ed50
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-06-25 15:49:27 +02:00
Leandro Melo
9daa34003d Revert "C++: Re-enable macro definition line test"
This reverts commit 44d8e7bef7.

The original test case was actually right. I guess I was mislead
by the recently added preprocessor tests, which are the ones
that should be corrected (together with the preprocessor, which
seems to have issues with # lineno generation).

Conflicts:

	tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp

Change-Id: I47f82ed23a37086d0d81c4b3ea2cac48fb753451
Reviewed-by: hjk <qthjk@ovi.com>
Reviewed-by: Francois Ferrand <thetypz@gmail.com>
2012-06-19 12:47:52 +02:00
Leandro Melo
f978400ae5 C++: Better handling of arg count mismatch in macros
Do not expand function-like macros at all when there's a mismatch
in the parameter/argument count.

The report below raises the issue but its expected result is not
correct. This would be the more appropriate fix.

Task-number: QTCREATORBUG-7225
Change-Id: Ide8580faa7b724d3e8b396ec1f899cc5ca7f9e7e
Reviewed-by: hjk <qthjk@ovi.com>
2012-06-19 12:47:44 +02:00
Leandro Melo
2af60cb1bf C++: Track macro argument reference even when empty
Change-Id: I6d226b4e42f94ebee41d012050c5109895f0c432
Reviewed-by: hjk <qthjk@ovi.com>
2012-06-12 18:10:56 +02:00
Leandro Melo
d90264d6c2 C++: Also expand first token after macro define
It was previously beeing skipped.

Change-Id: Iadd9b03acbcf0ee0fb4db537b8597661cb93af3f
Reviewed-by: hjk <qthjk@ovi.com>
2012-06-05 15:05:19 +02:00
Leandro Melo
ca7ac8c035 C++: Fix macro uses line info
Make sure the environment line is consistent during preprocessor
directives and identifier handling so clients can rely on consistent
information. Particularly important for macro usages.

New tests also added.

Change-Id: I962a39a86cd17b8d945d2959c2c95e2d258ea3e6
Reviewed-by: hjk <qthjk@ovi.com>
2012-06-01 14:28:03 +02:00
Leandro Melo
44d8e7bef7 C++: Re-enable macro definition line test
I believe those were actually incorrect, since the # mark
from the generated tokens `int f` should be relative to <stdin>
on the line they are defined, which is 1.

Change-Id: I663ef49ad75eb8bb0a4a4b18d4899a952011536c
Reviewed-by: Francois Ferrand <thetypz@gmail.com>
Reviewed-by: hjk <qthjk@ovi.com>
2012-05-31 18:02:08 +02:00
hjk
6d04f3ce25 preprocessor: do not loop endlessly on incomplete expressions
An missing closing parantheses after "defined(..." caused an endless loop.

Change-Id: I19b17cebc1a56880216c3bfb67c9d296f80cc064
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-05-30 13:34:38 +02:00
hjk
b13519d547 preprocessor: add an example of a macro that generates code
Change-Id: I902ebd73e039b8c3f44eca456be87809d1e1d3a4
Reviewed-by: hjk <qthjk@ovi.com>
2012-05-15 18:19:54 +02:00
hjk
2521d7d6e4 preprocessor: add (failing) test for concatenation
Change-Id: I9d51798cb4d95141d30b0609d03cd1d199088f0a
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-27 17:25:30 +02:00
hjk
051c33517f preprocessor test: code cosmetics
Change-Id: I67367e501c8f19cee9023e3782c6a9175b49c6c6
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-27 17:25:00 +02:00
hjk
bc01283481 preprocessor: add test cases for <=, == and >=
Change-Id: I126143daeb572a555b73dc33ad7996b22c1387f8
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-26 08:48:52 +02:00
hjk
feba990f6e preprocessor: swallow ) after defined(...
Task-number: QTCREATORBUG-7256
Change-Id: I6149e56e5f50f75c9e039be9c162036a3890e2d7
Reviewed-by: David Schulz <david.schulz@nokia.com>
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-25 13:41:51 +02:00
hjk
7f1f282111 preprocessor: some code style in auto test
Change-Id: I1381ce17098a87dbc3924dc86902d7cc1b1eec76
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-25 09:30:34 +02:00
Erik Verbruggen
bd47622183 Fix out-of-memory crash when indenting generated tokens.
Generated tokens do not have a position in any source file, so not try
to indent them. Previously, the 'source' used was the scratch buffer,
which would not contain newlines, so the indent depth would be the
length of the scratch buffer at that point.

Task-number: QTCREATORBUG-7262
Change-Id: If94213d6dffd13dd2b47c7038ec2398ad925d904
Reviewed-by: Yuchen Deng <loaden@gmail.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-23 11:06:35 +02:00
hjk
6d393252c4 preprocessor: rename operator() into run.
Easier to follow.

Change-Id: I6da1ca862ddb7048a6d16bf5e6ea18d6b2cfc7f8
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 19:37:14 +02:00
hjk
538901d441 preprocessor: make Preprocessor::preprocess private
Change-Id: Ic81e3ebec1b42ae0698a340ee7e1c711225c1162
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:47:03 +02:00