Commit Graph

755 Commits

Author SHA1 Message Date
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
Leandro Melo
11f6ae4a14 C++: Completion for templates as base classes
This fixes a variety of issues regarding class completion
when templates are used as base classes. The test cases
show examples.

Task-number: QTCREATORBUG-4357
Change-Id: I764d5ce817a78e1b19336e5beab758ca9e10f34b
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-08-23 14:31:42 +02:00
hjk
c685abebaf typeprettyprinter: fix handling of _ at start of identifiers
This broke e.g. 'AddDefinition' for 'int foo(int const * const _x)'.
resulting in 'foo(const int *const_x)'

Change-Id: I6aae6c4a47e127de109b5fbefdf202ca050a391f
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-08-23 10:56:33 +02:00
Tobias Hunger
8da8d21c18 Remove some unused member variables
Change-Id: I4b1bcfe8da32bd48c601d1efdb7c3aac1d39cbce
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-08-22 16:18:54 +02:00
Kai Koehne
5064933944 Avoid adding the same DEFINE multiple times to the command line
E.g. on MSVC, QT_CREATOR was passed 14 times ...

Change-Id: Ife39267b0d6f2def1706b823abfd0226325437ae
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2012-08-21 11:57:22 +02:00
Francois Ferrand
9c7b96c663 Fix display of templates in outline.
Change-Id: I8b099c8234fac55ef0de17b014c89fbe02534bf4
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-08-21 08:58:52 +02:00
hjk
e481b1ad27 libs/cplusplus: remove unneeded #includes
Change-Id: Iadd8ace8a3870a9b0046dc65bf00d7e702e15b97
Reviewed-by: hjk <qthjk@ovi.com>
2012-08-15 13:30:23 +02:00
Leandro Melo
a1b6a4749e C++: Fix finding of destructor in outlined definitions
Task-number: QTCREATORBUG-7323

Change-Id: I92a42a30d156de2d8006f1df8da86d808a1a518d
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
2012-08-08 16:01:57 +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
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
hjk
6a7cf405bd rename QtDebug to QDebug
More uniform.

Change-Id: I1c6057981f4c2b3170a4e69f0674fe4caf1143a2
Reviewed-by: Robert Loehning <robert.loehning@nokia.com>
2012-08-06 14:55:08 +02:00
Eike Ziller
42f4595e37 Merge remote-tracking branch 'origin/2.5'
Conflicts:
	src/libs/cplusplus/cplusplus-lib.pri

Change-Id: I430ec8c6dda4afad3aedb1bc47d3af64537cfe66
2012-07-24 14:17:33 +02:00
Christian Kamm
23777da0e8 C++: Add dumpers for common datatypes to simplify debugging.
Change-Id: I03f907dd0e8d9d63f0dfd38499c98296b5c7871a
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
2012-07-23 07:19:17 +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
Francois Ferrand
e203893fd1 Add function return type in outline.
Append the function return type in outline (after arguments), consistently with
variable type indication.

Change-Id: I1cc6d69634fc83227eb7fc9e3a0ee2ad6ca6ace8
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-07-17 19:05:43 +02:00
Leandro Melo
4557d586f6 C++: Initialize member
Change-Id: Ifb708cb875aa1403de66a4c3302f70e0d1b4d2ac
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
2012-06-28 13:50:28 +02:00
Leandro Melo
621e5c3dbe C++: Parse emit/Q_EMIT properly
The parser now understands emit/Q_EMIT as an expression statement.

Also, the recent fixes in the preprocessor introduced a side-effect
in the hanlding of code such as: emit signal(); Member signal started
being treated as a local use (parsed as a declaration) and possibily
being highlighted as unused variable.

Previously that worked by accident since there was an inconsistency
in the preprocessor on which only object-like macros were being
expanded even when the "no expand" flag was set. Then, the code
mentioned above was being parsed as an expression, what kind of worked.

Change-Id: I47a68ed4c1c1702872620b8ed7c7264fb0997034
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2012-06-28 11:49:50 +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
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
23c637c4f6 C++: Introduce unicode char/strings support
Those are the types char16_t and char32_t along with the new
char/string literals u'', U'', u"", u8"", and U"".

This is particularly important for the use of QStringLiteral
since in some platforms it relies on expansion such as above.

Note: The string literals quickfixes still need some tunning.

Task-number: QTCREATORBUG-7449
Change-Id: Iebcfea15677dc8e0ebb6143def89a5477e1be7d4
Reviewed-by: hjk <qthjk@ovi.com>
2012-06-06 14:55:07 +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
Francois Ferrand
809611f346 CppHighlighter: highlight all functions/methods.
- Highlight all function/methods (not just virtual methods).
- Highlight as a function even if number of arguments does not match. In
  that case, add a diagnostic message to indicate there are too many/too
  few arguments.
- Fix highlighting of parameters in function declarations.
  These used to be handled indiferently, and they could be mistaken for
  type or field references.
- Properly highlight template method calls.

Change-Id: I6e61c9ee47763db95c62314f9cc1c4d398df38b3
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-06-05 09:30:54 +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
Thiago Macieira
e58f203e4c Silence a warning about unrecognised pragma with ICC
src/libs/cplusplus/MatchingText.cpp(64): warning #161: unrecognized #pragma
  #    pragma GCC diagnostic ignored "-Wstrict-overflow"
              ^

This pragma is recognised in GCC only, so don't enable it for when ICC
fakes to be GCC.

Change-Id: I3d9830dc2b12632dd08d8c8961219bd253ad8c1d
Reviewed-by: hjk <qthjk@ovi.com>
2012-05-28 00:28:30 +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
Friedemann Kleint
d7f6bc3369 Fix warning about truncation from size_t to quint.
qstrncmp() takes a quint.

Change-Id: I6e11155a793e3a4d9d29861ebb7c7a9c5c2f31c8
Reviewed-by: hjk <qthjk@ovi.com>
2012-05-07 13:20:51 +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
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
Bradley T. Hughes
fb9146a9c3 Compile after qt5/qtbase commit 75a0c7f9
Commit 75a0c7f9b52cde47f20fdc1b89e1264d60350848 in qt5/qtbase changed
some QRegExp methods to be non-const (they were previously const). This
change makes Qt Creator compile again.

Change-Id: Ibc98c678126c3b3189df7fcc043463b940951445
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
2012-04-30 14:32:08 +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
ef09a67c6b preprocessor: add some helper function to dump Environment state
Change-Id: I5e1d549f96e899aadd5c94a5d7ef7f3169f45806
Reviewed-by: hjk <qthjk@ovi.com>
2012-04-19 18:48:07 +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
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
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
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
Oswald Buddenhagen
822233629d Merge remote-tracking branch 'origin/2.5'
Conflicts:
	qtcreator.pri
	src/libs/utils/utils.qbs
	src/plugins/projectexplorer/miniprojecttargetselector.cpp
	src/plugins/qmljseditor/qmljseditor.qbs
	src/plugins/qmljsinspector/qmljsinspector.qbs

Change-Id: Ib239d50c21cb06d3a8e821e03dc093552f40ffab
2012-04-19 16:13:09 +02:00
hjk
97069c2274 preprocessor: streamline ByteArrayRef
Change-Id: Iec09651a6aa2fe3b8a50e631fd2fdc57830892a5
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2012-04-19 10:53:10 +02:00