any C/C++ refactoring tool based on libclang? (even simplest “toy example” ) [closed]

Clang contains a library called “CIndex” which was developed, I believe, for doing code completion in IDEs. It can also be used for parsing C++ and walking the AST, but doesn’t have anything in the way of refactoring. See Eli Bendersky’s article here.

I have started such a project recently: cmonster. It’s a Python-based API for parsing C++ (using libclang), analyzing the AST, with an interface for “rewriting” (i.e. inserting/removing/modifying source ranges). There’s no nice way (yet) for doing things like modifying function names and having that translated into source-modifications, but it wouldn’t be terribly difficult to do that.

I have not yet created a release with this functionality (although it’s in the github repo), as I’m waiting for llvm/clang 3.0 to be released.

Also, I should point out a couple of things:

  • The code is very rough, calling it alpha would be perhaps generous.
  • I’m by no means an expert on this subject (unlike, say, Dr. Ira Baxter over there).

Adjust expectations appropriately.

Update: cmonster 0.2 has been released, which includes the described features. Check it out on Github.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)