Improve type printed for template specializations with numeric
or bool values.
Code example:
template<bool B, class T> struct enable_if{};
template<class T> struct enable_if<true, T>{ typedef T type; };
In outline: "enable_if<_Tp1, T> <T>" becomes "enable_if<true, T> <T>"
TemplateArgument class holds pointer to numeric literal owned
by CppDocument, so remove Control::squeeze() to not release
numericLiterals in CppDocument::releaseSourceAndAST()
This based on TemplateArgument class introduced in commit
9ee693ee22
Change-Id: Ib787a5e402c3e8d8467b520347a26afa6087d4bd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
These changes target Find Usages feature to work with shared_ptr.
Improve libs/3rdparty/cplusplus and plugins/cplusplus:
parse __declspec() attribute,
call to variadic function template without specified template arguments,
if constexpr,
c++11 attributes [[value]],
function templates with default parameters,
resolve order for function vs template with default parameter,
template operator->() with default arguments,
template specialization with numeric values,
find best partial specialization,
fix partial specialization for non-first specialized argument
Fixes: QTCREATORBUG-7866
Fixes: QTCREATORBUG-20781
Fixes: QTCREATORBUG-22857
Fixes: QTCREATORBUG-17825
Change-Id: I31a080f7729edfb2ee9650f1aff48daeba5a673b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Nikolai Kosjar <pinaceae.pinus@gmail.com>
Fix kewordgen to generate current Keywords.cpp with minimal diff,
but also to be compatible with old usage and kwgen files.
Add new parameters:
%no-namespace-for-tokens - not use namespace for tokens
%pre-check-argument - set type and name of additional variable to use
%function-name - name of a function ("classify" by default)
%pre-check - name of a variable to check for a keyword (i.e. cxxEnabled)
Now "%%" is also used to end and restart keywords parsing to be able to
generate additional keywords for classifyOperator()
Automatically add checks for LanguageFeatures to generated code
Pass input and output files with command line arguments, print usage
Update Keywords.kwgen to include all keywords currently used
Add missing aliases to Token.h
Change-Id: I6cc84e150e0d797277204032fc05ce9cfbd01f58
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Otherwise, we trip over uses of operators from the standard
library such as std::chrono's operator"" ms(), potentially breaking
basic code navigation.
Amends 425811291d.
Fixes: QTCREATORBUG-24067
Change-Id: I3b2863ce88ee3787414e7a1acdf25f368041cdb4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
...due to uninitialized member typeId.
Fixes: QTCREATORBUG-23184
Change-Id: I00afe87b9c61a1e8edefc122b1a99635736650cb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This applies for e.g.
* "Add Definition..." (on function decl)
* "Move Definition..." (on function decl)
* "Insert Virtual Functions of Base Class" (on class specifier)
Fixes: QTCREATORBUG-11849
Fixes: QTCREATORBUG-19699
Change-Id: I0d259bc1782470f3b3f19617230005a5594a5cca
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This also means that the implicitly-declared default constructor
does the right thing now, and the generator does not have to
take care of updating it anymore.
Change-Id: Ib4de88c506839398ce77ab4eaf4680a9b7e6091e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.
The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.
Because it reduces friction further, also do it in libcplusplus.
Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
C++14 supports the use of single quotes inserted between integer digits
as a separator. Updates the built-in C++ code model to recognize such
quotes. This fixes highlighting and indentation issues.
Change-Id: Ic35ce93060b96700a11d108dce1f3cf6c4543632
Fixes: QTCREATORBUG-14939
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
3rd_cplusplus is an OBJECT library, which will end up into CPlusPlus,
which is a shared library, it's safe to set PIC to ON.
Fixes https://bugreports.qt.io/browse/QTCREATORBUG-22465
Change-Id: I6ef9bf8c73102a3a5996c0fee7b1fe25e6aa677f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Based on Tobias Hunger's work from a few months ago.
The CMake configuration needs libclang and Qt paths specified as
CMAKE_PREFIX_PATH.
Auto tests are run with "ctest". At the moment the pass rate is 87%.
Change-Id: Iba98e39bf22077d52706dce6c85986be67a6eab0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Adds the comparison of isRvalueReference to make sure they get
difference entries.
Change-Id: I294205786f3d1322e542d3b308d61ab44647ecc9
Fixes: QTCREATORBUG-13839
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
In
commit 86aab16ea4
TextEditor: Highlight punctuators as Text
the order of tokens was changed, but the corresponding "spelling table"
token_names was not adapted. As a result, e.g. Token::spell() returned
"##" for the T_PLUS token.
Fixes
FAIL! : tst_Semantic::lambda_2() Compared strings are not the same
FAIL! : tst_Semantic::enum_constantValue4() Compared strings are not the same
FAIL! : tst_Semantic::enum_constantValueNegative() Compared strings are not the same
FAIL! : tst_Semantic::enum_constantValueNegative() '!expectedConstantValue' returned FALSE. ()
FAIL! : tst_Semantic::enum_constantValueNegative() '!expectedConstantValue' returned FALSE. ()
FAIL! : tst_Semantic::enum_constantValueNegative() '!expectedConstantValue' returned FALSE. ()
Change-Id: If4c676bdb963f53fbc57f7d92f3d68341dd51eda
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Token::spell() uses CPlusPlus::Kind as index into token_names. However,
checking whether CPlusPlus::Kind matches token_names is easier if it's
formatted in a similar way.
Change-Id: I3f32b72cf9508c2ea3a4fe6911c3853c309d9e9f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This amends the obviously wrong
aac1bebace.
Fixes
FAIL! : tst_Semantic::q_enum_1() Compared values are not the same
FAIL! : tst_CheckSymbols::test_checksymbols(EnumerationUse) 'resultCount > 0' returned FALSE. ()
FAIL! : tst_CheckSymbols::test_checksymbols(VariableHasTheSameNameAsEnumUse) Compared values are not the same
FAIL! : tst_CheckSymbols::test_checksymbols(enum_inside_block_inside_function_QTCREATORBUG5456) Compared values are not the same
FAIL! : tst_CheckSymbols::test_checksymbols(enum_inside_function_QTCREATORBUG5456) Compared values are not the same
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_block_inside_function) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_block_inside_function_cxx11) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_function) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_function_cxx11) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_class) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_class_cxx11) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_namespace) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_namespace_cxx11) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_member_function) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_member_function_cxx11) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_in_class_accessed_in_member_func_inline) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_completion(enum_in_class_accessed_in_member_func) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter(CppLocatorFilter-filtered) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter() Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_builtinsymbolsearcher(BuiltinSymbolSearcher::AllTypes) Compared lists have different sizes.
FAIL! : CppTools::Internal::CppToolsPlugin::test_builtinsymbolsearcher(BuiltinSymbolSearcher::Enums) Compared lists have different sizes.
Task-number: QTCREATORBUG-21413
Change-Id: I71ace00091e37f0a148086e5047efaec08923b1a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This amends the obviously wrong
de975aca4f, which did not honored nameless
enum specifiers.
This fixes e.g. "Find Usages" for declarations following "enum {};".
Change-Id: Id98c074156f576b9a63e6c25dab38721ca34e496
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
The enum name has to be an identifier. For the example in the referenced
report it was a destructor, which violated invariants in the lookup
code.
Fixes: QTCREATORBUG-20952
Change-Id: Ib8c9c23d6e001368c11c6a4b80c4295559786823
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Currently only operators have their own style but not
punctuation tokens. Make possible to highlight both.
Task-number: QTCREATORBUG-20666
Change-Id: I9533e0f1bef65b86c4e4f5c9756571103584124b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Testable on Linux/macOS by changing c++14 to c++1z in qtcreator.pri.
Testable with latest MSVC2017 by setting _CL_=/std:c++17.
unary_function, binary_function, and a few other things that were
deprecated are removed in C++17.
std::string got a non-const overload for its "data" member function,
so we cannot create a function pointer on it without specifying its
type. Use std::declval instead (though it requires a default constructor
for the type).
MSVC seems to have an issue with Utils::transform for std::vector
(used in Nim plugin), but that looks like a compiler issue.
Change-Id: I94f9a93d591d55b610f86fabfc618158927d6221
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This change limits the set of tokens that fall under
Token::isOperator(). That allows cpphighlighter.cpp to
distinguish operator tokens from punctuator tokens
(without changing any logic in cpphighlighter.cpp).
This change moves punctuators from "Operator"
to the "Text" style category where they belong.
Punctuators are not operators. Punctuators are
dumb text tokens.
Why don't we let the clang backend alone separate
these tokens for us?
1. Clang is slow on big files. Sometimes the
highlighting dictated by clang is painted _seconds_
after cpphighlighter.cpp runs. CppHighlighter is way
faster so we use it to "prepaint" code while clang is
busy in the background.
2. Secondly, clang cannot yet handle all operator types.
In particular, none if its "operator cursors"
CXCursor_UnaryOperator:
CXCursor_BinaryOperator:
CXCursor_CompoundAssignOperator:
CXCursor_ConditionalOperator:
includes the -> and . operators.
We still need CppHighlighter to paint those tokens.
However, once clang has finished processing the file some
operator tokens will be repainted. We need clang to get
all operators' semantics. In particular, we need clang to
tell us if < is a "smaller than"-operator or part of a
template parameter like set<int>.
Task-number: QTCREATORBUG-19659
Change-Id: I952cb58f7c79134b3281e2a8221425cc1d0ad263
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Basically move it from CppTools to CPlusPlus
to be able to use it there.
Change-Id: I0af80f93bdc029824397ceafdf940cb86c4382b0
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
While parsing a document Bind::asStringLiteral() Token::spell() was
called for a raw string literal token with a Token::literal nullptr.
This is due scanRawStringLiteral() not properly aborting for
invalid/incomplete code and that the code paths handling
multi-line-raw-strings were not limited to the highlighting case.
Address both cases.
Task-number: QTCREATORBUG-18941
Change-Id: I489d288ccbd7b59be396dada846613ff555436cf
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Nokia's license header was removed in
b342ad8cf4, but these files didn't have the
second license header that was supposed to remain.
Change-Id: Ib9977a3127fd48197a1a02982e7563c486bfca3a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
... and make use of it.
With gcc 7, the new option -Wimplicit-fallthrough is introduced and
added to the -Wextra set, triggering dozens of warnings in our sources.
Therefore, we annotate all obviously intended fall-throughs. The ones
that are still left are unclear and need to be checked by the respective
maintainer.
Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Make declarations equal in case they differ only
by argument const and/or volatile (13.1.3.4).
Task-number: QTCREATORBUG-18475
Change-Id: Id0561fda3b9081b92716a8739ba9963e90b5d709
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This fix makes some trick and replaces existing typedef of 'pointer'
to the simplest one(only in class unique_ptr), e.g.:
template <class _Tp>
class unique_ptr
{
typedef some_strange_things pointer;
pointer operator->();
}
is replace with
template <class _Tp>
class unique_ptr
{
typedef _Tp* pointer;
pointer operator->();
}
In most of the implementation of unique_ptr it should work.
Similar approach is done for std::list, std::vector, std::queue, std::set,
std::multiset, std::unordered_set.
It is done in this hacky way to omit problems with cyclic and complex
resolving of typedefs.
Change-Id: I1363dfc5e23d3cd2fa7af7fc27423bfbac2d894d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
With the built-in model, which affects basic highlighting.
Task-number: QTCREATORBUG-17720
Change-Id: I7369d7288d9c2c8e5ef36fc27549121014527e58
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>