Author Topic: Clang based CC, new CC interface  (Read 42061 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1511
Re: Clang based CC, new CC interface
« Reply #45 on: March 02, 2014, 02:01:07 am »
EDIT: I have one further question about the build process. I managed it to build the cc-branch and the clanglib plugin against the cc-branch's source code, but starting (compiled) CB leads to the error message: "One or more plugin could not be loaded........clanglib.dll", because of missing symbols. Is there something more I have to do?
From your LLVM/Clang installation, is 'libclang.dll' (some_path\LLVM\bin\libclang.dll) in the executable's searchable path?

Offline Meiner

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: Clang based CC, new CC interface
« Reply #46 on: March 02, 2014, 09:29:41 pm »
Yeah, that was it, stupid mistake of mine. Now I have a working build of CB which includes your plugin. It's so nice for me to see that there will be a working code completion for oglplus (C++ OpenGL wrapper), which seems to be a true nightmare for most existing code completion systems.

If you want to have some feedback:

1. In my case there is a huge delay when loading a project (first parsing takes place) and when changing the current active file. Is that a normal behaviour at the current development status?

2. I like the dynamic checking of code validity, it's very nice integrated, although with some code it's rather confusing (a lot of warnings^^).


Meiner
« Last Edit: March 03, 2014, 11:10:56 am by Meiner »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1511
Re: Clang based CC, new CC interface
« Reply #47 on: March 03, 2014, 09:25:49 pm »
If you want to have some feedback:
Feedback is always welcome, thank you.  (Though, life is very busy for me right now, so no promises on how soon I will be able to address anything.)

1. In my case there is a huge delay when loading a project (first parsing takes place) and when changing the current active file. Is that a normal behaviour at the current development status?
Known problem.  Currently, my development on this plugin has been mainly to try to explore the extent of possible functionality that clang provides.  I have ignored performance... though, once I try to bring this plugin to more 'daily' use, the next steps will be to increase caching of results, and to move parsing to a separate thread, so as not to block the UI for so long (not done yet due to simplicity).
« Last Edit: March 04, 2014, 02:27:19 am by Alpha »

Offline maryjeck

  • Single posting newcomer
  • *
  • Posts: 5
Re: Clang based CC, new CC interface
« Reply #48 on: March 10, 2014, 04:51:55 am »
Can it work under a nightly build ??? ???

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Clang based CC, new CC interface
« Reply #49 on: March 10, 2014, 10:06:15 am »
I guess many are waiting for it. ;)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10362
Re: Clang based CC, new CC interface
« Reply #50 on: March 10, 2014, 10:37:43 am »
Not yet, but hopefully the code will be merge soon.
Anyone interested in this should try the modified version from here https://github.com/alpha0010/codeblocks_sf/tree/cc_interface
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1511
Re: Clang based CC, new CC interface
« Reply #51 on: May 12, 2014, 01:00:20 am »
Binary release available here for Windows, compatible with nightly build rev9765.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4985
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Clang based CC, new CC interface
« Reply #52 on: May 12, 2014, 02:04:22 am »
Binary release available here for Windows, compatible with nightly build rev9765.
Hi, Alpha, very nice work, I have just download both the nightly build and this clanglib binaries, the question is: How to use this plugin?
Do I need to disable the normal cc plugin?
Thanks.

EDIT:
This function works fine, see image shot below:



Q1: How to remove(hide) the tip window, see image shot below, do I need to hit some short-cut key?



« Last Edit: May 12, 2014, 03:26:21 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline vali29

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Clang based CC, new CC interface
« Reply #53 on: May 12, 2014, 01:06:49 pm »
On my system:
Code: [Select]
codeblocks.exe caused an Access Violation at location 62f86c09 in module libclang.dll Reading from location 00000014.

Registers:
eax=00000000 ebx=0000001e ecx=0022f6d0 edx=7b220a2d esi=0022f6c8 edi=075a97b0
eip=62f86c09 esp=0022f568 ebp=0022f760 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246

Call stack:
62F86C09  libclang.dll:62F86C09  clang_getInclusions
62447151  clanglib.dll:62447151
6CC41261  wxmsw28u_gcc_cb.dll:6CC41261  _ZNK12wxAppConsole11HandleEventEP12wxEvtHandlerMS0_FvR7wxEventES3_
6CCC436E  wxmsw28u_gcc_cb.dll:6CCC436E  _ZN12wxEvtHandler21ProcessEventIfMatchesERK21wxEventTableEntryBasePS_R7wxEvent
6CCC47A7  wxmsw28u_gcc_cb.dll:6CCC47A7  _ZN12wxEvtHandler23SearchDynamicEventTableER7wxEvent
6CCC4864  wxmsw28u_gcc_cb.dll:6CCC4864  _ZN12wxEvtHandler12ProcessEventER7wxEvent
6CDC9F08  wxmsw28u_gcc_cb.dll:6CDC9F08  _ZN11wxTimerBase6NotifyEv
6CD01CB4  wxmsw28u_gcc_cb.dll:6CD01CB4  _ZN7wxTimer4InitEv
75DBC4E7  USER32.dll:75DBC4E7  gapfnScSendMessage
75DBC5E7  USER32.dll:75DBC5E7  gapfnScSendMessage
75DBCC19  USER32.dll:75DBCC19  gapfnScSendMessage
75DBCC70  USER32.dll:75DBCC70  DispatchMessageW
75DB41EB  USER32.dll:75DB41EB  IsDialogMessageW
6CCEFD80  wxmsw28u_gcc_cb.dll:6CCEFD80  _ZN11wxEventLoop17PreProcessMessageEP6tagMSG
6CCEF852  wxmsw28u_gcc_cb.dll:6CCEF852  _ZN11wxEventLoop14ProcessMessageEP6tagMSG
6CCEFAEF  wxmsw28u_gcc_cb.dll:6CCEFAEF  _ZN11wxEventLoop8DispatchEv
Win 7 x32 Home Premium, TDM-GCC 4.7.1 (with dragonegg), wxWidgets 2.8.12.1

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1511
Re: Clang based CC, new CC interface
« Reply #54 on: May 12, 2014, 04:58:38 pm »
Do I need to disable the normal cc plugin?
Technically you probably should (because otherwise you are parsing everything twice), however, I do not.  The two plugins seem to coexist nicely on my computer.

Q1: How to remove(hide) the tip window, see image shot below, do I need to hit some short-cut key?
Currently hardcoded to show warnings and errors, so I guess your two options are: fix the warning, or add -w to your compiler flags (restart C::B probably required).  Or patch the plugin :) .

On my system: [...]
Does this happen with any project?  If it is a specific file, are you able to post a (minimal) code piece that will cause this crash?

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1511
Re: Clang based CC, new CC interface
« Reply #55 on: May 12, 2014, 09:28:00 pm »
I have successfully compiled the ClangLib plugin but always crash at clang_getInclusions when they start to parse the project.
Odd...  Did you self-compile everything, or is this linking against a nightly?
Hi Alpha!

Compiled myself with TDM GCC 4.6.1, CB svn 9760, LLVM + Clang 3.3 and your ClangLib plugin.
On small CB projects, ex. c++ Hello World it's working but on projects with wxWidgets always crash.

Do you have a special build steps to compile LLVM with gcc on Windows?
Oh, apologies; looks like I never got back to you on this.
For Windows, I use the prebuilt LLVM/Clang (3.4), and TDM GCC 4.8.1 to compile wxWidgets and Code::Blocks.

My guess from your crash is that clang_parseTranslationUnit() is returning null (which it will do in the case of internal errors so extreme, it cannot recover), and then the null is passed to clang_getInclusions().  Most likely, this is due to a compiler flag (and not your source code itself - clang seems fairly good at handling, or gracefully backing down, on any sort of code I have sent it).  Could you post your full compile command line for the project that crashes?

Offline vali29

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Clang based CC, new CC interface
« Reply #56 on: May 12, 2014, 10:32:31 pm »
I have successfully compiled the ClangLib plugin but always crash at clang_getInclusions when they start to parse the project.
Odd...  Did you self-compile everything, or is this linking against a nightly?
Hi Alpha!

Compiled myself with TDM GCC 4.6.1, CB svn 9760, LLVM + Clang 3.3 and your ClangLib plugin.
On small CB projects, ex. c++ Hello World it's working but on projects with wxWidgets always crash.

Do you have a special build steps to compile LLVM with gcc on Windows?
Oh, apologies; looks like I never got back to you on this.
For Windows, I use the prebuilt LLVM/Clang (3.4), and TDM GCC 4.8.1 to compile wxWidgets and Code::Blocks.

My guess from your crash is that clang_parseTranslationUnit() is returning null (which it will do in the case of internal errors so extreme, it cannot recover), and then the null is passed to clang_getInclusions().  Most likely, this is due to a compiler flag (and not your source code itself - clang seems fairly good at handling, or gracefully backing down, on any sort of code I have sent it).  Could you post your full compile command line for the project that crashes?
Hi Alpha!
This is the command line for g++:
Code: [Select]
g++.exe -Wextra -Wall -pg -g -pipe -Wno-attributes -Winvalid-pch -include wx_pch.h -fpermissive -finput-charset=ISO-8859-2 -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -DWX_PRECOMP -D__WXDEBUG__ -D__USE_MALLOC -IE:\Dev\C-C++\CodeBlocks\DevPacks\wx\lib\gcc_lib\mswud -IE:\Dev\C-C++\CodeBlocks\DevPacks\wx\include -Ie:\Dev\C-C++\CodeBlocks\DevPacks\litecms2\include -IControls -IE:\Dev\C-C++\CodeBlocks\DevPacks\nvwa\bin\Debug -Ie:\Dev\C-C++\CodeBlocks\DevPacks\nvwa -Ie:\Dev\C-C++\CodeBlocks\DevPacks\debug -Ie:\Dev\C-C++\CodeBlocks\DevPacks\wx\lib\gcc_dll\mswu -c E:\Dev\C-C++\Proiecte\VaanColorPicker\VCPSettings.cpp -o obj\MinGW\Debug_lcms2\VCPSettings.o
Win 7 x32 Home Premium, TDM-GCC 4.7.1 (with dragonegg), wxWidgets 2.8.12.1

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1511
Re: Clang based CC, new CC interface
« Reply #57 on: May 12, 2014, 10:58:00 pm »
This is the command line for g++:
Code: [Select]
g++.exe -Wextra -Wall -pg -g -pipe -Wno-attributes -Winvalid-pch -include wx_pch.h -fpermissive -finput-charset=ISO-8859-2 -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -DWX_PRECOMP -D__WXDEBUG__ -D__USE_MALLOC -IE:\Dev\C-C++\CodeBlocks\DevPacks\wx\lib\gcc_lib\mswud -IE:\Dev\C-C++\CodeBlocks\DevPacks\wx\include -Ie:\Dev\C-C++\CodeBlocks\DevPacks\litecms2\include -IControls -IE:\Dev\C-C++\CodeBlocks\DevPacks\nvwa\bin\Debug -Ie:\Dev\C-C++\CodeBlocks\DevPacks\nvwa -Ie:\Dev\C-C++\CodeBlocks\DevPacks\debug -Ie:\Dev\C-C++\CodeBlocks\DevPacks\wx\lib\gcc_dll\mswu -c E:\Dev\C-C++\Proiecte\VaanColorPicker\VCPSettings.cpp -o obj\MinGW\Debug_lcms2\VCPSettings.o
Okay, I believe clang is choking on "-finput-charset=ISO-8859-2", could you test: disable clang plugin, remove that build flag, enable clang plugin (probably need to restart C::B).

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Clang based CC, new CC interface
« Reply #58 on: May 13, 2014, 03:51:40 am »
The plugin looks quite effective, thnx for your work. I listed some issues/features I encountered below, some might be bugs:

1- I had to disable the CC plugin to install the Clang plugin for the first time. CB crashed the first time after loading a project (CC plugin was enabled when I copied the files). After installation I could enable CC plugin.
2- I'm getting a ~1sec delay before the 1st and 3rd characters of anything I type on my old dual core cpu, will that delay be permanent?
3- The '.' and '->' kicks in for almost everything like 'for./->' 'int./->' 'some_class_name./->' even when typed on their own and the list consists of almost everything too.
4- I hope the argument tip comment for functions like 'some_func(/*! argument_type !*/)' will be optional as it doesn't play nice with my color profile.
5- I see the 'for', 'while' etc... are completed into complete blocks now and not just into keywords, is it possible to make this also optional? I use abbreviations plugin to customize these blocks.

Edit: Win7 x64
« Last Edit: May 13, 2014, 03:58:29 am by scarphin »

Offline vali29

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: Clang based CC, new CC interface
« Reply #59 on: May 13, 2014, 09:34:41 am »
This is the command line for g++:
Code: [Select]
g++.exe -Wextra -Wall -pg -g -pipe -Wno-attributes -Winvalid-pch -include wx_pch.h -fpermissive -finput-charset=ISO-8859-2 -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -DWX_PRECOMP -D__WXDEBUG__ -D__USE_MALLOC -IE:\Dev\C-C++\CodeBlocks\DevPacks\wx\lib\gcc_lib\mswud -IE:\Dev\C-C++\CodeBlocks\DevPacks\wx\include -Ie:\Dev\C-C++\CodeBlocks\DevPacks\litecms2\include -IControls -IE:\Dev\C-C++\CodeBlocks\DevPacks\nvwa\bin\Debug -Ie:\Dev\C-C++\CodeBlocks\DevPacks\nvwa -Ie:\Dev\C-C++\CodeBlocks\DevPacks\debug -Ie:\Dev\C-C++\CodeBlocks\DevPacks\wx\lib\gcc_dll\mswu -c E:\Dev\C-C++\Proiecte\VaanColorPicker\VCPSettings.cpp -o obj\MinGW\Debug_lcms2\VCPSettings.o
Okay, I believe clang is choking on "-finput-charset=ISO-8859-2", could you test: disable clang plugin, remove that build flag, enable clang plugin (probably need to restart C::B).
The same crash.
I made a simple wxFrame project and after i added a button on frame and set OnClick event for button...
Code: [Select]
#0 6970B665 libclang!clang_defaultCodeCompleteOptions() (E:\Dev\C-C++\CodeBlocks\libclang.dll:??)
#1 00000040 ?? () (??:??)
#2 695F749E libclang!clang_defaultCodeCompleteOptions() (E:\Dev\C-C++\CodeBlocks\libclang.dll:??)
#3 ?? ?? () (??:??)


Win 7 x32 Home Premium, TDM-GCC 4.7.1 (with dragonegg), wxWidgets 2.8.12.1