Commit Graph

301 Commits

Author SHA1 Message Date
Tim Jenssen
dae4477cd3 Clang: Make file ids unique
Clang file ids are only unique for one query. Because we query in parallel
we have to manage our own unique ids.

Change-Id: I67d57d8b1766cab75ad252a14e57bbf9dc5fdb79
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-07-03 09:27:05 +00:00
Nikolai Kosjar
202d4a52a0 Clang: Fix build with QTC_NO_CLANG_LIBTOOLING
...caused by

  commit f5d68398d5
  Clang: Fix canceling of clang query

Change-Id: Ic48485aed1d23e1ddd2f7bc1e37a797d2c2498c6
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-06-29 09:00:07 +00:00
Marco Bubke
f5d68398d5 Clang: Fix canceling of clang query
Every AST unit is created and queried asynchronously, like before, but
we don't wait anymore but use a timer to process new sources. So the server
will not be blocked and can process other messages like cancel.

Change-Id: If0e69466c78f628190f59fd32a03cab1c3a4d0a3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-06-28 09:15:51 +00:00
Orgad Shaneh
2c55c10cac Clang: Adapt unit tests to clang-5.0
Disable the tests on clang-3.x.

Change-Id: I80a8840c25e55785034abf7b5964a14afb01d9e7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-23 14:49:18 +00:00
Nikolai Kosjar
4a6057357b Clang: Do not gray out e.g. #endif
Task-number: QTCREATORBUG-18389
Change-Id: I8b0067f3860a0e0e09360da5989011e69adddce0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-19 13:27:00 +00:00
Nikolai Kosjar
b869f02f72 Clang: Introduce headers for client/server messages
This reduces the overhead when a new message needs to be added.

Change-Id: I5bb2833af2f06f2a8e101cfb03f75ffc2927bf68
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-19 11:08:39 +00:00
Nikolai Kosjar
1623af0da5 Clang: Add a disabled test for highlighting
In the example below, "var" is highlighted as a function, but it should
be highlighted as a local variable.

  struct OtherOperator { void operator()(int); };
  void g(OtherOperator o, int var)
  {
      o(var);
  }

This is due to a libclang bug.

Change-Id: I7c9fcad6f16c25191d31fc330e969ebd282d4869
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-06-16 06:09:19 +00:00
Nikolai Kosjar
cde8738269 Clang: Remove pointless call in tests
It was added only for debugging.

Change-Id: I7ea80d8d472f319cdcac548d3abf602e0f304fc9
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-06-16 06:08:58 +00:00
Nikolai Kosjar
a570614f3c Clang: Fix test file name
Change-Id: I27b25e4b8521aabab804812c4cc27cd41c23b46e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-15 08:00:34 +00:00
Nikolai Kosjar
f9f10a1e32 Clang: Fix conversion warning in tests
mock-matchers.h:204:60: warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
   bool operator()(const A& a, const B& b) const { return a == b; }
                                                             ~~^~~~

Change-Id: I58883118e1eb42f2e0129b760cdce07daf4ac8d3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2017-06-14 14:16:12 +00:00
Marco Bubke
ae485ac551 Clang: Return ClangString instead of Utf8String
Utf8String is allocating memory but for many compares it is not needed.
In an inner loop this can be expensive.

Change-Id: I6320823ab7e086008447eea255e52859a7faaad7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-14 14:04:49 +00:00
Ivan Donchevskii
33a2288c7d Clang: Fix extra space before left paren
Do not add space before left paren in function
because it must not be there

Task-number: QTCREATORBUG-14878
Change-Id: I0fd0e650aeeee59af7bbc157c2fae652109763bc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-14 13:06:47 +00:00
Nikolai Kosjar
ca72c29462 Clang: Provide highlighting for identifier under cursor
Change-Id: I80ffe23cbcc84ab7323124581d9dd6afbe974fd0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:49:05 +00:00
Nikolai Kosjar
cd6bd3c4d8 Clang: Move completion test
Change-Id: I61cd72c131407415732ed1231a4614be57c1454b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:24:52 +00:00
Nikolai Kosjar
de5cbacae5 Clang: Rename JobRequest::Requirements to ExpirationsReasons
...to avoid ambiguity in regard to a new enum in a follow-up change.

Change-Id: I4f732b5200ed674b6708510ac8de0a795afe52da
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 11:48:54 +00:00
Marco Bubke
43d6726c70 Clang: Add equal operators for ClangString
Converting them in a Utf8String in an inner loop can be quite heavy.

Change-Id: I4f2ccde47a6e3ca08ed054462eb7772ded9e55c9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-14 10:14:07 +00:00
Nikolai Kosjar
e6bf399003 Clang: Stop highlighting keywords in preprocessor directives
Task-number: QTCREATORBUG-15516
Change-Id: I30046ae7c1a73144985639800227012bf5a4e357
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 10:00:02 +00:00
Ivan Donchevskii
9a0eca15c5 Clang: fix completion after forward-declared class
Do not complete -> and . with global completions if
foo is a ptr/ref to forward-declared class.

Change-Id: I41e6745ffb07be1d973fe6a8132824f1b3bf7fb1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-09 07:05:25 +00:00
Ivan Donchevskii
78db7d7ed2 Clang: turn off delayed template parsing
Fix templates highlight and completion on Windows
Add UI to turn on/off delayed parsing (off by default)

Task-number: QTCREATORBUG-17222
Change-Id: I0cd5e0bcfff2789cd938e4096829f777ff15957a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-08 10:53:31 +00:00
Nikolai Kosjar
a3a62e78f7 Clang: Fix highlighting of function in using declaration
Change-Id: I0f646ce22cdc95e5932650a3fb2fe34b8d4a89a3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-06-01 13:33:07 +00:00
Nikolai Kosjar
e6c8fbfd92 Clang: Fix highlighting for partial specialization
Change-Id: I53f6a87064d45a3a68394d1b3bc0d767b91a9d11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-06-01 13:33:00 +00:00
Nikolai Kosjar
1a9808d393 Clang: Remove unused functions
Change-Id: I66e990dfce5196da48cdf158cf7e5a4050565670
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-23 10:52:41 +00:00
Eike Ziller
db11c01df8 Clang: Fix highlighting of primitive types
libClang categorizes these as keywords, so we need to check
if a keyword is actually a primitive type, and use that.

Task-number: QTCREATORBUG-17867
Change-Id: I354bb0422505ed7732a0799d9c86d3acfdeb0785
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-05-23 08:41:42 +00:00
Nikolai Kosjar
64ec695566 Clang: Show function signature hint for constructors and functors
For "foo(|" [1] we requested a completion from libclang with the cursor
position just before "foo" and then filtered the function declarations
for functions matching the name "foo". This worked fine for ordinary
functions, but obviously not for constructors and functors.

Recent versions of libclang support proper function call completion with
XCursor_OverloadCandidate, so make use of that.

[1] '|' represents the cursor position

Task-number: QTCREATORBUG-14882
Task-number: QTCREATORBUG-14884
Change-Id: I9d31b3960ccff6a8b9440dbcb7ff9f5ca9f61266
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-05-11 11:54:09 +00:00
Nikolai Kosjar
c1d7f4091e Clang: Rename/remove projectPartId
Change-Id: I91e95acd37152eda4e25c0b8abf46d36523fd2b9
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-05 12:11:01 +00:00
Nikolai Kosjar
cf0e3f2db3 Clang: Fix updating supportive translation unit
...with new project arguments.

Reproduce with:
 1. Open a file with some #ifdef
 2. Edit the file, e.g. type space.
 3. Change the build configuration so that the highlighting flips in the
    editor.
 4. Edit the file again, the configuration flips again [repeat].

Change-Id: Ib97c18fc46538d74c63972e682a348ae2736a4e6
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-05 12:10:56 +00:00
Nikolai Kosjar
ac59e2be40 Clang: Move createJobRequest into Jobs
This simplifies the high level client ClangCodeModelServer and removes
quite some duplication in tests.

Change-Id: I4c6ab8646c8728990ebaca2b920ae514e949c54a
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-05 10:39:39 +00:00
Nikolai Kosjar
b9c76d5218 Clang: Rename reparseNeeded to isDirty
...because the flag can be set for needed parses, too.

Change-Id: I8b328afefb282cb6bd1cf88711af3d08a56808db
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-05 08:18:08 +00:00
Nikolai Kosjar
e811ac4bfe Clang: Use class enum in Document
Change-Id: I754eaf185d10b61db5bd5f622d1912c53f71e79b
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-05 08:17:58 +00:00
Nikolai Kosjar
0e5fdb7fe3 Clang: Tests: Clean up CompletionChunksToTextConverter
* Remove pointless declarations.
* Remove duplicated test.
* Fix whitespace.

Change-Id: I08102f8313b87dc87a44d96ff9c77205ccbb1a01
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-04 10:18:31 +00:00
Nikolai Kosjar
bc9afe3bbb Clang: Tests: Fix test names in ClangCompletionContextAnalyzer
Change-Id: I5a1b322957edb30cd4fe5a50deb50255da18cf8d
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-05-04 10:18:24 +00:00
Nikolai Kosjar
35c395cd13 Clang: Enable now passing tests
Looks like this was fixed in libclang in the meanwhile.

Change-Id: I51200ef7c72a01f5075d2e5d6ca6db4690dfcdd0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-23 11:13:39 +00:00
Tim Jenssen
681daa0d69 UnitTest: fix no "-fno-omit-frame-pointer" argument
Change-Id: I356fee73b2b50301d4cc857704a90c6dd2eddc18
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-03-06 09:34:29 +00:00
Tim Jenssen
dc155d0834 UnitTest: adjust to new addMimeTypes API
Change-Id: Ib1735e56ec7f56b8792dd462b88882b0324ac08b
Reviewed-by: hjk <hjk@qt.io>
2017-03-06 08:40:45 +00:00
Eike Ziller
d64e17ad55 Move mimetype definitions to plugin specs
- Avoids the hassle of QRC files and manually registering mime types
- Avoids performance regressions because of mime types that are
  registered after mime database has been used
- Makes it technically possible to detect that a disabled plugin could
  handle a mime type if it was enabled

Change-Id: I373008b1b56e9c6b4853055f20b3eeb112a6eff9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2017-02-27 13:54:59 +00:00
Tim Jenssen
2631ffabd5 Remove spaces in initializer lists
Format initializer lists code style like.

Change-Id: Ib82c235e4ba7dc75ee96a7abc0c47eff7b0a9013
Reviewed-by: hjk <hjk@qt.io>
2017-02-22 16:25:09 +00:00
Marco Bubke
a5e96dbd99 Clang: Work around missing file
We now generate an empty fake file.

Change-Id: I92fef2b24dce788c1d1b675b034d4b31346b80d9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-21 08:25:47 +00:00
Marco Bubke
537217288a Clang: Ignore CHeader
Because we don't now if a *.h file is a C or C++ header we provide both
as project file if a C and C++ file is present. But C++ is not readable
by C compiler. So we skip that files and hope there is no non referenced
C header, which is very very unlikely.

Change-Id: I5505713e759749c8a0738e11b70bb6b309412966
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-20 16:09:16 +00:00
Marco Bubke
58763aa996 Clang: Silence warnings
Change-Id: I63f8a85f0a352fc8f41835bd3ab1574255d4436b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-20 16:09:05 +00:00
Nikolai Kosjar
8c90998fff CppTools/ProjectManagers: Reduce ui blocking when loading projects
${AnyProject}::updateCppCodeModel() did two potentially not that cheap
operations in the ui thread:
 (1) Querying the MimeDatabase for the mime type for the source files of
     the project. In 99.9% of the cases no files need to be read for
     this as the file extension will resolve the type. The expensiveness
     comes from the sheer number of files that can occur.
 (2) Calling compilers with the "(sub)project's compiler command line"
     to determine the macros. While the caches avoid redundant calls,
     the number of the unique compiler calls makes this still a
     ui-freezing experience.

These two operations are moved into a worker thread. For this, the
expensive compiler calls are encapsulated in thread safe lambdas
("runners") in order to keep the "mutexed" data minimal. The original
API calls of the toolchains are implemented in terms of the runners.

While adapting the project managers, remove also the calls to
setProjectLanguage(). These are redundant because all of the project
managers already set a proper value in the constructor. Also, currently
there is no need (client) to report back detection of C sources in
project parts. This also keeps CppProjectUpdater simple.

There is still room for improvement:
 * Run the compiler calls in parallel instead of sequence.
 * Ensure that the mime type for a file is determined exactly once.

Change-Id: I2efc4e132ee88e3c8f264012ec8fafe3d86c404f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-20 09:18:13 +00:00
Marco Bubke
aba09cc115 Clang: Add test for include collector
To be secure that include is only called it the definition is true.

Change-Id: I04bae9860e64206a1c6886d7cf1682a87e9f9a07
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-16 17:39:16 +00:00
Marco Bubke
1a75db12f4 Clang: Improve speed by content generation
The argument parsing has some considerable overhead. We try to avoid that
with merging all content together in one file.

Change-Id: Icf426bb5d6a5569d59c180f94c7eab66a22a251c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-16 17:39:05 +00:00
Nikolai Kosjar
5094cfe019 UnitTest: Replace "included File" with "header"
Change-Id: I30799e116a794e041c833d76c6cd969ba1a428bf
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-14 13:48:17 +00:00
Nikolai Kosjar
da1f1326f2 UnitTests: Remove unused function
Change-Id: I580a016ec8567505374e6fc2b0ebbba454ebc192
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-14 09:47:33 +00:00
Nikolai Kosjar
340063c624 Clang: Use Utils::TemporaryDirectory
Task-number: QTCREATORBUG-17401
Change-Id: Ibf6007455ec92b1d9fcac17e1f3b5e2af21b7438
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-02-13 15:21:04 +00:00
Eike Ziller
2b94bdaa2e Tests: Fix build on macOS without command line tools installed
Overwriting QMAKE_CXXFLAGS will remove the needed isysroot flag
for finding the standard headers.
Explicitly settings the standard lib on macOS is also no longer
necessary.

Change-Id: I8a5ae5df485785b473a435c7feb9f8fb3295952b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-02-10 07:59:40 +00:00
Marco Bubke
7f8e60b289 UnitTest: Improve linking time under linux
Change-Id: Ia1f90d0ec208535a75d187875f0969bfca65b318
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-02-09 12:34:51 +00:00
Nikolai Kosjar
50a07695bd CppTools: Report also C language back to project
...for Project::setProjectLanguage().

Change-Id: I77347c4597061fb48782c629d5ad6898028fee13
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-06 14:31:49 +00:00
Marco Bubke
68afbbce75 UnitTest: Fix compilation for different configurations
Change-Id: I20d4217d1c33002f7e1ac084af4b0982b2f04971
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-02-06 10:23:29 +00:00
Nikolai Kosjar
38ba61ec4f CppEditor: Rework showing/switching parse configurations
* Move the combox box for switching the parse configurations out of the
  "Additional Preprocessor Directives" dialog ('#'-button) to make it
  better visible/accessible. Also, decouple the extra preprocessor
  directives from the concrete parse context since this is not anymore
  in same dialog.
* The combo box appears only if multiple parse configurations are
  available for a file.
* The first time multiple parse configurations are detected, an info bar
  is shown that points the user to the combox box. A "Do Not Show Again"
  button is provided.
* Upon selecting an entry, the preferred parse configuration is saved as
  part of the session. The setting can be cleared with the context menu
  entry on the combo box.

Follow-up changes need to ensure that the display name and/or tooltip is
unambiguous, e.g. for qbs and cmake projects.

Change-Id: I9e9773704187291524ad7b605bfdddd83ef5b19d
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-02-03 11:58:27 +00:00