Commit Graph

1215 Commits

Author SHA1 Message Date
Nikolai Kosjar
624bfeb70b C++: Remove concurrent access to TemplateNameId
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>
2016-11-04 11:45:33 +00:00
Alessandro Portale
d54da12af9 CPlusPlus, Utils: Move namespace icon from CPlusPlus to Utils
...so that it can be used in the ScxmlEditor plugin

Change-Id: I0e0ed050f7765bcc901db3bb2c3273456a228b5e
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2016-10-26 10:45:06 +00:00
Orgad Shaneh
39aff55d8a C++: Enable showEnclosingTemplate also for function type
Do not require directly passing the enclosing template.

Change-Id: Ie03bc58338fe003677a5f5311d86d70f499373ee
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-06 09:33:48 +00:00
Francois Ferrand
7b2c09a118 C++: Disable C++ keywords in C files
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>
2016-08-23 12:35:04 +00:00
Orgad Shaneh
e7eac98c7e C++: Support pretty printing of template enclosing scope
Change-Id: Ib228184e1259585eeac61b9196195c39a9550cb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-19 13:34:44 +00:00
Nikolai Kosjar
ad49e64ff0 CppTools: Cancel parsing if editor is closed
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>
2016-07-29 12:03:07 +00:00
Dmitry Ashkadov
43075f5fb1 C++: Add support of ref-qualifier for functions.
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>
2016-06-22 17:47:59 +00:00
David Schulz
6750607244 Editor: Skip auto completed character only if it was recently inserted.
This means you can skip automatically inserted characters as long as you
don't explicitly move the text cursor and the editor doesn't lose the
focus. This will be visualized by highlighting the automatically
inserted character as long as you can perform the skipping.

This will reduce unexpected skipping in the case a cursor was explicitly
placed before an closing brace and a closing brace is typed.

Change-Id: I28e29e79ba10c9c48e8bc8817405fea630cca9bd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-21 11:56:56 +00:00
Christian Kandeler
e1e203598d qbs build: Final steps to support building plugins "out of source".
- Use the entire Export block when creating a module, not just the
  Depends items. Adapt references to the product source directory
  and the "share" directory so that they point to the respective
  locations in the install tree.
- Install dev headers for some more plugins.
- Bug fixes & polishing.

Create a "dev installation" like this:
$ qbs qtc.make_dev_package:true qbs.installRoot:<install root>

Then build your plugin against it like this:
$ qbs qtc.make_dev_package:true qbs.installRoot:<install root>
project.qbsSearchPaths:<install root>/qbs-resources
(Using qbs from 1.5 branch; 1.5.1 requires a trivial wrapper project.)

That's all. Successfully tested with all commercial plugins on Linux.

Change-Id: Ie39c4717dafcd431c533421a15f2f898783d8521
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-06-15 12:35:55 +00:00
David Schulz
179153829a CPP: Remove unused function.
Change-Id: Ib55fd0c059b2e5e117250eb4671b3352ab41b310
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-05-26 11:03:56 +00:00
David Schulz
509c977f30 C++: Improve automatic quoting magic.
Change-Id: I5d3a15dc100ae9c03bbc49de99714da1c89cb0d8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-05-25 13:56:05 +00:00
David Schulz
7595aaa227 Editor: Separate auto insert brace and quote magic.
To allow enabling/disabling both features separately.

Change-Id: Ica154e3b400823de7cf22daf006958802d751c64
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-05-25 13:55:50 +00:00
David Schulz
42ed3b44c8 C++: optimize paragraph insertion.
Do not check tokens which are returning the default return value.
Do not check for tokens when a previous condition excludes the other
token types.

Change-Id: Id97aed9d6342c6c12e9b26acdd0a8c4b0bca0868
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-05-20 12:46:57 +00:00
David Schulz
b482a6158c Remove duplicated code from c++ and glsl completer.
Change-Id: Ibda04771fceffef6344f6a6128d77dd8192379ca
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-05-20 12:35:10 +00:00
David Schulz
61be239795 CppEditor: Simplify insert matching characters.
Change-Id: Ib3a94d016b615d71b1635ebe13a87575b8dc12c5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-05-20 12:35:07 +00:00
Nikita Baryshnikov
ccb7aa8185 CPlusPlus: fix gcc warning
this 'if' clause does not guard

Change-Id: I004cb72dff2213738c59701d99748d7338991105
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-05-13 07:41:37 +00:00
Eike Ziller
0f94aa3f4d Merge remote-tracking branch 'origin/4.0'
Conflicts:
	src/plugins/debugger/debuggerruncontrol.cpp
	src/plugins/projectexplorer/projectwizardpage.cpp
	src/plugins/projectexplorer/xcodebuildparser.h
	src/plugins/qmldesigner/qmldesignerplugin.cpp
	src/tools/clangbackend/ipcsource/translationunits.cpp

Change-Id: Ibf0857cf8dbf95fc9ac13d5c2112b3f4a2ca7de6
2016-05-03 11:49:01 +02:00
Nikolai Kosjar
18e1dbed54 C++: Handle invalid indices in OverviewModel
This makes the following ModelTests pass:

ModelTest::nonDestructiveBasicTest()

  Q_ASSERT(model->data(QModelIndex()) == QVariant());

  Qt::ItemFlags flags = model->flags(QModelIndex());
  Q_ASSERT(flags == Qt::ItemIsDropEnabled || flags == 0);

Task-number: QTCREATORBUG-13142
Change-Id: If639981079b79d8b5b3bed22fb47453650449706
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2016-04-28 09:36:18 +00:00
Nikolai Kosjar
a717e980e7 C++: Guard against parent binding loop
Task-number: QTCREATORBUG-16146
Change-Id: Ib2a790954517859acd7ca5f16c7d889d28208fb0
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-04-27 11:42:21 +00:00
Eike Ziller
5c87432260 Merge remote-tracking branch 'origin/4.0'
Conflicts:
	src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp

Change-Id: I6ae2d37290643d69390f679a54f7596782f3d97f
2016-04-12 11:34:46 +02:00
Alessandro Portale
5e7edfefbd cplusplus.qbs Remove image files entries
Change-Id: I2283c8f2a0da28cbaa0352e9c0142197df8615bb
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
2016-04-11 15:50:26 +00:00
Alessandro Portale
4c7cef82aa CPlusPlus: New code model icons
Change-Id: I9ad6445319d85ffb652377a00256a68d56754352
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2016-04-11 11:24:33 +00:00
Alessandro Portale
984a6eca73 cplusplus: Make functions of Icons static
This avoids multiple instatiations and reloading of the same image files.

Change-Id: I4d0bb955e23c1cb817671c25bff4e74fb7b3d0f4
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-04-06 08:48:32 +00:00
hjk
39a38d5679 Wholesale conversion to #pragma once
Kudos to cgmb and https://github.com/cgmb/guardonce

Change-Id: Ifa8970734b8d43fd08c9260c645bdb0228633791
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-03-30 15:20:19 +00:00
Francois Ferrand
41b232962a C++: fix trigraph parsing in macros.
Trigraphs must only be parsed before/during preprocessing. The preprocessor
will now replace trigraphs with their standard form, and re-lexing in
TranslationUnit will not try to parse any trigraph.

Also added a few missing trigraphs: ??=, ??', ??! and ??-.

Task-number: QTCREATORBUG-13253
Change-Id: I1723ed53b00090b878c22b83b7e963b647b65f72
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-03-08 17:24:22 +00:00
Nikolai Kosjar
2b2ba298f3 CppEditor: Generate doxygen comments for functions with macros
...at least for object-like macros. This handles the common case where a
macro before the function signature annotates the DLL import/export.

Task-number: QTCREATORBUG-15819
Change-Id: I79f22508188019402fb7345222408aaf90106f20
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2016-03-04 14:22:27 +00:00
Tobias Hunger
f72370f20a Update License according to agreement with Free Qt Foundation
* Update remaining files in src

Change-Id: I1896f17fcf34f71c3310c87899fb5171b8e4afb1
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:59:41 +00:00
Nikolai Kosjar
3ed40074ff C++: Add missing includes
...that are needed for building unittest.pro.

Change-Id: I05a87febbb4a17752c4321b868f71cabf258e1dd
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-26 13:17:25 +00:00
Nikolai Kosjar
0498fb68ff C++: Revert lookup to 3.4.2
...which was least buggy.

The bugs fixed by the changes we revert here (highlighting/completion
for code involving templates) were minor compared to ones we currently
have. Those bugs will be addressed by the clang code model anyway.

Relevant commits were collected via:

  $ cd ${QTC}/src/libs/cplusplus
  $ git log \
   --no-merges \
   --format=oneline \
   v3.4.2..HEAD \
   -- LookupContext.* ResolveExpression.* TypeResolver.* TypeOfExpression.* \
      ../../plugins/cpptools/cppcompletion_test.cpp

From this list the following were skipped due to irrelevance:

  88c5b47e53 # CppTools: Minor cleanup in completion tests
  e5255a1f5c # CppTools: Add a test for ObjC not replacing dot with arrow
  5b12c8d63a # CppTools: Support ObjC in member access operator tests
  9fef4fb9ca # CPlusPlus: Fix warnings about overriding visit(...) methods

There were only minor conflicts while reverting those.

This changes touches so many files because there were quite some
cleanups and renames after the 3.4.2 release.

Task-number: QTCREATORBUG-14889
Task-number: QTCREATORBUG-15211
Task-number: QTCREATORBUG-15213
Task-number: QTCREATORBUG-15257
Task-number: QTCREATORBUG-15264
Task-number: QTCREATORBUG-15291
Task-number: QTCREATORBUG-15329
Change-Id: I01f759f8f35ecb4228928a4f22086e279c1a5435
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-19 14:48:38 +00:00
Orgad Shaneh
0bcddcd014 C++: Limit template instantiation depth
A recursive template generates infinite expansions.

Consider the following example:

template <class R1>
struct Base
{
};

template<typename R>
struct Derived :
  Base<
    typename Derived<typename Base<R>::type>::type,
    typename Derived<typename Base<R>::type>::type
  >::type
{};

R is instantiated as Base<R>::type, which causes another
instantiation of R into Base<Base<R>> etc...

This is not a solution, but a workaround.

Task-number: QTCREATORBUG-15141
Change-Id: Ib04f70275e07919e2cb6c7fb61a2045bd52f4a7d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-12 09:40:20 +00:00
Aleix Pol
b899684a89 Don't put QString in static attributes
It crashed in some places on our code-base due to the so-called "static
initialization order fiasco".
As a solution, it turns the variable into a function. This shouldn't have
a penalty due to QStringLiteral.

Change-Id: I9f8a955afdff878dc2f0db16fec861d81250c243
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2015-10-09 17:09:45 +00:00
Claus Steuer
158b07c9c8 C++: Support noexcept operator
The code model failed to parse the noexcept operator which is often
used in noexcept specifiers, e.g.: "void f() noexcept(noexcept(g()));"
Consequently some c++11 headers such as unordered_map, array
and unordered_set could not be parsed and no code completition was
available. I have created the NoExceptOperatorExpressionAST class
which is created whenever a noexcept token is found in an
expression with operator precedence. The noExcept test case
in the cplusplus/cxx11 test now contains a function that
uses the noexcept operator.

Fixed noexcept operator parsing

Added the test requested by Sergey Shambir, which then revealed that
i had not implemeneted the noexpect operator parsing according to the
c++ specification.
As stated here http://cpp0x.centaur.ath.cx/expr.unary.noexcept.html
the noexcept operator is a unary-expression that contains an
expression (and not a constant-expression). This should now be fixed.

Change-Id: Id4a99a43b660bd83e7680274491d99a698b57094
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-10-03 17:24:45 +00:00
Nikolai Kosjar
915f68deac C++: Revert problematic template specialization changes
This mainly reverts

    commit 81721f6781
    C++: Fix resolving of recursive typedef

    commit 2070431d8c
    C++: Fix resolving of partial specialization

and some bits of other changes due to dependencies. It also reverts

    commit e0594fc9b9
    C++: Fix expensive lookup for boost

which attempted to solve the upcoming problems.

Task-number: QTCREATORBUG-14741
Task-number: QTCREATORBUG-14889
Task-number: QTCREATORBUG-14962
Change-Id: I3f9e1f97199e5199b71da394fc27051c7709bd1f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-09-10 12:00:01 +00:00
Nikolai Kosjar
c504e56d0c C++: Fix MSVC assert in std::isspace()
...when dealing with UTF8 bytes.

std::isspace() expects unsigned char, not char.

Change-Id: I3f9b5e347d79cf94015cc99f8797d5feab406151
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-09-02 10:42:43 +00:00
Nikolai Kosjar
e0594fc9b9 C++: Fix expensive lookup for boost
With this patch, CheckSymbols takes about 200ms for processing the boost/proto
hello world example [1]. Before, it needed about 11 seconds (timer in
CheckSymbols::run). Same goes for including <boost/fusion/include/zip.hpp>.

The custom ProcessedSet object was added to support "completion for typedefs
for templates in namespaces", but apparently that's not needed anymore, as the
added test proves.

[1] http://www.boost.org/doc/libs/1_58_0/doc/html/proto/users_guide.html#boost_proto.users_guide.getting_started.hello_world

Task-numer: QTCREATORBUG-14889
Task-numer: QTCREATORBUG-14741
Change-Id: I90454e8970a9d04033d56beeb0c6d7a0d4e6cc62
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-08-21 10:25:15 +00:00
Orgad Shaneh
1b90b80f85 C++: Fix potential crash
If no template is found, findSpecialization will crash

Task-number: QTCREATORBUG-14748
Change-Id: I94b970e6eb994f0a8d85a4b996e52fcff0affef3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-03 09:32:05 +00:00
Orgad Shaneh
99dea548e0 C++: Fix crash in template argument resolving
Occurs in boost/phoenix.hpp

Task-number: QTCREATORBUG-14748
Change-Id: If89b0db48346aac72e0d8aaa8d165b2bf43bd784
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-03 09:31:45 +00:00
Nikolai Kosjar
892cb154b2 C++: Do not let ASTPath calculate line/column for generated tokens
ASTPath uses TranslationUnit::getPosition(), which returns reasonable
results for:

    1. non-expanded tokens
    2. expanded but not generated tokens

The expanded *and* generated tokens case is not handled since there is
no reasonable mapping from generated tokens to a continuous line/column
information. Consider:

    #define DECLARE_FOO int foo; // Multiple generated tokens
    DECLARE_FOO // ...can be mapped to this line, but to which columns?

Since the result where not valid for the expanded and generated case,
ASTPath took the wrong branches. Avoid this by skipping generated
tokens.

Change-Id: I33a2e0f62917f87d691b19feaeef67b09ea8d563
Task-number: QTCREATORBUG-13386
Task-number: QTCREATORBUG-13390
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-07-31 11:01:02 +00:00
Tobias Hunger
2e6855249f PNG: Run pngcrush on images with iCCP or sRGB profiles
This quietens warnings from libPNG during startup and shrinks the
image sizes.

Change-Id: Ieb4cb5e8ba30b99653896e283c2fb2cc267257f2
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-07-03 09:50:46 +00:00
Orgad Shaneh
7bed5cd3b6 C++: Cleanup LookupContext
Since the cache is now more reliable, some workarounds and optimizations
in the instantiation process are not needed anymore.

Also avoid instantiation of base classes when expandTemplates is
disabled.

As a bonus, we now resolve decltype of template function for a type that is not
referenced anywhere but in the decltype.

Change-Id: Idf42ba7280992db477c9aa62bb1815b27174594d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-07-01 14:41:43 +00:00
Orgad Shaneh
a77e32800c C++: Ignore explicit template instantiations
Defined in section 14.7.2 of the standard.

Fixes completion for std::string.

The following explicit instantiation appears in bits/basic_string.tcc:
  extern template class basic_string<char>;

This is wrongfully considered a specialization for a forward declaration
(like `template<> class basic_string<char>` is).

Introduce a new Symbol type for explicit instantiations.

Use-case:
template<class T>
struct Foo { T bar; };

template class Foo<int>;

void func()
{
    Foo<int> foo;
    foo.bar; // bar not highlighted
}

Change-Id: I9e35c8c32f6b78fc87b4f4f1fc903b42cfbd2c2b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-29 09:22:08 +00:00
Orgad Shaneh
f8544bbc42 C++: Resolve function-scope typedef inside lambda
Use-case:
struct Foo { int bar; };

void func()
{
    typedef Foo F;
    []() {
        F f;
        f.bar; // bar not highlighted
    };
}

Change-Id: Ifaee2d125931d993acad69f03031a675c6180858
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-29 09:09:16 +00:00
Orgad Shaneh
1faf2bd1ef C++: Fix resolving of using in enclosing scope
Use-case:
namespace Ns {
namespace Nested {
struct Foo
{
    void func();
    int bar;
};
}
}

using namespace Ns::Nested;

namespace Ns
{
void Foo::func()
{
    bar; // bar not highlighted
}
}

Change-Id: I6e667d63eb40511d65532c4d6d317aa4028a87a4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-29 09:08:46 +00:00
Alexander Izmailov
398ad5a40a Add icons for static fields and functions.
Icons for static members in completion list now with S letter.
Task-number: QTCREATORBUG-203
Change-Id: I6c997ad14eeb500936ffe73e2fc0ad8e552a46c9
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
2015-06-22 11:27:48 +00:00
Jochen Becher
431b25ad27 Introduce dragging for all explorer nodes.
Extend drop support with variant values. A drop may be a file drop or a
value drop or both.

Rename Utils::FileDropSupport to Utils::DropSupport and add methods to
add not only files but any QVariant value to the mime data. Project
explorer adds dragged nodes (which will be needed for future ModelEditor
plugin).

Change-Id: I799542c60fdecb3e64af0d3ba47b6caa9adbcfd7
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-06-15 08:12:56 +00:00
Orgad Shaneh
97d3d9ac09 C++: Support default template argument lookup for specialization
This fixes std::vector, although it doesn't really resolve numeric
template arguments. It just picks the first specialization.

Use-case:
class Foo {};
template<class T1 = Foo> class Temp;
template<> class Temp<Foo> { int var; };
void func()
{
    Temp<> t;
    t.var; // var not highlighted
}

Task-number: QTCREATORBUG-8922
Change-Id: I593515beb3a6d901b6088db8bc1b8e16c39083d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-09 14:18:17 +00:00
Orgad Shaneh
1c7e465c30 C++: Remove scope argument from initializeSubst
Use the template scope instead.

Change-Id: I8144427e14644697c709643da7c0ae0b0841e34d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-09 14:18:10 +00:00
Orgad Shaneh
997ab425ce C++: Improve accuracy in findSpecialization
* If a template type is specialized as a pointer, accept only pointers (of any
type)
* Same for references and arrays
* Only if the specialized type is not part of the template, match it
  against the input.

Fixes resolving of partial specialization with pointers.

Use-cases:
// 1
struct b {};
struct a : b {};
template<class X, class Y> struct s { float f; };
template<class X> struct s<X, b*> { int i; };
template<class X> struct s<X, a*> { char j; };

void f()
{
    s<int, a*> var;
    var.j; // j not highlighted
}

// 2
template <typename T> struct Temp { T variable; };
template <typename T> struct Temp<T &> { T reference; };
void func()
{
    Temp<int&> templ;
    templ.reference; // reference not highlighted
}

// 3
class false_type {};
class true_type {};
template<class T1, class T2> class and_type { false_type f; };
template<> class and_type<true_type, true_type> { true_type t; };
void func2()
{
    and_type<true_type, false_type> a;
    a.f; // f not highlighted
}

Task-number: QTCREATORBUG-14036
Change-Id: Idee5e3f41d15c0772318d3837cbcd442cb80293a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-09 14:17:38 +00:00
Orgad Shaneh
3fe1b92566 CppTools: Fix highlighting and follow for template using argument
Use-case:
template<class T>
using Foo = Bar<T>; // T not highlighted

Task-number: QTCREATORBUG-9944
Change-Id: I04cb62ea6a21f158f7fb4fb7ac79ccd6eb1bbfbb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-09 11:31:40 +00:00
Orgad Shaneh
63433e7b98 C++: Unindent findSpecialization
Change-Id: I5759c4e5b061865d53b00c7eeb0b1cee54f8398e
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
2015-06-09 05:51:17 +00:00