Commit Graph

232 Commits

Author SHA1 Message Date
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
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
Leandro Melo
bf9bc9914b C++: Fix argument tracking in macro expansion
Due to latest changes the macro arguments were no longer being tracked.
Then they were no available in the document's macro uses. The patch also
makes sure that the preprocessor condition to be expanded is spelled
exactly as in the source code (this guarantees that offsets will be
properly calculated).

Change-Id: I8aff0c3aca0c528ef2c4bcfa56ff1c3da2961060
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-05-23 17:40:05 +02:00
Thiago Macieira
e1cab76344 Fix ICC warnings about commas at the end of enums
They're non-standard. Remove them.

Change-Id: I58dc093c2459747ce0183685d325522fb51e86ab
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
2012-05-23 16:25:08 +02:00
hjk
0672d873d0 preprocessor: concatenate tokens need to preserve previous whitespace
Change-Id: Ibca5737ad906c1db7e1bf4e15e5c92030e87c0bb
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-05-02 00:37:11 +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
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
Erik Verbruggen
d1eefacd55 Code clean-up.
Change-Id: Ib2ba453e98befceaf3445a2daa6ecc4660a6a9b4
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
2012-04-22 15:46:32 +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
6d837b627a preprocessor: don't store original sources, it's never accessed again
Change-Id: I3b06cfc827543d20069f69e00123ccf2bc19ed31
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 19:30:17 +02:00
hjk
493cde8335 preprocessor: do not expand macros when checking defined(...)
Change-Id: I39cfbd7f7adf13ec52527c79c9481d56283087df
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 19:29:56 +02:00
hjk
0362016f02 preprocessor: inline state setup
Change-Id: Icc3ee542c8e8f95dfd48604144e3f4ab638fdcd4
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 19:05:29 +02:00
hjk
a9a894558f preprocessor: the state stack seems unused. remove it.
Change-Id: Id53c5ebc2867c1ea1e62bb9be6eebe9732774713
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-19 18:47:37 +02:00
hjk
64565e795a preprocessor: remove unused Preprocessor::string function
Change-Id: I12e487d278621325bfc3add4c569297efe3c264b
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:42:45 +02:00
hjk
e78f9e4dfe preprocessor: used std::deque instead of std::list for token buffer
Change-Id: I56b1ee492469c523266337a885f664dea5deab98
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:41:36 +02:00
hjk
acf6f8f0cb preprocessor: make Environment::{resolve,remove} work on ByteArrayRefs only
Change-Id: Idb93d359bd45696a38cb863dcea30c5c377eeabb
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:41:18 +02:00
hjk
d4b4a75603 preprocessor: save cycles by using ByteArrayRef
Change-Id: I339696763b045ef1bda17dd55746738ef4ddbb67
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:36:33 +02:00
hjk
3df5728dce preprocessor: use strtol immediately instead of intermediate bytearrays
Change-Id: I92ffe360847fc828b23467d0639824aea63fab32
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-19 18:35:47 +02:00
hjk
6808719962 preprocessor: avoid using QVector += QVector.
It destroys preallocation. See https://bugreports.qt-project.org/browse/QTBUG-25371.

Change-Id: Idde09a07f250a347f8016d8fdb04cd00d031fe10
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-18 13:20:51 +02:00
hjk
4e83279123 preprocessor: provide direct char* overloads for ByteArrayRef::operator==
Change-Id: I58de7e704bdbd3861a4a534d8080cc2a8399b7eb
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-18 13:20:17 +02:00
hjk
9e3127a2f6 preprocessor: don't create temporary bytearray objects to handle commas
Change-Id: I1c45bb9a5118e19b15878eb04e65b52bd6c5d1e7
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-18 13:20:04 +02:00
hjk
7383220d73 preprocessor: prevent temporary copy
Change-Id: Ic86d8b091da332393a527ba634a23556f2001a8b
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-18 13:06:22 +02:00
Thiago Macieira
8a5074734a Fix the compilation with GCC 4.6's headers.
std::list is in #include <list>

/home/thiago/src/qt/creator/src/libs/cplusplus/pp-engine.cpp(110): error: qualified name is not allowed
      std::list<PPToken> tokens;
      ^

Change-Id: I02a08afe6a678d66d528ce5dfca08317735704e8
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-04-11 13:32:44 +02:00
Francois Ferrand
68471c2100 Preprocessor: fix macro definition line.
The line corresponding to the macro definition is simply the token's
line. This caused errors in the macro definitions, since there were
multiple macros defined on the same line of the same file.

Task-number: QTCREATORBUG-7217
Change-Id: I56d17eeba677ac51f9eed283c0e964019bdfe4b7
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-04-02 17:01:52 +02:00
Francois Ferrand
332072019a Preprocessor: Fix client notification.
- Notify end of macro if function expansion is skipped.
- Do not notify client of generated macros expansion.

Change-Id: Ic027fc13ee391425a5ebadc8e84b9305912dbcf0
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-04-02 13:49:00 +02:00
Erik Verbruggen
f5aacb89eb [C++] Robustness fix for boost's preprocessor/seq/fold_right.hpp.
Change-Id: I11f6cff556519b768dd5d979dfd184809ed18291
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-03-30 16:05:18 +02:00
Erik Verbruggen
48154450de [C++] Fix crash for missing token after #include directive.
Change-Id: Ia54c5ddc801962c89dc0483f5912f1de436b8f43
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
2012-03-30 13:36:31 +02:00
Erik Verbruggen
ff0a465403 [C++] Always output a #line as first line of the pp output.
Change-Id: I60d25109ae8fe3628b1899078a21010263787c33
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-03-30 13:24:36 +02:00
Erik Verbruggen
2a74097b54 Fix #include MACRO_NAME.
Change-Id: Id1c4046d028ad26d17b28feb53a832f3b48363f1
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
2012-03-29 17:17:00 +02:00
Erik Verbruggen
60db573660 [C++] Rewrite of the preprocessor.
This rewrite fixes a couple of issues with the pre-processor. It now
supports:
- macros in macro bodies
- stringification of parameters [cpp.stringize]
- the concatenation operator [cpp.concat]
- #include MACRO_HERE
- defined() inside macro bodies used in pp-conditions.

Change-Id: Ifdb78041fb6afadf44f939a4bd66ce2832b8601f
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-03-29 14:28:17 +02:00
Francois Ferrand
2386d701b6 Preprocessor: fix line for generated code.
The macro used to be at the same line as the first token after the
closing parenthesis.

Change-Id: I4c2d7317632baf612900e84572017aeb247d0585
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
2012-03-19 10:48:43 +01:00
Francois Ferrand
ffd58c577a Preprocessor: Handle variadic arguments (__VA_ARGS__).
Change-Id: I69aa6c5e01ea97a4413f77f20ebbb4d4beb971aa
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
2012-03-19 10:31:09 +01:00
Erik Verbruggen
3fa55b7ab9 Removed module names from #include directives.
Getting the #include directives ready for Qt5. This includes the
new-project wizards.

Change-Id: Ia9261f1e8faec06b9285b694d2b7e9a095978d2b
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2012-02-15 16:24:46 +01:00
hjk
2931a499e6 Long live the king!
Change-Id: I2b72b34c0cfeafc8bdbaf49b83ff723544f2b6e2
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
2012-01-26 19:55:36 +01:00
hjk
31600758de all: s/info@qt.nokia.com/qt-info@nokia.com/
Change-Id: If18afb5d4665924e7d9250dccbc60a65e6daa75e
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2011-11-03 10:33:19 +01:00
Benito van der Zander
d6e46f7a84 add always defined macro Q_CREATOR_RUN to cpp parser
Merge-request: 336
Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>

Change-Id: Iefd0c60bb3e78047e28dcff33cc62c15ed11f711
Reviewed-on: http://codereview.qt-project.org/4292
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
2011-09-08 14:09:48 +02:00
Leandro Melo
d91c218d54 C++: More flexibility for string representation of macros
It's now possible to get the macro definition with the actual
line breaks used on the code. This is particularly useful for
tooltips in order for them to look nice.

The preprocessor is changed so the macro also stores the breaks
positions. This doesn't seem to have any impact on performance.
In my machine, for example, the total time for parsing Creator's
source code is approx. 18100ms with or without the patch.

Change-Id: Ic7487236315c3567d26496315accdb2adfea894a
Reviewed-on: http://codereview.qt.nokia.com/4253
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
2011-09-06 14:21:04 +02:00
Christian Kamm
9f1c294dd4 C++ preprocessor: Fix multiline tokens in ifdef'ed out blocks.
Change-Id: If6f9819565f891e861f9e111423d99caa7c0f7aa
Reviewed-on: http://codereview.qt.nokia.com/3884
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
2011-08-31 07:41:32 +02:00
Christian Kamm
93e367ed0c C++: Don't strip comments from preprocessed source code.
Change-Id: I3a4817d36b9c724abca504c42914a73f97ab34c7
Reviewed-on: http://codereview.qt.nokia.com/3480
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2011-08-25 13:20:09 +02:00
Tobias Hunger
aa2acec14c Fix/add copyright headers
Change-Id: I8b73d583be1ee7183f4074bce49d5390e38631a2
2011-05-06 15:17:05 +02:00
Friedemann Kleint
774fa49412 Fix more krazy warnings. 2011-04-19 15:43:53 +02:00
hjk
8397663964 Update license. 2011-04-13 11:49:28 +02:00
hjk
57eae3191e s:// end of namespace :// namespace :g for consistency
We use the latter style everywhere else to signify the end of a namespace block.
2011-02-04 12:45:32 +01:00
con
d1023c7614 It's 2011 now.
Reviewed-by: hjk
2011-01-12 09:46:24 +01:00
Christian Kamm
16542241c9 C++: Add parsing of Q_PRIVATE_PROPERTY.
Reviewed-by: Roberto Raggi
2011-01-04 15:58:22 +01:00
Christian Kamm
633c254986 C++: Fix bind of Q_INVOKABLE functions.
Reviewed-by: Roberto Raggi
2011-01-04 15:58:21 +01:00
con
04e32b0049 License headers. 2010-12-17 16:03:42 +01:00