Commit Graph

183 Commits

Author SHA1 Message Date
Christian Kamm
e85c6f4b38 C++11: Fix parsing of expressions like vector<int>{1}.
The parser considers '{' an operator and thus thought
"template-id {" couldn't possibly be valid. This patch adds
'{' as an exception to the rule.

Change-Id: I40730fcdc5cade48566b4c8b6fde390f455bbdba
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-16 20:06:58 +02:00
Eike Ziller
2786250c17 Merge remote-tracking branch 'origin/3.1'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/shared/qbs

Change-Id: Iba59e41db72e2afdf594f1f7003215d7d8d1e6d3
2014-06-13 10:51:51 +02:00
Orgad Shaneh
d0f00cc29d C++: Whitespace fixes in parser
Change-Id: I409699225b5f42db7ecb6c2dc8d150c1a66ee23c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-12 16:04:38 +02:00
Przemyslaw Gorszkowski
b90452e309 C++: fix nested anonymous with __attribute__
Task-number: QTCREATORBUG-12345
Change-Id: Ib2316ebdc81393b38185b9cb659fb85b78753e7b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-06-06 15:38:02 +02:00
Christian Kamm
eee94667e6 C++11: Fix parsing of trailing-type-specifier.
In particular "auto foo() -> typename Foo<T>::X;" didn't parse.

Change-Id: I7665c9b387e222e4107f053a529d502813ebf617
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-04 09:17:56 +02:00
Nikolai Kosjar
2e91dd1f3d C++: Fix matching NamedType
NamedType::isEqualTo() wasn't properly moved to Matcher.

In the test case, the function argument matching was failing.

Change-Id: Ia3cb82c11b039ddea61a41d9574f56d43da16ed0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-27 16:23:49 +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
558f62ec71 C++: Fix some Matcher::match() functions
...before using Matcher instead of {Type,Name}::isEqualTo().

Change-Id: Iba1c04064799fe9c81fe997dbd54fc02b15cdec7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:42:06 +02:00
Nikolai Kosjar
194591da98 C++: Fix potential null pointer dereference
Change-Id: I38d99b27ff76f44535c02c64886bede0a99c6225
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:41:42 +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
587eb49c4e C++: TranslationUnit::getPosition takes utf16char offsets
...and not byte offsets anymore. This is necessary in order to calculate
the line and column numbers correctly with respect to unicode code
points.

Change-Id: I5d79857b3eaefeb8d563b4f1e3938a64debc5e08
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:24 +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
Eike Ziller
6d1cc58697 Merge remote-tracking branch 'origin/3.1'
Conflicts:
	src/plugins/clangcodemodel/test/clangcompletion_test.cpp
	src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp
	src/plugins/projectexplorer/projectexplorer.pro
	src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
	src/plugins/vcsbase/vcsplugin.cpp
	src/shared/qbs

Change-Id: I9e5882be79ac5e8c7dfab4a57f16509d7569636a
2014-05-16 16:54:50 +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
6f63f6b647 C++: Remove unused functions in Lexer
Change-Id: I78b70eead1c64b9925272c50cc6109c5b415574d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 14:47:39 +02:00
Fawzi Mohamed
3ee6f37e4b support the latest g++ on mac
the latest g++ on mac is really clang with a compatibility frontend,
and claims to be clang and support all the features clang does
with -std=c++0x (which qmake by default passes in).
But if you link libstdc++ (again the default) then the library has
several gaps. Catch that.

Change-Id: I8387f8fdcfc7639538e576a2e93b2301e07086cd
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-13 11:23:30 +02:00
Orgad Shaneh
749e5452fc C++: Fix compilation with C++<11
and MSVC that disallows override on dtor

Change-Id: I8a8897fe1318dee0c6d9b4d5d9d515e4631f9318
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-27 20:49:51 +01:00
Erik Verbruggen
05fd47e02d Fix compilation on Ubuntu 11.10.
Cause: broken compiler.

Change-Id: Ic559ba4bbb9ddcbb1d4fbd90d0276ebacd50d039
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-03-27 16:25:31 +01:00
Erik Verbruggen
b0618281ec C++: Do type and name equality checking in a safe manner.
Change the TypeMatcher to also match names, and use two "block" lists
in SafeMatcher to prevent infinite recursion.

Task-number: QTCREATORBUG-11240
Change-Id: I0367ae795ee6be579b83aeb8d46723c877e4aa75
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-27 13:46:55 +01:00
Nikolai Kosjar
349de9331c C++: Fix weird logic in usage of TopLevelDeclarationProcessor::processDeclaration
As the name function name suggests, true should be returned if the
declaration should be processed. Otherwise false.

Change-Id: I8d266d99c579b331fee8772bde47aa1a466dae9c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-13 15:41:01 +01:00
Sergio Ahumada
c375436847 Fix some typos
Change-Id: I3be73c2a4d256a0d28e863fd2517a4d7442b34d8
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
2014-03-05 09:39:42 +01:00
Orgad Shaneh
ddab33545c Lexer: Skip also joined comments
Change-Id: Ic854958642bf1eedeb7d90ae74fb72993594b8d6
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-02-05 13:29:00 +01:00
Orgad Shaneh
e600424648 C++: Fix support for incremental input with \n
Also fix false positive line continuation on blank line

e.g.
"foo \

bar"

Change-Id: Ic6d345a4b578c955411d119b8438c8dc5065c072
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-02-04 11:33:54 +01:00
Orgad Shaneh
0f4e3c356a C++: Support multiline strings and comments
Task-number: QTCREATORBUG-662
Change-Id: I0997fe2afaba71998d5da549b7141df0c023ff12
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-21 10:54:56 +01:00
Povilas Kanapickas
9528230bd3 C++: Remove dead code in the parser
CPlusPlus::Parser::parseAccessSpecifier() is not used anywhere
throughout the QtCreator codebase.

Change-Id: I062a4ae257b9c61f02bf85079feb6d48bd07c49e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 16:30:06 +01:00
Povilas Kanapickas
3dbb1a9275 C++: Fix a typo in template declaration parser function
This is an obvious typo considering the checks at the beginning of the function.

Change-Id: I11b784153b650b02bba7bb942ca1131447a3da4a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 16:29:46 +01:00
Orgad Shaneh
a309b3cfe6 C++: Store token kind as lexer state
... when needed

Change-Id: I32a1649c87e1fa42da80eff5003b2f5714062064
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 14:11:18 +01:00
Orgad Shaneh
2216c399e5 C++: Remove unused functions in Lexer
Change-Id: I79285a9fc72f26bdfb7c1600d4e7680e02062593
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 12:29:15 +01:00
Eike Ziller
236ea9efb9 Merge remote-tracking branch 'origin/3.0'
Conflicts:
	share/qtcreator/debugger/dumper.cpp
	share/qtcreator/debugger/dumper_p.h
	share/qtcreator/debugger/test/main.cpp
	src/plugins/debugger/gdb/classicgdbengine.cpp
	src/plugins/debugger/gdb/pythongdbengine.cpp
	src/plugins/debugger/lldblib/guest/lldbengineguest.cpp
	src/plugins/debugger/lldblib/guest/lldbengineguest.h
	src/plugins/debugger/lldblib/guest/main.cpp
	src/plugins/debugger/lldblib/ipcengineguest.cpp
	src/plugins/debugger/lldblib/ipcengineguest.h
	src/plugins/debugger/lldblib/ipcenginehost.cpp
	src/plugins/debugger/lldblib/ipcenginehost.h
	src/plugins/debugger/lldblib/lldbenginehost.cpp
	src/plugins/debugger/lldblib/lldboptionspage.cpp
	src/plugins/qbsprojectmanager/qbsstep.cpp
	src/plugins/qbsprojectmanager/qbsstep.h
	src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp
	src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h
	src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
	src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h
	src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp
	src/plugins/qnx/blackberrycheckdevmodestep.cpp
	src/plugins/qtsupport/debugginghelper.cpp

Change-Id: Ie9fd0a885fb6264a6a8a72daee071b75bcbd2e9d
2014-01-08 11:01:06 +01:00
Robert Loehning
746c5d8863 Incremented year in copyright info
Change-Id: Ib5423fdd064e4546f848c0b640b0ed0514c26d3a
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2014-01-08 08:29:47 +01:00
Daniel Teske
a1c18d9e97 TypeRewriter: Handle rvalue references correctly
Task-number: QTCREATORBUG-10555
Change-Id: Icb9859f96220f613476c097b747dec8c2d1bc2ed
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-01-03 15:19:08 +01:00
Orgad Shaneh
0ce3f3e68c C++: Ignore return type on function overrides comparison
Change-Id: I9933e1cc1fb996181e818e2ea0aff76f9255f849
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-28 22:02:01 +01:00
Nikolai Kosjar
c4a0f90edd CppEditor: Introduce C++ Code Model Inspector
By default invokable via Ctrl+Shift+F12.

Change-Id: If8d61233b6d38d12131718f7c20bf40f76bc9ae4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-11 11:46:58 +01:00
Orgad Shaneh
a18b5e27a1 C++: Revive TranslationUnit::blockErrors()
Removed in f0f406ba

Required when CPLUSPLUS_NO_DEBUG_RULE is uncommented

Change-Id: I18ce50a84ed1ac4a77ca0aaa9d38ef070587ce49
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-11 11:35:03 +01:00
hjk
5c5240815a CPlusPlus: Fix parsing of ??< ??> ??( ??) trigraphs
Almost most useful feature ever.

Task-number: QTCREATORBUG-2474
Change-Id: If1ad661fab58ffb4a0b9ddb8ba771f2fde3b54ec
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-27 16:24:30 +01:00
Orgad Shaneh
eac518aee6 C++: Support __thread and thread_local
Task-number: QTCREATORBUG-7679
Change-Id: I794f52b2bcfb6c78ceef86ec53b6ed32b3d53d9f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-26 09:46:10 +01:00
Tobias Hunger
ef584f176c CPlusPlus: Use correct placeholders in printf
Change-Id: I42a41608c2f025a196e539b58c1992049f7eca35
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-18 12:24:37 +01:00
Yuchen Deng
ef1645f43f Avoid warning when compilation with MSVC2013
warning: C4005: 'va_copy' : macro redefinition

Change-Id: Ib2bfd2229cb3ae00e084dd6df7a4558a5a766d55
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-12 08:39:38 +01:00
Nikolai Kosjar
1a5c7d8ef5 C++: Safe accessing of elements of TranslationUnit::_tokens
Until now std::vector::at() was used to access the elements. This is
handy for debugging since an exception is thrown for invalid indices,
but it does not stop Qt Creator from crashing because exceptions are not
caught.

This is especially a problem for the parser, which has to look ahead via
LA(n), which accesses TranslationUnit::_tokens.

With this patch, explicit bounds checking is done before accessing the
elements and thus calls to

  std::vector::at() // bounds checking, throwing out_of_range

were replaced by calls to

  std::vector::operator[]() // no bounds checking, not throwing out_of_range

Measuring the parse time for the Qt Creator project shows that there is
no slowdown. In both cases, with and without the patch, about 15s are
needed on the authors machine.

Task-number: QTCREATORBUG-10453

Change-Id: I32b12a526ff7199bcadfc21a3deb5354063a3e3b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-10-23 10:46:14 +02:00
hjk
2b532c73ee CPlusPlus: Make (sub-)languague selection more generic
Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-10-15 16:22:28 +02:00
Nikolai Kosjar
b8dbac0b9c Rename "[Mm]ethod(s)" to "[Ff]unction(s)"
Only methods as programming functions are affected. Besides renaming
some actions like "Switch Between Function Declaration/Definition" this
mostly touches (api) code comments.

This is a follow-up patch to commit 872bfb7.

Change-Id: Icb65e8d73b59a022f8885b14df497169543a3b92
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-10-10 15:56:12 +02:00
Nikolai Kosjar
0e4deaba23 C++: Parse MEMBER in Q_PROPERTY()
MEMBER was added in Qt5.

Task-number: QTCREATORBUG-10068

Change-Id: Ic6c15a0e5ee8981ab98e4c12fc1521dc281b731f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-10-09 15:13:31 +02:00
hjk
0db5579592 CPlusPlus: Fix parsing of <: :> <% %> %: digraphs
See 2.5/2.12. Most useful feature ever.

Change-Id: I3f92256733e15078df56205dba9746ffff8ed145
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-10-07 21:06:18 +02:00
hjk
f17d9f01dc Use the canonical version of defining string literals
Change-Id: If36658de6f68f552f93830ba4f1cfa9994a2e44c
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-09-27 14:36:10 +02:00
Nikolai Kosjar
18bba097bd C++: Stricter checking in TemplateNameId::Compare
Change-Id: I96dbce004d18147fd91485b1117dc65c4bbc08a0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2013-09-13 15:41:15 +02:00
Friedemann Kleint
1901a1c7d4 Fix MSVC-64 warnings about size_t -> int truncations in C++-lib.
Change-Id: Ibe6f41ac15df1ec685b0d0766ff568abf6f3ae7e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-12 15:34:09 +02:00
Erik Verbruggen
3eaf044045 C++: replace a tree by a hash
Be more environment friendly by using less trees.

Change-Id: I54d3b23d697a3b72a6a803688a8da0eddaad3e17
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-09 15:06:51 +02:00
Christian Kandeler
72d173829c Remove superfluous include paths from project files.
A lot of our build system files specify unneeded include
paths. These roughly fall into the following categories:
    a) Paths that are already set in more general files
       such as qtcreator.pri.
    b) Paths that serve no purpose at all, possibly
       left over from earlier versions of the project.
    c) Paths that act as workarounds for wrong include
       statements of the form '#include "xyz.h"', where
       xyz.h is not in the same directory as the including
      file.
This patch removes such path specifications and fixes the offending
include statements from case c).
Tested on Linux, Windows and OSX with qmake and qbs.

Change-Id: I039a8449f8a65df0d616b4c08081145c18ae4b15
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
2013-09-02 17:28:17 +02:00