Commit Graph

853 Commits

Author SHA1 Message Date
Marco Bubke
9dfa210011 Clang: Partial fix for highlighting off output arguments
We get the source range for the parameter list and not the arguments
in the initializer list back. So we have to disable the test case.

Task-number: QTCREATORBUG-17101
Change-Id: I65ec6d111766b5728a951b024576cbf777c89728
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-11-24 16:54:01 +00:00
Marco Bubke
03bbd88eb1 Clang: Fix highlighting of instance with member for writable arguments
struct X
{
  int member;
};


void f(int &argument);

void foo()
{
  X x;

  f(x.member);
}

Task-number: QTCREATORBUG-17101
Change-Id: I6746122dbe86d032b3797a01b5f2257846007f94
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-11-23 15:22:50 +00:00
Marco Bubke
b196368785 Clang: Add disabled test case for HighlightingMarks
Constructors are not recognized by libClang as callable expressions.

Task-number: QTCREATORBUG-17101
Change-Id: I40eb46c07475e3b2e48bc8117de073732005f8b9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-11-23 14:47:33 +00:00
Tim Jenssen
6fe90532dc Utils: Add offset to search results
Offset are better to compute the length of a text range. The only problem
is that we get them for utf8 because that is the text representation of
source file. QTextDocument is Utf16 based, so it can not binary represent
the source file. Actually I do not see a simple performing workaround for
it.

Change-Id: Id615e1ee6a6e85c6ecc4f8044e275142409d9b46
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-23 12:33:34 +00:00
Tim Jenssen
7f757884c5 Clang: Extend clang query
It's a first step to introduce clang query.

Change-Id: I4d001a8883f56066765ce6bc561fa3f49611c0a4
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-23 12:16:04 +00:00
Nikolai Kosjar
c4d9f6ac3f Clang: Fix updating dependencies
...if the registered document comes with unsaved content.

This can easily happen if the document is opened and modified by a
refactoring action.

Task-number: QTCREATORBUG-17295
Change-Id: I3a95fb495b6122248ceaa80985e838851ba2c0e5
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-11-23 11:50:44 +00:00
Orgad Shaneh
6d1d1a4416 Merge remote-tracking branch 'origin/4.2'
Change-Id: I957c22020fbacb2f631220b0cdc7fa16a782798b
2016-11-21 10:25:45 +02:00
Nikolai Kosjar
da54b1e6a9 Clang: Tests: Fix compilation
refactoringclient-test.cpp:126:76: error: no matching function for call to
'ClangRefactoring::RefactoringCompilerOptionsBuilder::build(CppTools::ProjectPart*,
CppTools::ProjectFile::Kind&)'

Broke with:

    commit 36d4d01cd3
    Clang: Take precompiled headers into account when parsing source files

Change-Id: I7c5a2edec0859584ea2b33e144178060788cd4d9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-11-17 15:35:22 +00:00
Marco Bubke
19a00f418f Utils: Add const reverse iterators to SmallString
Change-Id: Iefd9d6abafbe38dcb7d3ed9ea200ac3244902433
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-17 15:06:46 +00:00
Marco Bubke
8a16151601 UnitTests: Add QByteArray printer
Change-Id: I1461db8b5337e6e6aa387edc4da72ca3379d8b73
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-17 15:06:31 +00:00
Eike Ziller
4026864f38 Merge remote-tracking branch 'origin/4.2'
Conflicts:
	src/plugins/clangrefactoring/refactoringengine.cpp
	src/tools/clangrefactoringbackend/source/symbolfinder.cpp

Change-Id: I7c1c87f3b8ade43a07f6668565501042e967fa8b
2016-11-16 16:04:59 +01:00
Tim Jenssen
9c7ff5199f Clang: Add clang query
Clang query is mechanism to use AST matcher to search for code. Think
about regular expression but in the context of AST. So you get a semantic
search tool for C++.

Change-Id: I72e882c5b53a0c52f352a3664847c4c3e4f6fc2e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-15 15:30:33 +00:00
Kai Koehne
e5becbdfb9 Replace WIN32 define with _WIN32
Only MinGW gcc defines WIN32, MSVC compiler does not. It's
also defined by qmake (msvc-desktop.conf), but not by qbs ...

Let's just use _WIN32, that's defined everywhere.

Change-Id: I8342a70498be54a965dcf7fae63eaf406aaa3c04
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-14 10:36:31 +00:00
Tim Jenssen
7b70c30750 Utils: fix that utils can be used in tests
Change-Id: I1f530f3f63e22719de6faed7f55c66282d4044e8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-11-02 12:25:20 +00:00
Orgad Shaneh
2ef3a44fdc Revert "Tests: add utils dependency"
It breaks compilation (at least on linux).

Anyway, HostOsInfo::isWindowsHost is header-only, and should not require
this dependency.

This reverts commit e3a2f3c796.

Change-Id: I8bd86d978742bdb7db3d9f8d429a4803be22a779
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-02 11:16:33 +00:00
Tim Jenssen
cb3064a09e Clang: use a pri file to set clang defines
Change-Id: I52167ab3ce480c795cb0f0bcd749f97b34db86d3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-11-01 14:14:40 +00:00
Tim Jenssen
e3a2f3c796 Tests: add utils dependency
Broke ConnectionClient compile which is using
isWindowsHost of utils.

Change-Id: I376efd5234a86de07764495af9a772b0810aaee7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-11-01 13:25:47 +00:00
Marco Bubke
aa97e29920 Clang: Add ostream for clang::StringRef
Change-Id: Ibafb1c179fcc49f1df330537ad6dc9addba5618d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-10-31 14:23:44 +00:00
Nikolai Kosjar
4fbdbdb1ee Clang: Fix delayed reparse of dirty and visible but not current documents
1. Open document foo.h
2. Create a split and open foo.cpp (#including "foo.h")
3. Edit foo.h (e.g. by introducing a syntax error, so that foo.cpp will
   indicate header errors in the toolbar or as info bar)
=> Actual: foo.cpp will be reparsed immediately.
 Expected: foo.cpp should be reparsed after a delay.

This saves resources (cpu time) and minimizes poping up of the header
info bar while editing header files in splits.

Regression introduced by

    commit 380d756a03
    Clang: Hook up supportive translation unit on first edit

Change-Id: Ib5fd90e49415dfc3aefacab7cd627b0e1937f5fc
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-18 11:39:01 +00:00
Marco Bubke
d6858b2f9f Clang: Fix unused warning
Change-Id: I1ed0698eb9ea2d73e4ccc6540121610b30d5f646
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-10-12 11:25:36 +00:00
Marco Bubke
63ae993bf2 Clang: Add output argument highlighting
This adds a mix-in for writable functions arguments.

Change-Id: I758f7fef77d992ea25395db550571ccb081fd5fd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-10-12 08:01:48 +00:00
Nikolai Kosjar
9d55d8485c Clang: Show info bar for parse errors in header files
...because those errors can lead to a substantial performance/functional
regression.

The actual diagnostics (possibly with children) are shown as details in
the info bar.

The info bar can be hidden with the "Do Not Show Again" button.
Re-enabling the info bar is possible with the new editor tool bar
button.

Change-Id: I03394ff8e3c84127946b0b791930b28a385f5a46
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-11 14:01:14 +00:00
Marco Bubke
eb55c1a4e4 Clang: Fix highlightingmarks include test
Change-Id: I3e3f34a7155149a4a12fb8cea3102aba10bb5fc7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-10-11 10:55:01 +00:00
Nikolai Kosjar
bf5c1cc4fb Clang: Avoid duplicate jobs without changes in-between
This could happen, e.g. with this message order:

  >>> updateTranslationUnitsForEditor()
  add job<1>
  run job<1>
  >>> updateVisibleTranslationUnits(Utf8String(), {})
  >>> updateVisibleTranslationUnits(path, {path})
  add job<2>
  finish job<1>
  run job<2> -- Ops, nothing is changed but job<2> is started

This led to an outdated translation unit (e.g. wrong highlighting).

Now JobQueue checks for duplicates in the queue and checks all the
currently running jobs.

Change-Id: I05843fddcbd21ce0489681c283227c0027ded428
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:37:20 +00:00
Nikolai Kosjar
380d756a03 Clang: Hook up supportive translation unit on first edit
Parsing happens rotationally on the translation units.

The recently parsed translation unit is used for completion jobs while
the older version is used for parse jobs.

Advantages:
  A1. A completion job cannot be blocked anymore by currently running
      parse job.
  A2. Faster triggering of parse jobs. A reparse was triggered about
      1650ms after the last keystroke. This is down to 500ms now since we
      do not have a blocking translation unit for the completion anymore.

Disadvantages:
  D1. Memory consumption is doubled for an edited document.
      This could be addressed by suspending the second translation unit
      after some time of inactivity.
  D2. Setup of the supportive translation unit takes some time.

Change-Id: I958c883c01f274530f5482c788c15cd38d6f4c3e
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:36:59 +00:00
Nikolai Kosjar
a85d5c7222 Clang: Return updated documents
Change-Id: Id4b1267914019ac56cdd132c6d597167a1f2b9a9
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:36:48 +00:00
Nikolai Kosjar
c8cec2dd0d Clang: Base JobQueue on translation unit
This enables a job per translation unit instead of per document.

This does not change any behavior yet.

Change-Id: Iafb8dab5da32b53dbb3010c16241bf89cbb81b38
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:36:33 +00:00
Nikolai Kosjar
8d443b40b7 Clang: Extract long clock/time_point references
Change-Id: If2790263e9a314f27762c57cf6bf4ef67f93a84b
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:36:24 +00:00
Nikolai Kosjar
1a426d9f01 Clang: Support second translation unit
A TranslationUnit is owned by TranslationUnits now. TranslationUnits
allows to add another TranslationUnit and to update/query the recently
and previously parsed translation unit.

This does not change any behavior yet.

Change-Id: I8a2f0cc05d3e51bf739dd5d7c4da14b54147f3ab
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:35:48 +00:00
Nikolai Kosjar
c12d01fb41 Clang: Add job queue for each document
...in preparation for follow-up changes. This will enable e.g. a timer
per document.

This does not change any behavior yet.

Change-Id: Ic1dc06de602373c666d47ce7a95ab99e56d389d5
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:35:35 +00:00
Nikolai Kosjar
ae92b68154 Clang: Remove some needless bools
Change-Id: Ia845c803fce85ad0e29e2cf6b64820b86599bac6
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-05 07:25:45 +00:00
Marco Bubke
381bee1434 Clang: fix llvm lib linking on windows
If we use paths with spaces we cannot split them anymore so we have to
handle unix and windows differently.

Change-Id: Ibfc8c51cfe2ecd68e913ad84e0e1269eb7eeda02
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-09-19 15:27:25 +00:00
Marco Bubke
47c01daeb2 UnitTest: Cleanup
Improve naming and introduce googletest.h.

Change-Id: I445c13db4c23d6dd5682ce0db3b83055cc6b8a89
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-09-19 15:17:54 +00:00
Nikolai Kosjar
cb0e730bb5 Clang: Clean up exceptions
* Extract common stuff into the base class ClangException
* Remove unused exceptions TranslationUnitParseErrorException and
  TranslationUnitReparseErrorException
* Do not send error messages to the Qt Creator side. The messages were
  only generated when the backend crashed and while it was not yet fully
  re-initialized (e.g. do code completion right after crash where the
  document was not yet registered at the backend).

Change-Id: I91d98d5ef681ad487f7a2fd66f78fa7cd1e958df
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-14 13:08:08 +00:00
Nikolai Kosjar
26cb17bb65 Clang: More renaming fixes
Change-Id: If796869b26fc6faf5919041368fb26e8a42ae8a2
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-14 13:08:04 +00:00
Nikolai Kosjar
9606988989 Clang: Move exception classes into single header/source unit
Change-Id: I60b4ce61e46d6f4ba87a2be49e6bbc219508c471
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-14 13:07:56 +00:00
Nikolai Kosjar
985e4436f2 Clang: Rename TranslationUnitCore to TranslationUnit
Change-Id: I03a59ae5d5073c812ad40c7623cfb1fdb80aad80
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-07 13:36:43 +00:00
Nikolai Kosjar
14b27183ce Clang: Rename TranslationUnit(s) to Document(s)
The "TranslationUnit parts" moved already to TranslationUnitCore.

Change-Id: I2bea7847e2b3e84fbfacc3d2dc43f180873349ac
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-07 12:36:19 +00:00
Marco Bubke
2e062552eb Clang: Report an error if the unit test are linked with LLVM without RTTI
We don't want to disable RTTI in unittest so we require to compile them
with RTTI. You can disable yourself RTTI if you don't want them for some
reasons.

Change-Id: I76d05a36442305f379ce3d88b3f6ed4372127002
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-09-05 10:01:14 +00:00
Nikolai Kosjar
435d631266 Clang: Fixes for unittest.pro
Change-Id: I356ccdec0eaa403e5ec7364fb54de39f24695b4b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-08-31 13:43:05 +00:00
Marco Bubke
68aeff4b9f UnitTest: Break the dependency to LLVM
If you have no LLVM installed it was impossible to compile the unit test.
But some unit test don't depend on LLVM. With this change it is now
possible to compile them.

Change-Id: Iac0c1b3cdf6c317e6ba4755acd5f8458db5a7451
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-08-22 09:12:56 +00:00
Marco Bubke
d23c4985cb Utils: Fix unittest
Prevent operator selection to be ambiguous.

Change-Id: I1ff0d6aad8fe5ce24b0d1038c1b6121a595800fe
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-08-22 09:12:35 +00:00
Nikolai Kosjar
4372514e6b Clang: Remove unused arguments
Change-Id: I72e6df2e0e5b94addbca79bbca6bf2aa7cff2042
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-08-22 07:02:26 +00:00
Marco Bubke
678e6e4ddf Clang: Fix CodeCompletionsExtractor test crash
CXCodeComplete_IncludeBriefComments has to used if the translation unit
is using it too. Otherwise an assert is triggered.

Change-Id: Ia252ffd9c440144f21c2354c6885f7ae73de4b29
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-08-18 13:06:17 +00:00
Orgad Shaneh
c9956b9e05 Revert required C++ version to 11
It was bumped to 14 in merge commit 1853f01a, due to a conflict in
unittest.pro which I confused with qtcreator.pri.

Change-Id: I1ec15d9d20d90c38849eea799a724f4c85fe36b5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-08-15 09:45:46 +00:00
Marco Bubke
092df2edaa Clang: Smallstring should not depend on std::ostream
We move the io operators in an extra header file because if we would
include ostream in smallstring.h we would blow the compile time.

Change-Id: Iea61ceedbbbcdd2adc6dc149794dab6e743084f8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 15:01:53 +00:00
Marco Bubke
f56ec53fa1 Clang: Test for file path RequestSourceLocationsForRenamingMessage
Change-Id: Ia384deb60e644d8894d7c56f81b3deb8b7706c11
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 14:19:02 +00:00
Marco Bubke
98a167c0d5 Clang: Fix template renaming
Change-Id: I8040fe8dfc99d66e242ce2ff8589aa914838bfc9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 13:50:25 +00:00
Marco Bubke
ec06fd0e84 Clang: Use std::replace instead of std::transform
Change-Id: I60e42577631dee5cf05b1129a49ea36c391e8923
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-08 13:27:38 +00:00
Orgad Shaneh
1853f01a5b Merge remote-tracking branch 'origin/4.1'
Change-Id: Ia442f30f387fe9292217582260bbe79e54608810
2016-08-05 11:40:07 +02:00