[cfe-commits] [PATCH 4/4] [clang.py] TranslationUnit API improvements

Anders Waldenborg anders at 0x63.nu
Mon May 7 23:17:40 PDT 2012


On Mon, May 07, 2012 at 10:08:46PM -0700, Gregory Szorc wrote:
> Everything is addressed.

Looks mostly good to me. A few minor things:

TranslationUnit.from_source documentation should mention
index. Also possibly mention the -x argument in the paragraph
about "C++ in test.c".

I guess you meant to change default value
TranslationUnit.codeComplete unsaved_files to None aswell?

It would be useful if the stringrepresentation of
TranslationUnitSaveError contained which error code it has, so it
is evident what error it is when a backtrace printed
to screen. Did you consider to make the different types of
TranslationUnitSaveError subclasses? e.g:

try:
    tu.save(p)
except TranslationUnitSaveInvalidError:
    handle_invalid()

Instead of:

try:
    tu.save(p)
except TranslationUnitSaveError as e:
    if e.save_error = TranslationUnitSaveError.ERROR_INVALID_TU:
        handle_invalid()
    else:
        raise



 anders



More information about the cfe-commits mailing list