Author Topic: GCCSense is quite good!  (Read 13613 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
GCCSense is quite good!
« on: December 05, 2010, 02:59:33 pm »
Hei, guys, I found another codecompletion tool, this is much like the Clang's codecompletion model. But it is based on GCC

http://cx4a.org/software/gccsense/index.html

screen shot here:



http://cx4a.org/software/gccsense/manual.html

http://gcc.gnu.org/ml/gcc/2010-04/msg00433.html

 :D :D

hope some brave guys can help cc to improve it's precise suggestion list.



« Last Edit: December 05, 2010, 03:11:30 pm 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 killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5258
Re: GCCSense is quite good!
« Reply #1 on: December 05, 2010, 03:19:39 pm »
this might be very interesting, since now and for sure in the future we will need the compilers information (for example the auto keyword, where the compiler will determine the actual type of the variable).

MSVC also uses its compiler for the intellisense.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: GCCSense is quite good!
« Reply #2 on: December 05, 2010, 05:48:40 pm »
The proble I see is, that it uses it's on gcc-derivate (if I see it correctly) and that it is not (yet) available for windows.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12911
    • Travis build status
Re: GCCSense is quite good!
« Reply #3 on: December 05, 2010, 05:56:36 pm »
The problems with this one is that it is a 'proof of concept' project and lots of works should be done before it is usable in production...
(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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GCCSense is quite good!
« Reply #4 on: December 07, 2010, 08:49:59 am »
The problems with this one is that it is a 'proof of concept' project and lots of works should be done before it is usable in production...
after I just review the patch here:http://gcc.gnu.org/ml/gcc/2010-04/msg00433.html
I totally agree oBF's comment. :D

currently, Clang is still the best candidate. but ... too complex and hard for me.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GCCSense is quite good!
« Reply #5 on: January 24, 2011, 05:56:46 am »
here is another source I found which Can be really usefull to support our codecompletion plugin.

http://codesynthesis.com/~boris/blog/2010/05/10/parsing-cxx-with-gcc-plugin-part-2/

GCC's plugin system is really quite nice place to retrieve the full AST.

Edit
it seems the plugin framework does not work under windows by default, see:
http://gcc.gnu.org/ml/gcc/2010-07/msg00003.html
« Last Edit: January 24, 2011, 07:04:28 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 thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: GCCSense is quite good!
« Reply #6 on: January 24, 2011, 10:00:29 am »
We discussed this a few years ago, I think, when there was first talk about GCC running as server some day in the future (is this still planned?). The ability of dumping the intermediate language tree existed as something between an experimental patch and an idea in the form of xml-gcc then.

I'd very much like to see a code completion based on the compiler, since it is really the only thing that makes sense. However, it should not need to launch the compiler a thousand times, for performance reasons. And, before spending weeks/months on writing a tree-dump-parser, one should be sure that the gcc guys have frozen the format (which may take years).
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GCCSense is quite good!
« Reply #7 on: January 24, 2011, 02:12:53 pm »
We discussed this a few years ago, I think, when there was first talk about GCC running as server some day in the future (is this still planned?). The ability of dumping the intermediate language tree existed as something between an experimental patch and an idea in the form of xml-gcc then.
I have read those topics about using gcc, I also notices that TDM has doing some testing, but he said it take several seconds to parse the stl header. so he said this was not satisfied.
currently, gcc-xml project was not active, see:
http://www.gccxml.org/pipermail/gccxml/2010-November/001435.html
the author suggest using clang instead.

Quote
I'd very much like to see a code completion based on the compiler, since it is really the only thing that makes sense. However, it should not need to launch the compiler a thousand times, for performance reasons. And, before spending weeks/months on writing a tree-dump-parser, one should be sure that the gcc guys have frozen the format (which may take years).
If we can use a PCH(or dynamically create a PCH), the speed of codecompletion can be quite nice. I have review the gccsense's patch against the gcc's parser. it does very simple thing.

The parser will normally skip any function body, but when the parser find a function body which embrace the current caret position, it will rollback to parse the current function body again.

But I think the AST tree structure can not help to do the codecompletion. then information need to do the completion is "the scope" information of the current caret position. I don't think the dumped AST has these information.

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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GCCSense is quite good!
« Reply #8 on: January 27, 2011, 04:19:17 am »
The proble I see is, that it uses it's on gcc-derivate (if I see it correctly) and that it is not (yet) available for windows.
I just create gccsense under windows, it works fine.
I create patches so it can apply on vanilla gcc 4.5.2 source.

See the attachment for more details. (includes patches and Howto) :D
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5277
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: GCCSense is quite good!
« Reply #9 on: February 17, 2011, 06:20:07 am »
FYI:
here:
http://blogs.msdn.com/b/vcblog/archive/2010/01/26/precompiled-header-files-in-visual-studio-2010.aspx
but "reparse" the source file is quite tricky
Quote
In order for the intellisense compiler to provide this information, the intellisense engine must initially parse the TU like the command-line compiler, recursively parsing all #include files listed at the top of the source file before parsing the rest of the source file.  Thanks to C++ scoping rules, we know that we can skip all method bodies except the one you might currently be in, but, other than this optimization, the rest of the translation unit must be parsed to give an accurate answer.  We refer to this as the “pre-parse.”

Pre-parses are not always required, as users spend much of their time writing code inside of a local scope.  Through careful tracking of user edits, we can say whether or not the user has changed information which requires a new pre-parse.  When this happens, we throw away our old pre-parse and start again.
it seems that code completion result can be reused if we don't change the "scope". :D, but we maybe need to track the "}".
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.