loarabia / Clang-tutorial

A collection of code samples showing usage of clang and llvm as a library
Other
754 stars 122 forks source link

Update tutorial code for latest Clang revision #13

Closed tritao closed 12 years ago

tritao commented 12 years ago

The latest Clang needs to have a CompilerInvocation object set up or else it will crash later on.

    CompilerInvocation cinv;
    CompilerInvocation::CreateFromArgs(cinv, args, args + ARRAY_SIZE(args), ci.getDiagnostics());

    ci.setInvocation(&cinv);

You can either use that overload to set it up from arguments, or need to setup the different options manually.

loarabia commented 12 years ago

Just synced, rebuilt against the lastest in the SVN, and ran every tutorial and I don't see any errors. Can you tell me which one is failing and what the error code is?

Also, what do you consider latest, 3.1 or svn trunk?

tritao commented 12 years ago

Well, you are right. I tested again and it seems to work today.

The problem I had was that the createPreprocessor() call was failing consistently. I stepped into it and it was an Invocation dereference. But now it seems to work without adding setting an explicit CompilerInvocation. CompilerInstance creates a new CompilerInvocation in it's constructor.