Review Request 123963: First bits of refactorings. Skeleton of interface for KDevelop. Build system. CompilationDatabase for CMake projects and ClangTool.

Maciej Poleski d82ks8djf82msd83hf8sc02lqb5gh5 at gmail.com
Sat Jun 6 17:19:50 UTC 2015



> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > hey there! I have some issues with your excessive use of new C++11 features, I think they are often not idiomatic. please clean this code up a bit and strive for easy-to-read, documented code. while you are of course free to use new C++11 code, it is not meant as a playground where you should use every new feature just because its new.

hey!

I will think again about use of rvalue references with special regard to http://stackoverflow.com/questions/14856344/when-should-stdmove-be-used-on-a-function-return-value/14856553#14856553
In fact i'm using C++14... is that ok?


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/Cache.cpp, line 28
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379045#file379045line28>
> >
> >     style: join next line
> >     
> >     and why do you take by reference? shouldn't it be const ref? also in the other places

opening brace in the same line as in `for (...) {`?

i cannot move object taken by const reference


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/interface.h, line 36
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379046#file379046line36>
> >
> >     yes. as Kevin and me suggested on the ML - keep it simple and don't care too much about these issues for now. Just concentrate on getting refactoring features in. I.e. feel free to remove this file for now and we can handle this later on.

Yes the purpose of this file is changing from "ABI-stabilizer" to simply "interface". We are going to link this library into kdev-clang, depending on situation it may be very simple interface to the whole stuff. I'm not sure about future of this file, for now i will leave details about binary compatibility and simply focus on interface. And "in case" - we will have less work to make this binary separation.


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/interface.h, line 74
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379046#file379046line74>
> >
> >     do not use out-parameters. return a struct containing the database and an error message
> >     
> >     or, looking at the overdesigned method itself, I'd still suggest you only pass in a build path. If no database is returned (i.e. nullptr), we can construct an error message on the other side if necessary.
> >     
> >         CompilationDatabase compilationDatabase(const std::string& buildPath);

Ok, i will create this simpler version. For now it will provide enough functionality.


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/interface.h, line 77
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379046#file379046line77>
> >
> >     here and below, style:
> >     
> >         ret_t function(arg1_t arg1, arg2_t arg2,
> >                        arg3_t arg3, ...);
> >                        
> >     furthermore, we do not ever call functions `getFoo`, always just `foo`, following the Qt API guidelines.

I used new lines to improve readability - argument strings are quite long, but can change if this style if prefered. How long line can be? (i assumed 80 columns)

Maybe i should use other prefix like "build" or something like this. I wanted to emphasize that this function "makes" returned instance (which is more expensive than simply returning already built object).


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/interface.h, line 78
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379046#file379046line78>
> >
> >     using `std::string` inside an `extern "C"` block? not a good idea.

I only wanted "C" linkage (elude name mangling). Of course calling this function from C is not possible. But KDevelop is written in C++ - building std::string objects is not a problem.

Or is using non-POD argument types as parameters in functions with "C" linkage forbidden?


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/utils.cpp, line 55
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379049#file379049line55>
> >
> >     instead of marking stuff as static, wrap it all in an anonymous namespace

Anonymous namespace will not prevent compiler from emiting symbol (function will have external linkage). The purpose of this is to reduce size of binary and give compiler mare chances to optimize (including optimizing out the whole function)


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/utils.cpp, line 96
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379049#file379049line96>
> >
> >     what does this function do? maybe move into a free function instead of using a lambda? it's fancy and new, but not really readable

This piece of code would repeat inside of implementation of `toRange` function. It has inherent contracts on state of `toRange` invocation (exclusive permission to modify local variables of `toRange`). It isn't usable outside of this function.


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/utils.cpp, line 162
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379049#file379049line162>
> >
> >     ? please translate to english

This should be removed before commit...


> On Cze 6, 2015, 4:05 po południu, Milian Wolff wrote:
> > refactoring/utils.cpp, line 201
> > <https://git.reviewboard.kde.org/r/123963/diff/2/?file=379049#file379049line201>
> >
> >     ?

I noticed that DocumentChangeSet can also carry information about file renaming. libTooling will not do that, but such renaming actions may be reasonable (e.g. when we change name of a class which had name similar to name of file with its definition).


- Maciej


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/123963/#review81265
-----------------------------------------------------------


On Cze 6, 2015, 3:31 po południu, Maciej Poleski wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/123963/
> -----------------------------------------------------------
> 
> (Updated Cze 6, 2015, 3:31 po południu)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdev-clang
> 
> 
> Description
> -------
> 
> First bits of refactorings.
> Skeleton of interface for KDevelop.
> Build system (really nasty, linked DSO has 18MiB).
> CompilationDatabase for CMake projects and ClangTool (with cache, but without cache updates).
> Interface is not frozen for now.
> 
> Currently building of refactorings is enabled only if Clang 3.6.x is found. In other case build system behaves exactly as current master.
> 
> Refactorings require some contextual informations about projects. I made draft of interface with should feature:
>  - Stable ABI - dlopen (or equivalent) a DSO and if succeed (binary is still compatible with Clang libraries ABI), dlsym (or equivalent) some functions which are to provide all refactorings features
>  - Prototypes (with some implementation) of functions constituting API between KDevelop and refactorings backend
>  - It may be considered to use Qt plugin system to provide implementation of this (or equivalent) interface. This would be more expensive, but also more portable
>  - In worst case this library (static version) can be used with additional driver to make stand-alone executable providing all refactorings features (but it would require additional marshaling and hamper cooperation with user (how to provide UI in such a case?))
> 
> Handling dependencies between Clang/LLVM libraries is a nightmare. I extended FindClang.cmake to find much more libraries and used them to link with first pieces of my code. This is huge, requires additional libraries like zlib and even ordering of dependencies can cause linker errors.
> 
> Interface is not finished
> 
> 
> Diffs
> -----
> 
>   CMakeLists.txt 875172a8407f4bd9faf330f032a280fa66c2b16f 
>   cmake/FindClang.cmake 6c9bd6ef0242319122dcc7e6fd6cea8d9f0cbfbb 
>   refactoring/CMakeLists.txt PRE-CREATION 
>   refactoring/Cache.h PRE-CREATION 
>   refactoring/Cache.cpp PRE-CREATION 
>   refactoring/interface.h PRE-CREATION 
>   refactoring/interface.cpp PRE-CREATION 
>   refactoring/utils.h PRE-CREATION 
>   refactoring/utils.cpp PRE-CREATION 
> 
> Diff: https://git.reviewboard.kde.org/r/123963/diff/
> 
> 
> Testing
> -------
> 
> Compiles on my Gentoo system. It makes sense to build this only on system with Clang 3.6.
> 
> 
> Thanks,
> 
> Maciej Poleski
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20150606/23ba4bbd/attachment-0001.html>


More information about the KDevelop-devel mailing list