[cfe-dev] [PATCH] libclang: report error code for bad PCH files
Dmitri Gribenko
gribozavr at gmail.com
Wed Feb 12 03:04:21 PST 2014
On Wed, Feb 12, 2014 at 2:05 AM, Argyrios Kyrtzidis <kyrtzidis at apple.com> wrote:
> This seems more complicated than it’s worth, particularly since we do add a new API that the caller must be aware of, anyway.
>
> How about for the functions that don’t support detailed error codes we just introduce a new variant that does support error codes ?
> Clients interested in the error codes can move to calling the new function (whether we should deprecate the existing one or not is a different question).
This does seem cleaner. With this approach, we will have to introduce
three new APIs, mirroring the following:
clang_createTranslationUnitFromSourceFile
clang_createTranslationUnit
clang_parseTranslationUnit
While these APIs already return error codes:
clang_reparseTranslationUnit
clang_indexSourceFile
Compared to this, the approach that I proposed has at least two advantages:
- only a single new API;
- allows us to report more detailed errors -- for example, which PCH
file specifically was bad.
OTOH, there is a huge disadvantage of my approach: the erroneous TU is
ignored by all APIs, and the client that does not check for the error
with the new API will just see that TU as completely empty. I think
this is bad enough to justify addition of three new APIs. I will
update the patch.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the cfe-dev
mailing list