Commit Graph

60 Commits

Author SHA1 Message Date
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
hjk
386ca7c8dd Adjust license headers
Change-Id: Ice592c6de9951ee3b2c4cb52ed0bb3b6770e0825
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2012-10-05 17:12:56 +02:00
Christian Kamm
605acda9ae C++: Expand object-like macros in fast preprocessing mode again.
Task-number: QTCREATORBUG-7512
Change-Id: I59898a0449f1f6997963e0f31c47293358a773f6
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-08-07 07:35:34 +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
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
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
Thorbjørn Lindeijer
b35b0dd5e2 CPlusPlus: Removed two unused member variables
Change-Id: I1dd97c742af7c2783baaf04384ef2749027f3b9f
Reviewed-by: hjk <qthjk@ovi.com>
2012-05-02 11:12:52 +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
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
538901d441 preprocessor: make Preprocessor::preprocess private
Change-Id: Ic81e3ebec1b42ae0698a340ee7e1c711225c1162
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:47:03 +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
17c114fde8 preprocessor: make CPlusPlus::Internal::ByteArrayRef public
Change-Id: Ief6ea71f750b6ba19b650050bae376f4ad82d9d2
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:37:31 +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
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
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
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
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
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
hjk
8397663964 Update license. 2011-04-13 11:49:28 +02:00
con
d1023c7614 It's 2011 now.
Reviewed-by: hjk
2011-01-12 09:46:24 +01:00
con
04e32b0049 License headers. 2010-12-17 16:03:42 +01:00
hjk
9595504bda Long live the king! 2010-03-05 11:28:13 +01:00
Roberto Raggi
293f67580d Fixed: Wrong usage highlighting if function's argument list contains comment.
Task-number: QTCREATORBUG-577
2010-03-03 14:11:45 +01:00
Roberto Raggi
146ec6248d Renamed Preprocessor::_true_test 2009-10-21 16:20:45 +02:00
Roberto Raggi
5b7a19425b Use bit vectors to store the preprocessor's state. 2009-10-21 16:19:23 +02:00
hjk
93cbef8724 long live the king 2009-08-14 09:30:56 +02:00
Roberto Raggi
2f649be146 Disable macro expansion when preprocessing in fast-mode. 2009-07-06 09:53:25 +02:00
Jason McDonald
884b7af769 Update license headers and sales contact details.
Reviewed-by: Trust Me
2009-06-17 00:01:27 +10:00
Roberto Raggi
e2a0a4d7c5 Keep the original encoded text around while preprocessing. 2009-06-15 15:39:20 +02:00
Roberto Raggi
bdf6c3d0be Store the encoded file name in a QString. 2009-05-27 15:34:13 +02:00
Roberto Raggi
caad98ec4c Refactored a bit the preprocessor so we can use it to generate file dependencies. 2009-05-13 15:29:59 +02:00
Roberto Raggi
064201ff85 Mark the generated regions of text. 2009-03-04 14:36:47 +01:00
Roberto Raggi
e253f39360 Store the actual arguments of the macro expansions. 2009-03-04 11:47:30 +01:00
Roberto Raggi
5bbb882b3d Introduced expandBuiltinMacro(). 2009-03-03 17:23:12 +01:00
Roberto Raggi
7327a8ea4d Introduced skipActualArguments(). 2009-03-03 16:59:55 +01:00
Roberto Raggi
1d75990667 Introduced processObjectLikeMacro(). 2009-03-03 16:56:55 +01:00
Roberto Raggi
b316939dff Introduced expandObjectLikeMacro(). 2009-03-03 16:46:21 +01:00
Roberto Raggi
656d70fa74 Introduced expandFunctionLikeMacro(). 2009-03-03 16:19:03 +01:00
Roberto Raggi
454438e47d More cleanup. 2009-03-03 10:41:20 +01:00
Roberto Raggi
ae04679373 Introduced processNewline() and processSkippingBlocks(). 2009-03-03 10:27:02 +01:00
Roberto Raggi
d7e86c22b6 Cleanup the function-like macro expansion. 2009-03-03 10:13:51 +01:00
Roberto Raggi
2a8327e57f Obsoleted code. 2009-03-03 09:58:54 +01:00
Roberto Raggi
ebe17889f4 Some refactoring of the preprocessor, it'll simplify my next commits. 2009-03-02 19:03:07 +01:00