Commit Graph

135 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
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
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
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
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
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
4cdb5bab15 Clang: Add clang refactoring
Change-Id: I2e3f36f810276da3f8dc7dcc587b06f8edb586d3
GPush-Base: d02f51b48fc752fddcdef6dcb32b3f7f6c0195a3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-08-04 14:37:19 +00:00
Eike Ziller
69fa7a8ffb Merge remote-tracking branch 'origin/4.0' into 4.1
Conflicts:
	src/plugins/projectexplorer/runconfiguration.h
	tests/unit/unittest/unittest.pro

Change-Id: I3d327b1198df2a7e9268916af9624ce5d21195df
2016-06-28 11:42:03 +02:00
Nikolai Kosjar
05c1efd8ef Clang: Fix dot-arrow-correction for not-yet-parsed unsaved content
The issue was re-producible with e.g.:

    void g()
    {
        // Type 'foo.' as fast as possible in the next line

    }

This led to "foo->" with completion results as if there was no "foo." at
all in that line.

We relied on a correct position for
translationUnit.sourceLocationAtWithoutReparsing(), but the just typed
characters were not yet reparsed. And we do not want to reparse at that
point since takes too long. We already determine the utf8 position for
the dot character, so simply use that instead.

This completes commit 17c1325cc4.

Change-Id: I669888b5c17ee63b2aec7b16c9921f9d79e281f9
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-24 08:31:28 +00:00
Nikolai Kosjar
b032038781 Clang: Tests: Use test data working with clang 3.6 *and* clang 3.8
The test data produces different results when it is run with libclang
3.6 and libclang 3.8. (lib)clang 3.8 will generate an error instead of a
warning and suppress further diagnostics. See below.

Use simpler test data that is agnostic to the different clang versions.

$ cat input.cpp
    class X {
	X(X&&) noexcept;
    };

    X::X(X&&) = default;

    int function()
    {
    }

$ clang++-3.6 -fsyntax-only -std=c++11 input.cpp
    input.cpp:5:4: warning: 'X' is missing exception specification 'noexcept'
    X::X(X&&) = default;
       ^
	      noexcept
    input.cpp:2:5: note: previous declaration is here
	X(X&&) noexcept;
	^
    input.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
    2 warnings generated.

$ clang++-3.8 -fsyntax-only -std=c++11 input.cpp
    input.cpp:5:4: error: 'X' is missing exception specification 'noexcept'
    X::X(X&&) = default;
       ^
	      noexcept
    input.cpp:2:5: note: previous declaration is here
	X(X&&) noexcept;
	^
    1 error generated.

Change-Id: I6d786a8b87eb4438fa8db36540db9358181b9a5b
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-22 12:39:39 +00:00
Eike Ziller
9e66ce48e4 Merge remote-tracking branch 'origin/4.0'
Conflicts:
	src/plugins/autotest/testcodeparser.cpp
	src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri
	tests/unit/unittest/unittest.pro

Change-Id: I9db4fbea6ea7c9fdd0d8e1703735af20c92e754b
2016-05-09 16:37:41 +02:00
Nikolai Kosjar
17c1325cc4 Clang: Fix dot to arrow correction
The position of the dot character was determined on an outdated
translation unit.

We queried the translation unit for the source location of the dot
character, but apparently clang_codeCompleteAt() does not update the
source locations for the translation unit. And we do not want to reparse
since this is expensive. Thus, determine the byte position manually by
scanning over the document until the right line/column is reached.

Change-Id: I25e256bb81a83bb71c7e46a0fb3e927bf4031b16
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-05-03 12:19:13 +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
Marco Bubke
2349b13ae5 Clang: Rename HighlightingInformation to HighlightingMark
Change-Id: I3954c7c9abe593ea04092337f48ac2b153e883ba
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-03-07 12:06:40 +00:00
Orgad Shaneh
0c575700cb Clang: Fix highlighting of variables in lambda capture
void func() {
    const int var = 42;
    auto lambda = [var](int input) { // var is not highlighted
        return var + input;
    };
}

Change-Id: I95a5732ab8391e1232894e419b081c729e2d1ba1
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-02-22 15:38:42 +00:00
Nikolai Kosjar
57877cc14d Clang: Workaround dot detection for arrow correction
...by explicitly checking for the dot in the source.

Task-number: QTCREATORBUG-15654
Change-Id: I4172e88a7fbb3015ef391daf13ded1f0002aab9c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-02-01 12:20:58 +00:00
Tobias Hunger
954569387c Update License according to agreement with Free Qt Foundation
* Update license information in tests directory

Change-Id: I311441dd37d053ca3175e44b284258e232ee93e0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 16:01:06 +00:00
Nikolai Kosjar
8d6549fa74 Clang: Correct member access operator if possible
1 struct Foo { int member; };
 2 void f(Foo *foo)
 3 {
 4     foo.<REQUEST COMPLETION> // correct '.' to '->' and provide results
 5 }

The preferred approach would be to check if "foo" in line 4 is of
pointer type, but there is no suitable cursor (only CompoundStmt) at
that position since the code is usually not yet parsed and thus invalid.

Thus, just run the completion as is. If there are not any results for a
dot completion, re-run the completion with "." exchanged by "->". This
approach is inherently slower than the preferred approach implemented in
the built-in code model.

The following rare cases are not handled:

 1) Requesting completion after white space:
      Works: foo.<COMPLETE HERE>
      Fails: foo. <COMPLETE HERE>

 2) Opening a file and requesting completion (ctrl+space) without prior
    editing. No editing before triggering completion means that no
    unsaved file is generated on the backend side, which is a
    requirement for the correction.

Task-number: QTCREATORBUG-11581
Change-Id: I6bc8e8594778774ab342755fdb01a8a3e5c52ba0
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-01-19 13:20:35 +00:00
Oswald Buddenhagen
5a7d3e78db Merge remote-tracking branch 'origin/3.6'
Conflicts:
	qtcreator.pri
	qtcreator.qbs

Change-Id: Ifbe181e86c161e082cc9a69a4bc7bd399f34ff47
2016-01-04 14:11:07 +01:00
Marco Bubke
18fa35c152 Clang: Fix highlighting for using a namespaced type
using NameSpace::StructInNameSpace;

Task-number: QTCREATORBUG-15271
Change-Id: I17a3ad1e1eed7a820ed7dead5d15a3de760c135f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-12-16 15:28:27 +00:00
Nikolai Kosjar
86f3194cc1 Clang: Add disabled test ArgumentToUserDefinedIndexOperator
It looks like there is no way to mark a test as expected to fail, so
disable it.

Task-number: QTCREATORBUG-15473
Change-Id: Ic6cb2c00a64cf647cb499492064d451d0dd08075
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-16 15:21:21 +00:00
Nikolai Kosjar
0af0bd8e36 Clang: Show type icon for usings/typedefs
...in the completion widget.

Task-number: QTCREATORBUG-15078
Change-Id: I1309b628e1f060fa68bdcf13838037728207b035
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-08 13:05:02 +00:00
Marco Bubke
c209aaf22e Clang: Fix highlighting issues
...for macros, typedefs and enums.
	
Change-Id: I926e7238695caefd7f4463dbe0cf5b428aa98c1a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-12-07 08:41:03 +00:00
Marco Bubke
2e499b73d6 Clang: Filter scope operators
Scope operators are not really user defined.

Change-Id: I1ab08dc3db7c39b98da02b6ef10bf78b75a6856d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-25 14:18:42 +00:00
Marco Bubke
bcd93b594e Clang: Extract highlighting information
Prepare the move of the semantic highlighting to the clang back end. We
have it under tests too so it should be quite easy to make changes or
corrections.

Change-Id: I5706a8a06fde5a9ba2eba3a8ba62782102ac0bd3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-17 12:41:37 +00:00
Nikolai Kosjar
f7741ef63c Clang: Report only diagnostics that can be shown in the editor
Change-Id: I9c258159d240c6ba7eeff34702d8512d9220b3af
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-16 14:18:37 +00:00
Nikolai Kosjar
08fcb7f317 Clang: Filter out invalid diagnostic ranges
Apparently libclang might return invalid ranges.

Now we discard the invalid ranges. Since there is a diagnostic location
(in addition to ranges) the editor will still display an indication for
the user.

Task-number: QTCREATORBUG-15272
Change-Id: I351e136b9925a53fb2273a394e17873c5533798d
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-06 11:33:12 +00:00
Nikolai Kosjar
f1300df6b3 Strip BOM from files
Change-Id: I9167c016760fe1e8378cdf84144c4bed5cd4e57c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-10-01 10:51:10 +00:00
Nikolai Kosjar
a7928b4b0b Clang: Integrate clang's fixits as refactoring actions
They are invokable by the usual means (Alt+Enter, editor's context menu
> Refactor) plus by the context menu of the editor's left margin for the
related line.

The fixit text comes directly from libclang and is thus not translated.
We modify the text slighty by stripping the diagnostic category prefix
("note:", "error:", ...) and capitalizing the first letter.

A follow-up change should properly indicate available refactorings with
a refactoring icon in the editor's left margin.

Task-number: QTCREATORBUG-14868
Change-Id: I86157c9f824d2a9dedf19087476d02ad1e6cc854
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-09-29 11:39:21 +00:00
Nikolai Kosjar
de6d7f0617 Clang: Refactor handling of diagnostics
...by introducing ClangDiagnosticManager and the helper class
ClangDiagnosticFilter.

ClangDiagnosticManager will get more state in a follow-up change.

Change-Id: Id2c312bc897ea41ed67292b56b24dcfb7975ff4a
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-09-29 11:38:53 +00:00
Marco Bubke
f2b7371af1 Clang: Reparse only if files are changed
Includes are now watched by a file watcher. Unsaved file changes are
watched too. If they are changed the translation units which depend on
them are set to a state which require a reparse. Later the diagnostics
of this units are collected and send back to creator.

Change-Id: I2fb5c7dd6644687f22399edd8d18edd6215c9505
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 15:00:07 +00:00
Marco Bubke
aa6aaee510 Clang: Add brief comment support
Change-Id: I5af23b6694d3d0bf45ed0a30b4d91b350f0515df
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 14:59:50 +00:00
Marco Bubke
b278dc87ca Clang: Add diagnostics
Diagnostics are now moved to the clang backend process. Fixits are
supported too.

Change-Id: I20faacf466bbf78dec479220c3d7b336a47bc453
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 14:59:16 +00:00
Marco Bubke
0fd213357e Clang: Tests for code completion
Reparsing in Clang is broken in master. We need to test what is working
in which version.

Change-Id: I620acd4a0a5adc951951e0fc3c0a4096ac9844fe
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-04 16:16:45 +00:00
Marco Bubke
1402c067b1 Clang: Rename CodeModelBackEnd in ClangBackEnd
Change-Id: I13e8a458634110456375956d4d4da7239c86957f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-16 13:29:27 +00:00