[cfe-dev] LibTooling vs. LibClang+Python for simple refactoring

Amit Margalit AMITM at il.ibm.com
Tue Dec 31 22:37:38 PST 2013

Just my $0.02 here - using LibClang with Python bindings is a bit slow.

On a moderate sized source file, it can take several hundred milliseconds 
to parse.

If I understand correctly, this is because the parsing involves creating 
of many Python objects, to represent just about everything in your AST.

The size of the original source is actually not the issue, but the size of 
the preprocessed source quickly becomes very large with the inclusion of 
many headers.

For working one-file at a time, this is not a problem at all, however, I 
wrote something that uses the Python bindings to inject custom 
instrumentation code, during the build of a large project, and this slowed 
the build considerably.

Again, just for the sake of everyone thinking about this - I should have 
written that in C++ from the beginning.

Amit Margalit
IBM XIV - Storage Reinvented
XIV-NAS Development Team
Tel. 03-689-7774
Fax. 03-689-7230

From:   "dblaikie at gmail.com" <dblaikie at gmail.com>
To:     "Schlottke, Michael" <m.schlottke at fz-juelich.de>, cfe-dev 
Developers <cfe-dev at cs.uiuc.edu>, Daniel Jasper <djasper at google.com>, 
Manuel Klimek <klimek at google.com>, Sean Silva <silvas at purdue.edu>
Date:   01/01/2014 01:26 AM
Subject:        Re: [cfe-dev] LibTooling vs. LibClang+Python for simple 
Sent by:        cfe-dev-bounces at cs.uiuc.edu

On Monday, December 30, 2013 2:40:30 PM, Sean Silva <silvas at purdue.edu> 
On Mon, Dec 30, 2013 at 9:40 AM, dblaikie at gmail.com <dblaikie at gmail.com> 
On Sun Dec 29 2013 at 10:25:19 AM, Schlottke, Michael <m.schlottke at fz-
juelich.de> wrote:
Hi David,  
Thanks for the fast reply. 
>From your description I infer that clang-fixit is a tool for enforcing a 
certain naming convention, rather than changing specific names, or did I 
misunderstand you? 
That's correct - but it has the same challenges in terms of resizing 
names, etc.

However, maybe it could be a place for me to start looking for ideas... 
The only reference I found to clang-fixit is http://llvm-
reviews.chandlerc.com/D51, but nothing in the llvm or clang/extra 
repository. Could you tell me where I can find more information on it? 
Hmm, perhaps it hasn't really been started yet. Sorry for the red herring.
Do you maybe mean clang-tidy? It's in clang-tools-extra last I checked

Indeed I did. Thanks for the correction!
-- Sean Silva

I would guess clang-migrate would be the next best tool to look at. It 
does various code changes and deals with reformatting the resulting code, 
- David


-------- Ursprüngliche Nachricht --------
Von: dblaikie at gmail.com 
An: "Schlottke, Michael" <m.schlottke at fz-juelich.de>,cfe-dev Developers <
cfe-dev at cs.uiuc.edu>,djasper at google.com,klimek at google.com 
Betreff: [cfe-dev] LibTooling vs. LibClang+Python for simple refactoring 

Tooling, specifically the clang-fixit till is one place sheet efforts are 
being made to apply these kinds of refractoriness (specifically 
clang-fixit would apply predefined naming convention rules, rather than 
user specified renaming).
One of the things that tooling might help you with would be the necessary 
reformatting (clang-format) and build/source discovery.
On Sunday, December 29, 2013 3:49:06 AM, Schlottke, Michael <m.schlottke@
fz-juelich.de> wrote:
Hi everyone,
For our research group, I need to get started with some relatively simple 
refactoring tasks in a modestly complex C++ project. The goal is to have a 
tool that (in the beginning) is good for at least two things:
- renaming member variables/methods
- replacing member variable access by getters/setters
After the extremely positive experiences I've had with clang (and since 
the IDE tools I tried failed for our project), I'd like to utilize the 
clang infrastructure for this task. However, in the very beginning I 
already face the problem of where I should start:
On the one hand, LibTooling seems to be the interface of choice when it 
comes to refactoring code (it's one of the canonical examples on http://
clang.llvm.org/docs/Tooling.html). On the other hand libclang seems to be 
easier to use, has Python bindings, and from the outset looks like it 
could be already sufficient for the task at hand.
Do you have any experience/recommendations for which library is the one to 
use in this case?
Michael Schlottke
SimLab Highly Scalable Fluids & Solids Engineering
Jülich Supercomputing Centre (JSC)
Forschungszentrum Jülich GmbH
52425 Jülich
Phone: +49 (2461) 61 2326
Mail: m.schlottke at fz-juelich.de
Web: http://www.fz-juelich.de/jsc
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt

cfe-dev mailing list
cfe-dev at cs.uiuc.edu
cfe-dev mailing list
cfe-dev at cs.uiuc.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140101/0987c208/attachment.html>

More information about the cfe-dev mailing list