chpatrick / clang-pure

Easy C++ code analysis with pure Haskell
Apache License 2.0
35 stars 20 forks source link

Expose all arguments of clang_createIndex and clang_parseTranslationUnit2 #15

Closed kodemeister closed 5 years ago

kodemeister commented 5 years ago

Hi @chpatrick,

This PR adds two new functions createIndexWithOptions and parseTranslationUnitWithOptions that support all arguments of libclang's clang_createIndex and clang_parseTranslationUnit2. Now you can write something like this:

let code = "int main(int argc, char **argv) { return 0; }"
idx <- createIndexWithOptions [DisplayDiagnostics]
tu <- parseTranslationUnitWithOptions idx "main.cpp" ["-Wall"] [("main.cpp", code)] [SkipFunctionBodies]

These additional options are useful to fine-tune Clang parser and process in-memory files.

I kept existing functions createIndex and parseTranslationUnit for backward compatibility but implemented them as shortcuts to createIndexWithOptions and parseTranslationUnitWithOptions.

Thanks in advance!


This change is Reviewable

chpatrick commented 5 years ago

Thank you!