Sysprogs forums › Forums › VisualGDB › Clang based IntelliSense engine issues
- This topic has 7 replies, 2 voices, and was last updated 6 years, 9 months ago by
SFC01.
-
AuthorPosts
-
June 15, 2018 at 15:34 #21132
SFC01
ParticipantI have encountered a few issues when using the Clang based IntelliSense engine and would like to document them here.
System information:
Windows 7 Professional SP1
Visual Studio Community 2017 Version 15.7.3
VisualGDB 5.3 (build 1836) licensed
ARM toolchain 7.2.0/8.0.1/r3
Navigation bar issues:
At the top of the text editor window there is a navigation bar with three drop down menus that allow for navigation inside the currently selected file. From left to right you can select the scope and then the methods. This works perfectly fine when using the native Visual Studio IntelliSense engine. When using Clang based IntelliSense engine, however, it appears to be broken. When a number of classes implementing an interface are placed within a namespace, you cannot scope to an individual class, and instead a list of all functions in all classes in the namespace is shown in the drop down selection menu. That renders the navigation bar useless, because you don’t know what method belongs to what class.
You can reproduce the issue with this example code:
Header.h:
#ifndef HEADER_H_ #define HEADER_H_ namespace MyNamespace { class Interface { public: virtual void Init(void) = 0; virtual void Reset(void) = 0; virtual void Update(void) = 0; }; class ImplementationA final : public Interface { public: virtual void Init(void) override; virtual void Reset(void) override; virtual void Update(void) override; }; class ImplementationB final : public Interface { public: virtual void Init(void) override; virtual void Reset(void) override; virtual void Update(void) override; }; class ImplementationC final : public Interface { public: virtual void Init(void) override; virtual void Reset(void) override; virtual void Update(void) override; }; } #endif // HEADER_H_
Source.cpp:
#include "Header.h" namespace MyNamespace { void ImplementationA::Init(void) {} void ImplementationA::Reset(void) {} void ImplementationA::Update(void) {} void ImplementationB::Init(void) {} void ImplementationB::Reset(void) {} void ImplementationB::Update(void) {} void ImplementationC::Init(void) {} void ImplementationC::Reset(void) {} void ImplementationC::Update(void) {} }
Formatting issues:
- Braces are not placed in the correct spot. Typing i.e. “class Interface{” with the Clang based IntelliSense engine enabled produces
class Interface
{};
This ignores my formatting settings, which in this case state that the opening braces should be kept on the same line (Tools->Options->Text Editor->C/C++->Formatting->New Lines). It is very annoying to have to manually correct the formatting.
- I have configured tabs to be replaced by spaces (Tools->Options->Text Editor->C/C++->Tabs). But when Clang is enabled this setting is ignored as well and tabs are kept.
- After typing i.e. “template<typename Type>[ENTER]” the new line is indented. I don’t even know if this can be configured, but when using the native VS IntelliSense engine there is no indent.
Syntax highlighting issues:
Note: The dark color theme is configured in Visual Studio. Color and font options are set to default.
- Preprocessor directives are displayed in a blue color (like C keywords) instead of the configured color and the color cannot be altered via the settings.
- Types in templates are displayed in a dark grey color (like arguments) instead of the configured color. Other types appear to be displayed correctly.
June 15, 2018 at 22:20 #21140support
KeymasterHi,
No problem, we have fixed the navigation bar issues in this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.3.2315.msi
Please use the Tools->Options->Text Editor->C/C++ (VisualGDB) to configure the tabs/spaces for the VisualGDB projects. Unfortunately the language service design inherited from Visual Studio forces this to be a separate setting from the regular C/C++ tabs/spaces. You can also set the position of the new braces via Tools->Options->Text Editor->C/C++ (VisualGDB)->Formatting->Newline Insertion->New types.
The new build also contains experimental support for clang-format, including an interactive style editor. You can enable it via VisualGDB Project Properties -> IntelliSense Settings. It is a complete drop-in replacement to the regular formatting engine and is heavily optimized to seamlessly run in the background.
July 18, 2018 at 07:32 #21393SFC01
ParticipantThank you! The navigation bar and most of the formatting work well with the preview version.
Are you going to fix the syntax highlighting (see first post)?
I have another question. When using the native engine, initializer lists are formatted like this with spaces:
std::vector<int32_t> list{ 1, 2, 3, 4, 5 };
When using the Clang engine (advanced Clang-format enabled), initializer lists are formatted without spaces:
std::vector<int32_t> list{1, 2, 3, 4, 5};
Is there a way to modify this, when using Clang?
Sometimes, when using Clang, the “Format Document” or “Format Selection” commands don’t work. Executing the commands has no effect and the code remains unformatted. I had to restart Visual Studio and reload the project and perform a rescan of the project to get it to work again. What could be the cause for this behaviour?
Visual Studio Community 2017 version 15.7.5
VisualGDB Custom Edition version 5.4 (preview 3, build 2315)
July 18, 2018 at 20:04 #21404support
KeymasterHi,
You might be able to control the initializer list formatting using the ConstructorInitializerIndentWidth parameter (see clang-format reference). If this doesn’t help, please consider checking with the clang community. Since the clang-format logic is a part of clang, we are not able to tweak it more than clang itself allows, however we should be able to integrate new versions of the formatter into our engine as they come out.
If the formatting commands don’t work, please try checking the View->Clang IntelliSense Diagnostics Console for error messages. If nothing helps, please let us know if there is a specific sequence of steps that could reproduce this issue.
With the highlighting colors, VisualGDB has to use a relatively complex workaround in order to synchronize its color settings with the regular VC++ color settings and sometimes the VS color cache gets corrupt, preventing proper synchronization. Normally changing the corresponding color via Tools->Options manually fixes the problem.
If it doesn’t help, please attach a screenshot of the incorrectly colored code (the entire VS window including the navigation bar so we could check for other possible clues) and a screenshot of the corresponding color setting.
July 23, 2018 at 07:53 #21434SFC01
ParticipantConstructorInitializerIndentWidth does something different.
ConstructorInitializerIndentWidth = 4:
class Test final { public: Test(const int32_t argument1, const int32_t argument2) : member1_{argument1}, member2_{argument2} {} private: int32_t member1_; int32_t member2_; };
ConstructorInitializerIndentWidth = 0:
class Test final { public: Test(const int32_t argument1, const int32_t argument2) : member1_{argument1}, member2_{argument2} {} private: int32_t member1_; int32_t member2_; };
The colors of preprocessor directives and template parameters are always displayed in the wrong color when Clang is enabled. Changing the color via the options has no effect. Preprocessor directives are always displayed in blue, regardless of the setting. User types in templates are always displayed in grey, regardless of the setting. The color of other user types can be changed though. Please see the attached screenshots.
Visual Studio version 15.7.5
VisualGDB Custom Edition version 5.4 (preview 3, build 2315)
Attachments:
You must be logged in to view attached files.July 23, 2018 at 07:54 #21439SFC01
ParticipantHere are the remaining screenshots.
Attachments:
You must be logged in to view attached files.July 23, 2018 at 20:47 #21454support
KeymasterHi,
Thanks for clarifying the constructor initialization list issue and providing detailed screenshots. As the clang-format logic comes directly from the clang codebase, we won’t be able to maintain a parallel formatting engine with an extended set of formatting rules/options. However if you could convince the Clang maintainers to add the advanced options you require to their codebase (e.g. by sending them a merge request), we should be able to update our engine promptly.
The “preprocessor keywords” indeed looks like our bug. Please try this build: http://sysprogs.com/files/tmp/VisualGDB-5.4.3.2358.msi
For user types in templates VisualGDB uses a separate setting – C++ Template Type Parameters. Please consider changing it additionally to C++ User Types.
July 24, 2018 at 08:10 #21462 -
AuthorPosts
- You must be logged in to reply to this topic.