News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Clang based CC, new CC interface

Started by Alpha, January 11, 2014, 01:45:53 AM

Previous topic - Next topic

Alpha

I made an attempt to just get clang CC running with the working state of the CC plugin interface redesign.  Code attached.  (This is purely for demonstration, as it currently runs synchronously and does not cache results, so usability is low.)
Only tested under linux, some search directories are hard coded (and may need to be changed), the project directory expects to be extracted into src/plugins/, it may be necessary to disable the main CC plugin to see any results (CCManager will only query one of them because both claim to support the same files).

(For some reason, it appears clang_codeCompleteAt() is simply dumping all tokens that it knows, instead of using any sort of heuristic search/namespace resolution.  I do not know if that is error on my part, or if that is the expected output...)

Alpha

Quote from: Alpha on January 11, 2014, 01:45:53 AM
(For some reason, it appears clang_codeCompleteAt() is simply dumping all tokens that it knows, instead of using any sort of heuristic search/namespace resolution.  I do not know if that is error on my part, or if that is the expected output...)
Oops.  User error on my part.  The location I passed for line/column was 0-index based, however, clang was expecting 1-index based.

(I will start a git repository for this plugin soon.)

dmoore

Cool! I will give it a try when it makes it to git. Never understood how clang's CC works in terms of finding symbols outside of local file scope. Presumably it already knows how to find std lib stuff, but what about something like wxwidgets?

Btw, when do we get the merge of your cc branch into trunk?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Alpha

#3
Repository is up.
git clone https://github.com/alpha0010/ClangLib.git
https://github.com/alpha0010/ClangLib
Please copy the attached image into src/devel/share/codeblocks/images/codecompletion/ before testing.

Quote from: dmoore on January 12, 2014, 02:39:54 AM
Btw, when do we get the merge of your cc branch into trunk?
From what I can tell, it runs as stable as the trunk (I am using the cc_interface branch as my main code editor).  Part of my purpose with testing this Clang plugin is to see if any obvious changes must be made to the interface.
My thoughts are, merge the branch once the interface works without losing any features from the main CC plugin (done), tests from this Clang plugin (in progress...), and the FortranProject (not yet looked at).  If we merge before these are complete, the interface would be likely to change soon after (defeating the purpose of working in a branch).
That said, my ideal target is one/two months (which depends a lot on how easy porting the FortranProject turns out to be).

Quote from: dmoore on January 12, 2014, 02:39:54 AM
Never understood how clang's CC works in terms of finding symbols outside of local file scope.
The way it is set up, Clang essentially compiles the file (into memory), so all of the #includes are resolved and expanded.  Searches are done per translation unit, not per file (which does mean I had to do a bit of file trickery in this plugin).

dmoore

Quote from: Alpha on January 12, 2014, 11:12:20 PM
Repository is up.
git clone https://github.com/alpha0010/ClangLib.git
https://github.com/alpha0010/ClangLib

Ubuntu 13.10's clang libs seems to be missing clang-c/Index.h, so I can't build it. Anyone know of a workaround? (Installing clang from source not an option in the near term)

Quote
Please copy the attached image into src/devel/share/codeblocks/images/codecompletion/ before testing.

Why don't you just deploy this file with a post build step in the project settings?

Quote from: Alpha on January 12, 2014, 11:12:20 PM
That said, my ideal target is one/two months (which depends a lot on how easy porting the FortranProject turns out to be).

If my python experience is a guide, this should be relatively straightforward. Your code eliminates a lot of the fiddling with cbEditor/wxScintilla.

Has anyone contacted the fortran maintainer? (I think he has the username darmar)
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

ollydbg

If I remember correct, index.h and other Clang shared libraries can be copied from CodeLite IDE's code repo.
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.

oBFusCATed

dmoore: Have you tried to install clang-dev or -devel?
(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!]

Alpha

Quote from: dmoore on January 15, 2014, 11:03:14 PM
Ubuntu 13.10's clang libs seems to be missing clang-c/Index.h, so I can't build it. Anyone know of a workaround? (Installing clang from source not an option in the near term)
The package libclang-3.4-dev has it (libclang-dev also works, but why not use the newer version since it is available?).  (Note that in the project file, the search path for it is currently hard coded, so you may have to adapt it to your computer.)

Quote from: dmoore on January 15, 2014, 11:03:14 PM
Why don't you just deploy this file with a post build step in the project settings?
I was planing to have CCManager provide a default set of icons, so I would end up deleting this from the Clang project later... Not really a valid excuse :) .  Just lazy.

Quote from: dmoore on January 15, 2014, 11:03:14 PM
Has anyone contacted the fortran maintainer? (I think he has the username darmar)
I have not yet; I will send a PM now.

dmoore

Quote from: oBFusCATed on January 16, 2014, 01:22:39 AM
dmoore: Have you tried to install clang-dev or -devel?

Yes. No sign of the needed headers. I will try installing 3.4...
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Alpha

Quote from: dmoore on January 16, 2014, 02:05:37 AM
Yes. No sign of the needed headers. I will try installing 3.4...
Hmm... I found them under /usr/lib/llvm-3.2/include and /usr/lib/llvm-3.4/include respectively.

dmoore

Quote from: Alpha on January 16, 2014, 02:16:41 AM
Quote from: dmoore on January 16, 2014, 02:05:37 AM
Yes. No sign of the needed headers. I will try installing 3.4...
Hmm... I found them under /usr/lib/llvm-3.2/include and /usr/lib/llvm-3.4/include respectively.

Ohh... completely obvious that they would put it there  ::) and who needs pkg-config files these days.  :-\
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

dmoore

Anyway, I should have looked more closely at your project file and I would have figured this out. doh!

This works really well and as far as I can tell is every bit as quick as our CC plugin. I didn't really do much testing but it seemed to be able to complete most things I tried. (Some things seemingly took a bit of time to populate in whatever DB clang uses so didn't come up first time)
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

...did you try that on Windows already?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Alpha

I have it running on Windows now as well.  I will commit the project file once I am done cleaning it up.

thomas

You got a working Clang on Windows? How so?
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."