Commit Graph

1069 Commits

Author SHA1 Message Date
Nikolai Kosjar
79f0ab18c3 C++: Clear state in DependencyTable::build
...since build() is called multiple times for e.g. the global snapshot
(CppModelManager::projectPartFromDependencies,
CppModelManager::replaceDocument).

Change-Id: I03667496a5abc984ba976046dc7b76998a6e3336
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-09-22 19:22:30 +02:00
hjk
9a968b7417 CppTools: Move DependencyTable to Snapshot
It logically depends on the Snapshot and has a related lifetime.
Keeping it in the Snapshot avoids some code compelxity.

Change-Id: I24ee4483b44d9b0d7f2e4d494ae7ea624b949f9c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-19 11:11:30 +02:00
hjk
7104998d41 CPlusPlus: Simplify MatchingText interface
Change-Id: I46878d9ca048d0c79032445f5adc27c12d27f30c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-17 11:26:14 +02:00
Erik Verbruggen
67421f6c53 C++: fix invalid nesting of if statement.
Reported as a dead store by the clang static analyzer.

Change-Id: Id5eb72ea4698a17486b8a05d88ee66f3fd89bcfc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-12 11:31:56 +02:00
Nikolai Kosjar
1f53ecd898 Revert "C++: add support for resolving typedefs for template arguments"
This reverts commit c228b36ccf.

There are multiple issues with the reverted patch:
  * Infinite loop due to indirect recursion e.g. when opening projectmodels.cpp
  * Crash when executing CppTools tests on Windows (no infinite loop)

Change-Id: I38f02132ca57d3d32085db6146d0df7d620d7618
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-09-11 12:55:02 +02:00
Przemyslaw Gorszkowski
c228b36ccf C++: add support for resolving typedefs for template arguments
Example:
template <typename T>
struct Base { T t; };
struct Foo { int foo; };
void fun() {
  typedef Foo TypedefedFoo;
  Base<TypedefedFoo> baseFoo;
  baseFoo.t.// no code completion
}

Change-Id: I4822693d3fa1ee2e9b0e4cdd28bb9a8d441fb313
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-09 13:49:31 +02:00
Orgad Shaneh
dc6c0bceac C++: Remove double return in FindUsages
Change-Id: I76a0f4e20b364affdd8a7939fced6f0f012b661c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-09 11:58:47 +02:00
Christian Kandeler
847f10e9cc Remove Qt version checks.
Qt 5.3 is the minimum requirement these days. Remove all fallback code
from sources and project files.

Change-Id: If6188a471197acadda4d6baee71804ba1a8026c6
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-09-08 10:33:25 +02:00
Kai Koehne
e2584f69d4 Replace QLatin1String("x") with QLatin1Char('x') where possible
Change-Id: I2f90c8ae7b5e968b9de882833f8661ab540a9232
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-09-04 14:50:00 +02:00
Eike Ziller
49db3a450a Merge remote-tracking branch 'origin/3.2'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/coreplugin/editormanager/editormanager.cpp
	src/plugins/cppeditor/cppeditor.cpp
	src/plugins/remotelinux/remotelinuxdebugsupport.cpp
	src/plugins/texteditor/basetexteditor.cpp

Change-Id: I0da7c1cf2506b12d0563795aa8177fc45e97050f
2014-09-03 16:08:02 +02:00
Nikolai Kosjar
d5c6a360d0 C++: Remove unused local variable
Change-Id: I4568709edc7e11de2584916014c16f95ceb4b584
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2014-08-29 16:59:44 +02:00
Erik Verbruggen
c8c2aaafdf C++: Fix possible use-after-free of AST.
The CppRefactoringChanges::fileNoEditor takes a Document from the
snapshot it has. Although this snapshot is a safe copy, it might have
been gotten right after it was updated by indexing. Such a document will
still have its AST. If this AST is used by any refactoring action
without retaining it, the pointers will be dangling after a short while
(specifically: after the locator has extracted all the information).

The fileNoEditor method is called by the declDefLinkFinder to search
the target document. The snapshot is obtained before, and contains the
document for the semantic info. However, the target document will not
come from the semantic info, but from the indexer.

Change-Id: I212ff41dde6910e94e80552b2c3e5911fe9496ae
Task-number: QTCREATORBUG-11262
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-29 14:14:37 +02:00
Erik Verbruggen
703f36a4b8 C++: remove reserved names.
See [global.names] (17.6.4.3.2 in the C++11 spec.)

Change-Id: I8434496dbe392b52d339d5f17cfaeee8dbd88995
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-28 17:58:33 +02:00
Przemyslaw Gorszkowski
29532a6971 C++: refactoring: extract finding anonymous as nested type
Change-Id: I73d50d7b51e6a4e9d2b20df487f871793a6a6889
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-28 16:02:07 +02:00
Filipp
077bbf6803 search for partial specialization for arrays
A<int[]> now prefer second specialization for
template<typename T> class A
template<typename T> class A<[]>

Change-Id: I32e874f78b2f5b363d088fbab6a8897e42e44035
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-20 10:26:11 +02:00
Przemyslaw Gorszkowski
b514d4d7b2 C++: fix code completion for typedef of pointer array
Example:
struct Foo { int foo; };
typedef Foo *FooArr[10];

void func()
{
    FooArr arr;
    arr[0]-> // No completion
}

Task-number: QTCREATORBUG-12703
Change-Id: I1898dbf83eaa0a6dfa8c401390f28c78e5739bc4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-18 09:02:57 +02:00
Oswald Buddenhagen
f3a61e8bf7 Merge remote-tracking branch 'origin/3.2'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/android/androidglobal.h

Change-Id: I3367bf2ea47c088989175dddeed2210294346f4c
2014-08-05 14:24:23 +02:00
Przemyslaw Gorszkowski
ba42ceb0cb C++: nested class with enclosing template class
The parent of instantiation of nested class of template class
should be the instantiation of enclosing template class.

To prevent the infinite loop for case with local typedef of enclosing
template we should not change a parent of typedefed instatiation of
enclosing template. Example:
template <typename T>
struct Enclosing
{
  typedef Enclosing<T> EnclosingT;// first case
  struct Nested
  {
    typedef Enclosing<T> EnclosingT;// second case
  };
};

Task-number: QTCREATORBUG-11752
Task-number: QTCREATORBUG-11999
Change-Id: Iadd7b5ef73ee0c4881f59c9dabfe03339f55827b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-01 09:59:59 +02:00
Przemyslaw Gorszkowski
0bc202d52f C++: use pointer in template specialization and initialization
Fix code completion for using pointer in template specialization and
initialization.
Example:
template <typename T>
struct S {};

template <typename T>
struct S<T*> { T* t; };

struct Foo { int foo; };

int main()
{
  S<Foo*> s;
  s.t-> //no code completion
  return 0;
}

Task-number: QTCREATORBUG-12638
Change-Id: Idcd461806a22f08b76236f2db6346f157b12f5d3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2014-07-31 22:53:14 +02:00
Nikolai Kosjar
6a9ae7e25f CppTools: Auto-include pre-compiled headers
So far the pre-compiled headers were processed (thus defines from those
headers were visible), but the actual includes for the documents were
not added, which is necessary for lookup/completion.

Note that this will be only done if pre-compiled headers are not ignored
(Options > C++ > Code Model > [] Ignore pre-compiled headers).

Change-Id: I54a8e6b00597af164d958e3e9f2a1075ea187788
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-07-24 12:25:02 +02:00
Erik Verbruggen
45b1169d06 C++: Support alignas in C++11 mode.
Change-Id: Ifa81a481bf92b5b71495a105ae292f3e9895f704
Task-number: QTCREATORBUG-9279
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-07-22 16:43:51 +02:00
Nikolai Kosjar
dc59d28736 C++: Check for Function::name() before using it
Lambdas do not have a name.

Change-Id: Ifda4816c62dcfe19bdbb1649dc1caf408e056b37
Task-number: QTCREATORBUG-12686
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2014-07-17 12:09:36 +02:00
Przemyslaw Gorszkowski
059cfde677 C++: template base class and default argument for template class
Fix code completion for case:
struct Foo
{
    int bar;
};

template <typename T>
struct Base
{
    T t;
};

template <typename T1 = Foo>
struct Derived : Base<T1>
{};

int main()
{
    Derived<> foo;
    foo.t.// no code completion
    return 0;
}

Task-number: QTCREATORBUG-12606
Change-Id: Iadf2fae172739d0a5844c6b437fd2686616e64e7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-07-08 09:53:48 +02:00
Przemyslaw Gorszkowski
4aa4e64b77 C++: base class and default argument for template class
Fix code completion in case:
struct Foo
{
  int bar;
};

template <typename T1 = Foo>
struct Derived : T1 { };

int main()
{
  Derived<> foo;
  foo. // members from Foo are not proposed
  return 0;
}

Task-number: QTCREATORBUG-12605
Change-Id: Ibe35c7b9a161e789057a4518c72390ac52489a3e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-07-07 13:26:14 +02:00
Eike Ziller
cbf4de0315 Merge remote-tracking branch 'origin/3.1'
Conflicts:
	tests/auto/debugger/tst_dumpers.cpp

Change-Id: I1bad0c1477d7fd6996c0f8ca82e76ba521bc0dcc
2014-06-18 14:20:58 +02:00
Dale Marchand
ff52061e52 Fixed compilation error on RHEL 5.10.
Nesting the namespace "Internal" inside of other namespaces and using
sequential "using namespace" directives *or* relying on a "using
namespace" directive to resolve a method name that contained the
"Internal" namespace for resolution resulted in ambiguous resolution
errors when compiling with the RHEL5.10 stock compiler (GCC 4.1.2).  A
sample error is provided below:

Compilation error encountered was:
reference to 'Internal' is ambiguous
/usr/lib/gcc/x86_64-redhat-
candidates are: namespace Internal { }
qt-creator/src/libs/cplusplus/PPToken.h:106: error:
namespace CPlusPlus::Internal { }

Modifying the using namespace directives to reflect the nested nature of
the namespace names resolved the compilation errors.  For example:

using namespace CppEditor;
using namespace Internal;

produced errors.  However,

using namespace CppEditor;
using namespace CppEditor::Internal;

resolved the compilation errors by removing the ambiguity.

Change-Id: I6d5051e20acb2c147bd7ee1c6c6e1e3b2b4ff0f9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-18 11:06:45 +02:00
Wang Hoi
c56b999fff C: Parser: Support parsing of c99 designated initializers
In case:

    int a[6] = { [4] = 29, [2] = 15 };
    struct point { int x, y; };
    struct point p = { .y = 3, .x = 2 };

Grammar change when c99 language feature is enabled:
old grammar:

    braced-init-list :: '{' initializer-list '}'

new grammar:

    braced-init-list :: '{' designated-initializer-list '}'
    designated-initializer-list :: designated-initializer (',' designated-initializer )*
    designated-initializer :: designator* initializer-clause
    designator :: '.' identifier
                | '[' constant-expression ']'

Task-number: QTCREATORBUG-1902
Change-Id: Ib99d6f553f8d0f50ba3eff86f3a2e86d73372426
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-17 16:23:23 +02:00
Przemyslaw Gorszkowski
9b6d4573aa C++: fix 'using' in separate block of scope
Task-number: QTCREATORBUG-12357
Change-Id: I7397b0e66783d3249daa5a8ee422bfd5f5bc7bea
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-13 23:32:07 +02:00
Erik Verbruggen
6a514c8be6 Move ScopedSwap template out of pp-engine.cpp and into the utils lib.
Change-Id: I9370da5f3159f6d8ad9ee9f8fe949f66eb235592
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2014-06-04 10:25:29 +02:00
Nikolai Kosjar
ff1203de9e C++: Fix Macrouse::utf16charsBegin()
This caused displaced highlighting of macro uses after #if constructs.

MacroUse::utf16charBegin() was based on the last "continuation token",
which was wrong.

Change-Id: I89983d82fcf804ba853c04a59a7533c489785d05
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-03 14:54:17 +02:00
Orgad Shaneh
c3b7dc0ac1 C++: Optimize condition
Change-Id: Ifc48b9c89d6399636aed3693a0736ad6d58f0cff
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-28 16:50:20 +02:00
Orgad Shaneh
b84611e199 C++: Enable runtime lookup debug...
... by setting the environment variable QTC_LOOKUPCONTEXT_DEBUG

Change-Id: Ia46f55b2989129d5327d894734b6ea9c77c3e0ac
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-28 15:46:00 +02:00
David Schulz
8d587fa816 Debugger: Allow breakpoints inside lambdas.
When the cdbengine is using the codemodel breakpoint correction.

Change-Id: I70efa3119ca36b4ffd658425132f3fdff3d3eecf
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-26 07:19:10 +02:00
Nikolai Kosjar
acbc4b9f07 C++: Get rid of {Name,Type}::isEqualTo()
...since it's superseded by the class Matcher.

For consistency, rename FullySpecifiedType::isEqualTo() to match().

Change-Id: I07640f9218d814e0350265de45f05929e5d595a9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:43:30 +02:00
Nikolai Kosjar
c6358e5d38 C++: Add utf16 indices to Macro and Document::MacroUse
In most cases we need to work with the utf16 indices. Only in
cppfindreferences the byte interface is still needed since there we read
in files and work on a QByteArray to save memory.

Change-Id: I6ef6a93fc1875a8c9a305c075d51a9ca034c41bb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:34:01 +02:00
Nikolai Kosjar
bea8fc8e6a Cpp{Tools,Editor}: Expect UTF-8 encoded literals
Change-Id: I9843c4163aad3fa3f1bfa33060c76328fc2dc25a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:24:23 +02:00
Nikolai Kosjar
41aa2cb3bd C++: Use Token::utf16chars{Begin,End} where appropriate
...especially in CppTools/CppEditor where the offsets are used with a
QString/QTextDocument.

Change-Id: Ic6d18fbc01fb9cc899a9bd2d7424cd2edae487f1
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:51 +02:00
Nikolai Kosjar
57ff992961 C++/CppTools: Pass UTF-8 encoded source to Lexer
The Lexer can handle it now.

Task-number: QTCREATORBUG-7356
Change-Id: I8c4b03a247656e013d44c3cedca4835e133d4036
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:41 +02:00
Nikolai Kosjar
70122b3061 C++: Support for UTF-8 in the lexer
This will save us toLatin1() conversations in CppTools (which already
holds UTF-8 encoded QByteArrays) and thus loss of information (see
QTCREATORBUG-7356). It also gives us support for non-latin1 identifiers.

API-wise the following functions are added to Token. In follow-up
patches these will become handy in combination with QStrings.
    utf16chars() - aequivalent of bytes()
    utf16charsBegin() - aequivalent of bytesBegin()
    utf16charsEnd() - aequivalent of bytesEnd()

Next steps:
 * Adapt functions from TranslationUnit. They should work with utf16
   chars in order to calculate lines and columns correctly also for
   UTF-8 multi-byte code points.
 * Adapt the higher level clients:
    * Cpp{Tools,Editor} should expect UTF-8 encoded Literals.
    * Cpp{Tools,Editor}: When dealing with identifiers on the
      QString/QTextDocument layer, code points
      represendet by two QChars need to be respected, too.
 * Ensure Macro::offsets() and Document::MacroUse::{begin,end}() report
   offsets usable in CppEditor/CppTools.

Addresses QTCREATORBUG-7356.

Change-Id: I0791b5236be8215d24fb8e38a1f7cb0d279454c0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:15 +02:00
Erik Verbruggen
ee200a7be0 C++: fix follow-symbol-under-cursor for #import <xyz>
Task-number: QTCREATORBUG-12254
Change-Id: I4179c78f3ce6bf2236f8375da1765122a974118c
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-22 13:11:41 +02:00
Orgad Shaneh
e23dbb4c65 C++: Pass some values by reference
Change-Id: If2829e9ec5f796714bf3906c17c4c654cdfc4dea
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-21 15:55:24 +02:00
Orgad Shaneh
804eb7178a C++: Avoid repetitive calls
Change-Id: I6f04b98c14567d344907ac635df7eeee2f7aeac7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-21 15:44:32 +02:00
Orgad Shaneh
480e8134e9 C++: Remove unused loop
Change-Id: I107c09bce86219476fab034b133b54f83170c17f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-21 15:44:07 +02:00
Nikolai Kosjar
126e69137a C++: Clarify units of a Token
This will avoid confusion when later more length and indices methods are
added.

In Token:
    length() --> bytes()
    begin() --> bytesBegin()
    end() --> bytesEnd()

Change-Id: I244c69b022e239ee762b4114559e707f93ff344f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 15:55:38 +02:00
Nikolai Kosjar
ba76baa65f C++: Use getter functions of Token
They are already inlined. Now it's easier to find read-only accesses.

Change-Id: I9aaeca3bc5860e3a20a536a2484925e4334c005f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 15:55:11 +02:00
Nikolai Kosjar
a9c15c0bf5 C++: Remove Lexer::{tokenOffset(),tokenLength()}
The necessary data can be retrieved by the resulting Token.

Change-Id: I79afb23183c156240c690beff30bb11dfe943e61
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 14:48:03 +02:00
Nikolai Kosjar
d84bd0b359 C++: Remove unused functions in Document::Block
Change-Id: I7049388d970c2c1454a95f0a0df6cfd8f5a960a8
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 14:47:20 +02:00
Alessandro Portale
551f7e1caf QString(QLatin1String()) -> QString::fromLatin1()
Change-Id: I93bdd926ca1c7a37a298335711069d985f1f91dd
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-05-09 09:03:19 +02:00
Eike Ziller
8c1c106a4f Merge remote-tracking branch 'origin/3.1' 2014-04-14 16:53:23 +02:00
Nikolai Kosjar
697ec70037 Revert "C++: nested class with enclosing template class"
This reverts commit 5d76b4339a since it
might lead to an infinite loop.

Task-number: QTCREATORBUG-11999
Change-Id: I12c7f3afc4aa53a83ddc2bf2d33eb76c29b747ee
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2014-04-09 17:32:04 +02:00