diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,46 @@
+# Revision history for libclang-bindings
+
+## 0.1.0.0 -- 2026-07-14
+
+### Breaking changes
+
+* Removed `LLVM_CONFIG` configuration variable. Configure `PATH` so that the
+  desired `llvm-config` is found instead.
+
+### New features
+
+* Add a binding for `clang_isBeforeInTranslationUnit`. This function is only
+  available for Clang versions 20.1 and newer; see [PR-53][pr-53].
+* Add a binding for the `clang_Type_getOffsetOf` function. See [PR #37][pr-37].
+* Add a new `clang_disposeToken` function to free a single `CXToken`. This is a
+  helper function alongside the existing `clang_disposeTokens` functions, which
+  frees arrays of `CXToken`s. See [PR#42][pr-42].
+* Add a new `foldTry` function that behaves like `foldWitHandler`, but it
+  returns the caught exception as a value like `Control.Exception.try` would.
+  The caught exception is represented using a new type called `FoldException`.
+  See [PR #47][pr-47]
+* Add a compile-time check of the `CLANG_VERSION` macro. See the
+  `Clang.Version.checkUserClangVersion` documentation for details.
+* Add `--with-so` option to the `configure` script, used to work around Cabal
+  linking issues.
+* Add the `Clang.Discover` module, providing `getPaths` to discover the `clang`
+  executable and the builtin include directory.
+
+### Minor changes
+
+### Bug fixes
+
+* Silence `-Wdeprecated-declarations` warnings emitted by `<clang-c/Index.h>`
+  on Clang 21 at the system-header include sites only, so that deprecation
+  warnings for libclang APIs we actually call remain visible. See
+  [issue #58][issue-58].
+
+[pr-37]: https://github.com/well-typed/libclang/pull/37
+[pr-42]: https://github.com/well-typed/libclang/pull/42
+[pr-47]: https://github.com/well-typed/libclang/pull/47
+[pr-53]: https://github.com/well-typed/libclang/pull/53
+[issue-58]: https://github.com/well-typed/libclang/issues/58
+
+## 0.1.0-alpha -- 2026-02-06
+
+* Release candidate.
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,29 @@
+Copyright (c) 2024-2026, Well-Typed LLP and Anduril Industries Inc.
+
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of the copyright holder nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
new file mode 100644
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+# `libclang-bindings`
+
+`libclang-bindings` is a [Haskell][] library that provides bindings for the
+[LLVM/Clang][] `libclang` C API. It supports the [`hs-bindgen`][] project but
+can be used independently.
+
+`libclang-bindings` requires an LLVM/Clang installation and some build
+configuration; see the [manual][] before use.
+
+[Haskell]: <https://www.haskell.org/>
+[`hs-bindgen`]: <https://github.com/well-typed/hs-bindgen>
+[LLVM/Clang]: <https://github.com/llvm/llvm-project>
+[manual]: <https://github.com/well-typed/libclang-bindings/blob/main/manual/README.md>
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import Distribution.Simple (autoconfUserHooks, defaultMainWithHooks)
+
+main :: IO ()
+main = defaultMainWithHooks autoconfUserHooks
diff --git a/autogen/Version_libclang_bindings.hs.in b/autogen/Version_libclang_bindings.hs.in
new file mode 100644
--- /dev/null
+++ b/autogen/Version_libclang_bindings.hs.in
@@ -0,0 +1,8 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Version_libclang_bindings where
+
+import Data.Text (Text)
+
+clangVersionCompileTime :: Text
+clangVersionCompileTime = "@LIBCLANG_VERSION_STRING@"
diff --git a/autogen/clang_config.h.in b/autogen/clang_config.h.in
new file mode 100644
--- /dev/null
+++ b/autogen/clang_config.h.in
@@ -0,0 +1,54 @@
+/* autogen/clang_config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the 'clang_isBeforeInTranslationUnit' function. */
+#undef HAVE_CLANG_ISBEFOREINTRANSLATIONUNIT
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
+   required in a freestanding environment). This macro is provided for
+   backward compatibility; new code need not use it. */
+#undef STDC_HEADERS
diff --git a/autogen/libclang_version.h.in b/autogen/libclang_version.h.in
new file mode 100644
--- /dev/null
+++ b/autogen/libclang_version.h.in
@@ -0,0 +1,12 @@
+#ifndef LIBCLANG_VERSION_H
+#define LIBCLANG_VERSION_H
+
+#define LIBCLANG_VERSION_MAJOR @LIBCLANG_VERSION_MAJOR@
+#define LIBCLANG_VERSION_MINOR @LIBCLANG_VERSION_MINOR@
+#define LIBCLANG_VERSION_PATCH @LIBCLANG_VERSION_PATCH@
+
+#define MIN_VERSION_LIBCLANG(major,minor,patch) ( \
+  (major)*10000+(minor)*100+(patch) <= \
+    (LIBCLANG_VERSION_MAJOR)*10000+(LIBCLANG_VERSION_MINOR)*100+(LIBCLANG_VERSION_PATCH))
+
+#endif // LIBCLANG_VERSION_H
diff --git a/cbits/clang_wrappers.c b/cbits/clang_wrappers.c
new file mode 100644
--- /dev/null
+++ b/cbits/clang_wrappers.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+
+#include "clang_wrappers.h"
+
+/**
+ * Traversing the AST with cursors
+ *
+ * We need a function pointer to `wrap_visitor`, so this cannot be defined as
+ * `static inline` in the header file.
+ */
+
+enum CXChildVisitResult wrap_visitor(CXCursor cursor, CXCursor parent, CXClientData client_data) {
+    WrapCXCursorVisitor visitor = client_data;
+    return visitor(&cursor, &parent);
+}
+
+/**
+ * Debugging
+ */
+
+void clang_breakpoint(void) {
+    static int i = 0;
+    fprintf(stderr, "clang_breakpoint: %d\n", ++i);
+}
+
diff --git a/cbits/clang_wrappers.h b/cbits/clang_wrappers.h
new file mode 100644
--- /dev/null
+++ b/cbits/clang_wrappers.h
@@ -0,0 +1,85 @@
+#ifndef CLANG_WRAPPERS_H
+#define CLANG_WRAPPERS_H
+
+#include "libclang_version.h"
+
+#if LIBCLANG_VERSION_MAJOR == 21
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+#include <clang-c/Index.h>
+#if LIBCLANG_VERSION_MAJOR == 21
+#pragma GCC diagnostic pop
+#endif
+
+#include <stdio.h>
+#include "clang_wrappers_ffi.h"
+
+/**
+ * Wrappers for clang functions that take structs, or return them, by value.
+ *
+ * For functions that return structs by value, we instead expect a buffer to be
+ * preallocated Haskell-side.
+ */
+
+/**
+ * Traversing the AST with cursors
+ *
+ * NOTE: The visitor is passed the two cursors as pointers, but those pointers
+ * are pointers to the /stack/. If these pointers can outlive their scope, then
+ * the visitor should copy them to the heap.
+ */
+
+typedef enum CXChildVisitResult(*WrapCXCursorVisitor)(CXCursor* cursor, CXCursor* parent);
+
+enum CXChildVisitResult wrap_visitor(CXCursor cursor, CXCursor parent, CXClientData client_data);
+
+static inline unsigned wrap_visitChildren(const CXCursor* parent, WrapCXCursorVisitor visitor) {
+    return clang_visitChildren(*parent, &wrap_visitor, visitor);
+}
+
+/**
+ * Type information for CXCursors
+ */
+
+static inline enum CXTypeKind wrap_cxtKind(const CXType* type) {
+    return type->kind;
+}
+
+static inline signed int wrap_compareTypes(const CXType *A, const CXType *B) {
+    if (A->data[0] < B->data[0]) {
+        return -1;
+    } else if (A->data[0] > B->data[0]) {
+        return +1;
+    } else {
+        if (A->data[1] < B->data[1]) {
+            return -1;
+        } else if(A->data[1] > B->data[1]) {
+            return +1;
+        } else {
+            return 0;
+        }
+    }
+}
+
+/**
+ * Call `clang_getUnqualifiedType`
+ *
+ * This function does not exist in versions before Clang 16.  This function acts
+ * as a no-op in that case, and `result` should not be used.
+ *
+ * Calling this function with an invalid CT results in a segfault.
+ */
+static inline void wrap_getUnqualifiedType(const CXType* CT, CXType* result) {
+    #if CINDEX_VERSION_MINOR >= 63
+        *result = clang_getUnqualifiedType(*CT);
+    #endif
+}
+
+/**
+ * Debugging
+ */
+
+void clang_breakpoint(void);
+
+#endif
diff --git a/cbits/clang_wrappers_ffi.h b/cbits/clang_wrappers_ffi.h
new file mode 100644
--- /dev/null
+++ b/cbits/clang_wrappers_ffi.h
@@ -0,0 +1,716 @@
+/* this header is autogenerated with cabal run libclang-bootstrap */
+
+#include "clang_config.h"
+
+/* *** Top-level *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX.html> */
+
+/* OMITTED: CXIndex             clang_createIndexWithOptions (const CXIndexOptions * options); */
+
+/* OMITTED: void                clang_CXIndex_setGlobalOptions (CXIndex, unsigned options); */
+
+/* OMITTED: unsigned            clang_CXIndex_getGlobalOptions (CXIndex); */
+
+/* OMITTED: void                clang_CXIndex_setInvocationEmissionPathOption (CXIndex, const char * Path); */
+
+/* OMITTED: unsigned            clang_isFileMultipleIncludeGuarded (CXTranslationUnit tu, CXFile file); */
+
+static inline void wrap_getLocation(CXTranslationUnit tu, CXFile file, unsigned line, unsigned column, CXSourceLocation * result) {
+  *result = clang_getLocation(tu, file, line, column);
+}
+
+/* OMITTED: CXSourceLocation    clang_getLocationForOffset (CXTranslationUnit tu, CXFile file, unsigned offset); */
+
+/* OMITTED: CXSourceRangeList * clang_getSkippedRanges (CXTranslationUnit tu, CXFile file); */
+
+/* OMITTED: CXSourceRangeList * clang_getAllSkippedRanges (CXTranslationUnit tu); */
+
+/* OMITTED: CXDiagnosticSet     clang_getDiagnosticSetFromTU (CXTranslationUnit Unit); */
+
+/* *** Diagnostic reporting *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html> */
+
+/* OMITTED: CXDiagnosticSet           clang_loadDiagnostics (const char * file, enum CXLoadDiag_Error * error, CXString * errorString); */
+
+static inline void wrap_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options, CXString * result) {
+  *result = clang_formatDiagnostic(Diagnostic, Options);
+}
+
+static inline void wrap_getDiagnosticLocation(CXDiagnostic Diag, CXSourceLocation * result) {
+  *result = clang_getDiagnosticLocation(Diag);
+}
+
+static inline void wrap_getDiagnosticSpelling(CXDiagnostic Diag, CXString * result) {
+  *result = clang_getDiagnosticSpelling(Diag);
+}
+
+static inline void wrap_getDiagnosticOption(CXDiagnostic Diag, CXString * Disable, CXString * result) {
+  *result = clang_getDiagnosticOption(Diag, Disable);
+}
+
+static inline void wrap_getDiagnosticCategoryText(CXDiagnostic Diag, CXString * result) {
+  *result = clang_getDiagnosticCategoryText(Diag);
+}
+
+static inline void wrap_getDiagnosticRange(CXDiagnostic Diagnostic, unsigned Range, CXSourceRange * result) {
+  *result = clang_getDiagnosticRange(Diagnostic, Range);
+}
+
+static inline void wrap_getDiagnosticFixIt(CXDiagnostic Diagnostic, unsigned FixIt, CXSourceRange * ReplacementRange, CXString * result) {
+  *result = clang_getDiagnosticFixIt(Diagnostic, FixIt, ReplacementRange);
+}
+
+/* *** File manipulation routines *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html> */
+
+static inline void wrap_getFileName(CXFile SFile, CXString * result) {
+  *result = clang_getFileName(SFile);
+}
+
+/* OMITTED: time_t   clang_getFileTime (CXFile SFile); */
+
+/* OMITTED: int      clang_getFileUniqueID (CXFile file, CXFileUniqueID * outID); */
+
+/* OMITTED: int      clang_File_isEqual (CXFile file1, CXFile file2); */
+
+/* OMITTED: CXString clang_File_tryGetRealPathName (CXFile file); */
+
+/* *** Physical source locations *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html> */
+
+/* OMITTED: CXSourceLocation clang_getNullLocation (void); */
+
+/* OMITTED: unsigned         clang_equalLocations (CXSourceLocation loc1, CXSourceLocation loc2); */
+
+#ifdef HAVE_CLANG_ISBEFOREINTRANSLATIONUNIT
+
+static inline unsigned wrap_isBeforeInTranslationUnit(const CXSourceLocation * loc1, const CXSourceLocation * loc2) {
+  return clang_isBeforeInTranslationUnit(*loc1, *loc2);
+}
+
+#endif
+
+/* OMITTED: int              clang_Location_isInSystemHeader (CXSourceLocation location); */
+
+static inline int wrap_Location_isFromMainFile(const CXSourceLocation * location) {
+  return clang_Location_isFromMainFile(*location);
+}
+
+/* OMITTED: CXSourceRange    clang_getNullRange (void); */
+
+static inline void wrap_getRange(const CXSourceLocation * begin, const CXSourceLocation * end, CXSourceRange * result) {
+  *result = clang_getRange(*begin, *end);
+}
+
+/* OMITTED: unsigned         clang_equalRanges (CXSourceRange range1, CXSourceRange range2); */
+
+static inline int wrap_Range_isNull(const CXSourceRange * range) {
+  return clang_Range_isNull(*range);
+}
+
+static inline void wrap_getExpansionLocation(const CXSourceLocation * location, CXFile * file, unsigned * line, unsigned * column, unsigned * offset) {
+  return clang_getExpansionLocation(*location, file, line, column, offset);
+}
+
+static inline void wrap_getPresumedLocation(const CXSourceLocation * location, CXString * filename, unsigned * line, unsigned * column) {
+  return clang_getPresumedLocation(*location, filename, line, column);
+}
+
+/* OMITTED: void             clang_getInstantiationLocation (CXSourceLocation location, CXFile * file, unsigned * line, unsigned * column, unsigned * offset); */
+
+static inline void wrap_getSpellingLocation(const CXSourceLocation * location, CXFile * file, unsigned * line, unsigned * column, unsigned * offset) {
+  return clang_getSpellingLocation(*location, file, line, column, offset);
+}
+
+static inline void wrap_getFileLocation(const CXSourceLocation * location, CXFile * file, unsigned * line, unsigned * column, unsigned * offset) {
+  return clang_getFileLocation(*location, file, line, column, offset);
+}
+
+static inline void wrap_getRangeStart(const CXSourceRange * range, CXSourceLocation * result) {
+  *result = clang_getRangeStart(*range);
+}
+
+static inline void wrap_getRangeEnd(const CXSourceRange * range, CXSourceLocation * result) {
+  *result = clang_getRangeEnd(*range);
+}
+
+/* OMITTED: void             clang_disposeSourceRangeList (CXSourceRangeList * ranges); */
+
+/* *** String manipulation routines *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__STRING.html> */
+
+static inline const char * wrap_getCString(const CXString * string) {
+  return clang_getCString(*string);
+}
+
+static inline void wrap_disposeString(const CXString * string) {
+  return clang_disposeString(*string);
+}
+
+/* OMITTED: void         clang_disposeStringSet (CXStringSet * set); */
+
+/* *** Translation unit manipulation *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html> */
+
+/* OMITTED: CXString          clang_getTranslationUnitSpelling (CXTranslationUnit CTUnit); */
+
+/* OMITTED: CXTranslationUnit clang_createTranslationUnitFromSourceFile (CXIndex CIdx, const char * source_filename, int num_clang_command_line_args, const char * const * clang_command_line_args, unsigned num_unsaved_files, struct CXUnsavedFile * unsaved_files); */
+
+/* OMITTED: CXTranslationUnit clang_createTranslationUnit (CXIndex CIdx, const char * ast_filename); */
+
+/* OMITTED: enum CXErrorCode  clang_createTranslationUnit2 (CXIndex CIdx, const char * ast_filename, CXTranslationUnit * out_TU); */
+
+/* OMITTED: unsigned          clang_defaultEditingTranslationUnitOptions (void); */
+
+/* OMITTED: enum CXErrorCode  clang_parseTranslationUnit2FullArgv (CXIndex CIdx, const char * source_filename, const char * const * command_line_args, int num_command_line_args, struct CXUnsavedFile * unsaved_files, unsigned num_unsaved_files, unsigned options, CXTranslationUnit * out_TU); */
+
+/* OMITTED: unsigned          clang_defaultSaveOptions (CXTranslationUnit TU); */
+
+/* OMITTED: int               clang_saveTranslationUnit (CXTranslationUnit TU, const char * FileName, unsigned options); */
+
+/* OMITTED: unsigned          clang_suspendTranslationUnit (CXTranslationUnit TU); */
+
+/* OMITTED: unsigned          clang_defaultReparseOptions (CXTranslationUnit TU); */
+
+/* OMITTED: int               clang_reparseTranslationUnit (CXTranslationUnit TU, unsigned num_unsaved_files, struct CXUnsavedFile * unsaved_files, unsigned options); */
+
+/* OMITTED: const char *      clang_getTUResourceUsageName (enum CXTUResourceUsageKind kind); */
+
+/* OMITTED: CXTUResourceUsage clang_getCXTUResourceUsage (CXTranslationUnit TU); */
+
+/* OMITTED: void              clang_disposeCXTUResourceUsage (CXTUResourceUsage usage); */
+
+static inline void wrap_TargetInfo_getTriple(CXTargetInfo Info, CXString * result) {
+  *result = clang_TargetInfo_getTriple(Info);
+}
+
+/* OMITTED: int               clang_TargetInfo_getPointerWidth (CXTargetInfo Info); */
+
+/* *** Cursor manipulations *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html> */
+
+static inline void wrap_getNullCursor(CXCursor * result) {
+  *result = clang_getNullCursor();
+}
+
+static inline void wrap_getTranslationUnitCursor(CXTranslationUnit TU, CXCursor * result) {
+  *result = clang_getTranslationUnitCursor(TU);
+}
+
+static inline unsigned wrap_equalCursors(const CXCursor * C1, const CXCursor * C2) {
+  return clang_equalCursors(*C1, *C2);
+}
+
+static inline int wrap_Cursor_isNull(const CXCursor * C) {
+  return clang_Cursor_isNull(*C);
+}
+
+static inline unsigned wrap_hashCursor(const CXCursor * C) {
+  return clang_hashCursor(*C);
+}
+
+static inline enum CXCursorKind wrap_getCursorKind(const CXCursor * C) {
+  return clang_getCursorKind(*C);
+}
+
+static inline unsigned wrap_isInvalidDeclaration(const CXCursor * C) {
+  return clang_isInvalidDeclaration(*C);
+}
+
+static inline unsigned wrap_Cursor_hasAttrs(const CXCursor * C) {
+  return clang_Cursor_hasAttrs(*C);
+}
+
+static inline enum CXLinkageKind wrap_getCursorLinkage(const CXCursor * cursor) {
+  return clang_getCursorLinkage(*cursor);
+}
+
+static inline enum CXVisibilityKind wrap_getCursorVisibility(const CXCursor * cursor) {
+  return clang_getCursorVisibility(*cursor);
+}
+
+static inline enum CXAvailabilityKind wrap_getCursorAvailability(const CXCursor * cursor) {
+  return clang_getCursorAvailability(*cursor);
+}
+
+/* OMITTED: int                     clang_getCursorPlatformAvailability (CXCursor cursor, int * always_deprecated, CXString * deprecated_message, int * always_unavailable, CXString * unavailable_message, CXPlatformAvailability * availability, int availability_size); */
+
+/* OMITTED: void                    clang_disposeCXPlatformAvailability (CXPlatformAvailability * availability); */
+
+static inline void wrap_Cursor_getVarDeclInitializer(const CXCursor * cursor, CXCursor * result) {
+  *result = clang_Cursor_getVarDeclInitializer(*cursor);
+}
+
+static inline int wrap_Cursor_hasVarDeclGlobalStorage(const CXCursor * cursor) {
+  return clang_Cursor_hasVarDeclGlobalStorage(*cursor);
+}
+
+static inline int wrap_Cursor_hasVarDeclExternalStorage(const CXCursor * cursor) {
+  return clang_Cursor_hasVarDeclExternalStorage(*cursor);
+}
+
+/* OMITTED: enum CXLanguageKind     clang_getCursorLanguage (CXCursor cursor); */
+
+static inline enum CXTLSKind wrap_getCursorTLSKind(const CXCursor * cursor) {
+  return clang_getCursorTLSKind(*cursor);
+}
+
+static inline CXTranslationUnit wrap_Cursor_getTranslationUnit(const CXCursor * cursor) {
+  return clang_Cursor_getTranslationUnit(*cursor);
+}
+
+/* OMITTED: CXCursorSet             clang_createCXCursorSet (void); */
+
+/* OMITTED: void                    clang_disposeCXCursorSet (CXCursorSet cset); */
+
+/* OMITTED: unsigned                clang_CXCursorSet_contains (CXCursorSet cset, CXCursor cursor); */
+
+/* OMITTED: unsigned                clang_CXCursorSet_insert (CXCursorSet cset, CXCursor cursor); */
+
+static inline void wrap_getCursorSemanticParent(const CXCursor * cursor, CXCursor * result) {
+  *result = clang_getCursorSemanticParent(*cursor);
+}
+
+static inline void wrap_getCursorLexicalParent(const CXCursor * cursor, CXCursor * result) {
+  *result = clang_getCursorLexicalParent(*cursor);
+}
+
+/* OMITTED: void                    clang_getOverriddenCursors (CXCursor cursor, CXCursor * * overridden, unsigned * num_overridden); */
+
+/* OMITTED: void                    clang_disposeOverriddenCursors (CXCursor * overridden); */
+
+static inline CXFile wrap_getIncludedFile(const CXCursor * cursor) {
+  return clang_getIncludedFile(*cursor);
+}
+
+/* *** Mapping between cursors and source code  *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html> */
+
+/* OMITTED: CXCursor         clang_getCursor (CXTranslationUnit TU, CXSourceLocation Source); */
+
+static inline void wrap_getCursorLocation(const CXCursor * cursor, CXSourceLocation * result) {
+  *result = clang_getCursorLocation(*cursor);
+}
+
+static inline void wrap_getCursorExtent(const CXCursor * cursor, CXSourceRange * result) {
+  *result = clang_getCursorExtent(*cursor);
+}
+
+/* *** Type information for CXCursors *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html> */
+
+static inline void wrap_getCursorType(const CXCursor * C, CXType * result) {
+  *result = clang_getCursorType(*C);
+}
+
+static inline void wrap_getTypeSpelling(const CXType * CT, CXString * result) {
+  *result = clang_getTypeSpelling(*CT);
+}
+
+static inline void wrap_getTypedefDeclUnderlyingType(const CXCursor * C, CXType * result) {
+  *result = clang_getTypedefDeclUnderlyingType(*C);
+}
+
+static inline void wrap_getEnumDeclIntegerType(const CXCursor * C, CXType * result) {
+  *result = clang_getEnumDeclIntegerType(*C);
+}
+
+static inline long long wrap_getEnumConstantDeclValue(const CXCursor * C) {
+  return clang_getEnumConstantDeclValue(*C);
+}
+
+static inline unsigned long long wrap_getEnumConstantDeclUnsignedValue(const CXCursor * C) {
+  return clang_getEnumConstantDeclUnsignedValue(*C);
+}
+
+static inline unsigned wrap_Cursor_isBitField(const CXCursor * C) {
+  return clang_Cursor_isBitField(*C);
+}
+
+static inline int wrap_getFieldDeclBitWidth(const CXCursor * C) {
+  return clang_getFieldDeclBitWidth(*C);
+}
+
+static inline int wrap_Cursor_getNumArguments(const CXCursor * C) {
+  return clang_Cursor_getNumArguments(*C);
+}
+
+static inline void wrap_Cursor_getArgument(const CXCursor * C, unsigned i, CXCursor * result) {
+  *result = clang_Cursor_getArgument(*C, i);
+}
+
+/* OMITTED: int                         clang_Cursor_getNumTemplateArguments (CXCursor C); */
+
+/* OMITTED: enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind (CXCursor C, unsigned I); */
+
+/* OMITTED: CXType                      clang_Cursor_getTemplateArgumentType (CXCursor C, unsigned I); */
+
+/* OMITTED: long long                   clang_Cursor_getTemplateArgumentValue (CXCursor C, unsigned I); */
+
+/* OMITTED: unsigned long long          clang_Cursor_getTemplateArgumentUnsignedValue (CXCursor C, unsigned I); */
+
+static inline unsigned wrap_equalTypes(const CXType * A, const CXType * B) {
+  return clang_equalTypes(*A, *B);
+}
+
+static inline void wrap_getCanonicalType(const CXType * T, CXType * result) {
+  *result = clang_getCanonicalType(*T);
+}
+
+static inline unsigned wrap_isConstQualifiedType(const CXType * T) {
+  return clang_isConstQualifiedType(*T);
+}
+
+static inline unsigned wrap_Cursor_isMacroFunctionLike(const CXCursor * C) {
+  return clang_Cursor_isMacroFunctionLike(*C);
+}
+
+static inline unsigned wrap_Cursor_isMacroBuiltin(const CXCursor * C) {
+  return clang_Cursor_isMacroBuiltin(*C);
+}
+
+static inline unsigned wrap_Cursor_isFunctionInlined(const CXCursor * C) {
+  return clang_Cursor_isFunctionInlined(*C);
+}
+
+static inline unsigned wrap_isVolatileQualifiedType(const CXType * T) {
+  return clang_isVolatileQualifiedType(*T);
+}
+
+static inline unsigned wrap_isRestrictQualifiedType(const CXType * T) {
+  return clang_isRestrictQualifiedType(*T);
+}
+
+static inline unsigned wrap_getAddressSpace(const CXType * T) {
+  return clang_getAddressSpace(*T);
+}
+
+static inline void wrap_getTypedefName(const CXType * CT, CXString * result) {
+  *result = clang_getTypedefName(*CT);
+}
+
+static inline void wrap_getPointeeType(const CXType * T, CXType * result) {
+  *result = clang_getPointeeType(*T);
+}
+
+/* OMITTED: CXType                      clang_getUnqualifiedType (CXType CT); // NOTE: does not exist before clang-16, so we define a custom wrapper in clang_wrappers.h */
+
+/* OMITTED: CXType                      clang_getNonReferenceType (CXType CT); */
+
+static inline void wrap_getTypeDeclaration(const CXType * T, CXCursor * result) {
+  *result = clang_getTypeDeclaration(*T);
+}
+
+/* OMITTED: CXString                    clang_getDeclObjCTypeEncoding (CXCursor C); */
+
+/* OMITTED: CXString                    clang_Type_getObjCEncoding (CXType type); */
+
+static inline void wrap_getTypeKindSpelling(enum CXTypeKind K, CXString * result) {
+  *result = clang_getTypeKindSpelling(K);
+}
+
+/* OMITTED: enum CXCallingConv          clang_getFunctionTypeCallingConv (CXType T); */
+
+static inline void wrap_getResultType(const CXType * T, CXType * result) {
+  *result = clang_getResultType(*T);
+}
+
+/* OMITTED: int                         clang_getExceptionSpecificationType (CXType T); */
+
+static inline int wrap_getNumArgTypes(const CXType * T) {
+  return clang_getNumArgTypes(*T);
+}
+
+static inline void wrap_getArgType(const CXType * T, unsigned i, CXType * result) {
+  *result = clang_getArgType(*T, i);
+}
+
+static inline void wrap_Type_getObjCObjectBaseType(const CXType * T, CXType * result) {
+  *result = clang_Type_getObjCObjectBaseType(*T);
+}
+
+static inline unsigned wrap_Type_getNumObjCProtocolRefs(const CXType * T) {
+  return clang_Type_getNumObjCProtocolRefs(*T);
+}
+
+static inline void wrap_Type_getObjCProtocolDecl(const CXType * T, unsigned i, CXCursor * result) {
+  *result = clang_Type_getObjCProtocolDecl(*T, i);
+}
+
+static inline unsigned wrap_Type_getNumObjCTypeArgs(const CXType * T) {
+  return clang_Type_getNumObjCTypeArgs(*T);
+}
+
+static inline void wrap_Type_getObjCTypeArg(const CXType * T, unsigned i, CXType * result) {
+  *result = clang_Type_getObjCTypeArg(*T, i);
+}
+
+static inline unsigned wrap_isFunctionTypeVariadic(const CXType * T) {
+  return clang_isFunctionTypeVariadic(*T);
+}
+
+static inline void wrap_getCursorResultType(const CXCursor * C, CXType * result) {
+  *result = clang_getCursorResultType(*C);
+}
+
+static inline int wrap_getCursorExceptionSpecificationType(const CXCursor * C) {
+  return clang_getCursorExceptionSpecificationType(*C);
+}
+
+static inline unsigned wrap_isPODType(const CXType * T) {
+  return clang_isPODType(*T);
+}
+
+static inline void wrap_getElementType(const CXType * T, CXType * result) {
+  *result = clang_getElementType(*T);
+}
+
+static inline long long wrap_getNumElements(const CXType * T) {
+  return clang_getNumElements(*T);
+}
+
+static inline void wrap_getArrayElementType(const CXType * T, CXType * result) {
+  *result = clang_getArrayElementType(*T);
+}
+
+static inline long long wrap_getArraySize(const CXType * T) {
+  return clang_getArraySize(*T);
+}
+
+static inline void wrap_Type_getNamedType(const CXType * T, CXType * result) {
+  *result = clang_Type_getNamedType(*T);
+}
+
+static inline unsigned wrap_Type_isTransparentTagTypedef(const CXType * T) {
+  return clang_Type_isTransparentTagTypedef(*T);
+}
+
+/* OMITTED: enum CXTypeNullabilityKind  clang_Type_getNullability (CXType T); */
+
+static inline long long wrap_Type_getAlignOf(const CXType * T) {
+  return clang_Type_getAlignOf(*T);
+}
+
+/* OMITTED: CXType                      clang_Type_getClassType (CXType T); */
+
+static inline long long wrap_Type_getSizeOf(const CXType * T) {
+  return clang_Type_getSizeOf(*T);
+}
+
+static inline long long wrap_Type_getOffsetOf(const CXType * T, const char * S) {
+  return clang_Type_getOffsetOf(*T, S);
+}
+
+static inline void wrap_Type_getModifiedType(const CXType * T, CXType * result) {
+  *result = clang_Type_getModifiedType(*T);
+}
+
+static inline void wrap_Type_getValueType(const CXType * CT, CXType * result) {
+  *result = clang_Type_getValueType(*CT);
+}
+
+static inline long long wrap_Cursor_getOffsetOfField(const CXCursor * C) {
+  return clang_Cursor_getOffsetOfField(*C);
+}
+
+static inline unsigned wrap_Cursor_isAnonymous(const CXCursor * C) {
+  return clang_Cursor_isAnonymous(*C);
+}
+
+static inline unsigned wrap_Cursor_isAnonymousRecordDecl(const CXCursor * C) {
+  return clang_Cursor_isAnonymousRecordDecl(*C);
+}
+
+/* OMITTED: unsigned                    clang_Cursor_isInlineNamespace (CXCursor C); */
+
+/* OMITTED: int                         clang_Type_getNumTemplateArguments (CXType T); */
+
+/* OMITTED: CXType                      clang_Type_getTemplateArgumentAsType (CXType T, unsigned i); */
+
+/* OMITTED: enum CXRefQualifierKind     clang_Type_getCXXRefQualifier (CXType T); */
+
+/* OMITTED: unsigned                    clang_isVirtualBase (CXCursor C); */
+
+/* OMITTED: long long                   clang_getOffsetOfBase (CXCursor Parent, CXCursor Base); */
+
+/* OMITTED: enum CX_CXXAccessSpecifier  clang_getCXXAccessSpecifier (CXCursor C); */
+
+/* OMITTED: enum CX_BinaryOperatorKind  clang_Cursor_getBinaryOpcode (CXCursor C); */
+
+/* OMITTED: CXString                    clang_Cursor_getBinaryOpcodeStr (enum CX_BinaryOperatorKind Op); */
+
+static inline enum CX_StorageClass wrap_Cursor_getStorageClass(const CXCursor * C) {
+  return clang_Cursor_getStorageClass(*C);
+}
+
+/* OMITTED: unsigned                    clang_getNumOverloadedDecls (CXCursor cursor); */
+
+/* OMITTED: CXCursor                    clang_getOverloadedDecl (CXCursor cursor, unsigned index); */
+
+/* *** Traversing the AST with cursors *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html> */
+
+/* OMITTED: unsigned clang_visitChildren (CXCursor parent, CXCursorVisitor visitor, CXClientData client_data); */
+
+/* OMITTED: unsigned clang_visitChildrenWithBlock (CXCursor parent, CXCursorVisitorBlock block); */
+
+/* *** Cross-referencing in the AST  *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html> */
+
+/* OMITTED: CXString         clang_getCursorUSR (CXCursor); */
+
+/* OMITTED: CXString         clang_constructUSR_ObjCClass (const char * class_name); */
+
+/* OMITTED: CXString         clang_constructUSR_ObjCCategory (const char * class_name, const char * category_name); */
+
+/* OMITTED: CXString         clang_constructUSR_ObjCProtocol (const char * protocol_name); */
+
+/* OMITTED: CXString         clang_constructUSR_ObjCIvar (const char * name, CXString classUSR); */
+
+/* OMITTED: CXString         clang_constructUSR_ObjCMethod (const char * name, unsigned isInstanceMethod, CXString classUSR); */
+
+/* OMITTED: CXString         clang_constructUSR_ObjCProperty (const char * property, CXString classUSR); */
+
+static inline void wrap_getCursorSpelling(const CXCursor * C, CXString * result) {
+  *result = clang_getCursorSpelling(*C);
+}
+
+static inline void wrap_Cursor_getSpellingNameRange(const CXCursor * C, unsigned pieceIndex, unsigned options, CXSourceRange * result) {
+  *result = clang_Cursor_getSpellingNameRange(*C, pieceIndex, options);
+}
+
+/* OMITTED: unsigned         clang_PrintingPolicy_getProperty (CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property); */
+
+/* OMITTED: void             clang_PrintingPolicy_setProperty (CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property, unsigned Value); */
+
+static inline CXPrintingPolicy wrap_getCursorPrintingPolicy(const CXCursor * C) {
+  return clang_getCursorPrintingPolicy(*C);
+}
+
+static inline void wrap_getCursorPrettyPrinted(const CXCursor * Cursor, CXPrintingPolicy Policy, CXString * result) {
+  *result = clang_getCursorPrettyPrinted(*Cursor, Policy);
+}
+
+/* OMITTED: CXString         clang_getTypePrettyPrinted (CXType CT, CXPrintingPolicy cxPolicy); */
+
+/* OMITTED: CXString         clang_getFullyQualifiedName (CXType CT, CXPrintingPolicy Policy, unsigned WithGlobalNsPrefix); */
+
+static inline void wrap_getCursorDisplayName(const CXCursor * C, CXString * result) {
+  *result = clang_getCursorDisplayName(*C);
+}
+
+static inline void wrap_getCursorReferenced(const CXCursor * C, CXCursor * result) {
+  *result = clang_getCursorReferenced(*C);
+}
+
+static inline void wrap_getCursorDefinition(const CXCursor * C, CXCursor * result) {
+  *result = clang_getCursorDefinition(*C);
+}
+
+static inline unsigned wrap_isCursorDefinition(const CXCursor * C) {
+  return clang_isCursorDefinition(*C);
+}
+
+static inline void wrap_getCanonicalCursor(const CXCursor * C, CXCursor * result) {
+  *result = clang_getCanonicalCursor(*C);
+}
+
+/* OMITTED: int              clang_Cursor_getObjCSelectorIndex (CXCursor); */
+
+/* OMITTED: int              clang_Cursor_isDynamicCall (CXCursor C); */
+
+/* OMITTED: CXType           clang_Cursor_getReceiverType (CXCursor C); */
+
+/* OMITTED: unsigned         clang_Cursor_getObjCPropertyAttributes (CXCursor C, unsigned reserved); */
+
+/* OMITTED: CXString         clang_Cursor_getObjCPropertyGetterName (CXCursor C); */
+
+/* OMITTED: CXString         clang_Cursor_getObjCPropertySetterName (CXCursor C); */
+
+/* OMITTED: unsigned         clang_Cursor_getObjCDeclQualifiers (CXCursor C); */
+
+/* OMITTED: unsigned         clang_Cursor_isObjCOptional (CXCursor C); */
+
+/* OMITTED: unsigned         clang_Cursor_isVariadic (CXCursor C); */
+
+/* OMITTED: unsigned         clang_Cursor_isExternalSymbol (CXCursor C, CXString * language, CXString * definedIn, unsigned * isGenerated); */
+
+/* OMITTED: CXSourceRange    clang_Cursor_getCommentRange (CXCursor C); */
+
+static inline void wrap_Cursor_getRawCommentText(const CXCursor * C, CXString * result) {
+  *result = clang_Cursor_getRawCommentText(*C);
+}
+
+static inline void wrap_Cursor_getBriefCommentText(const CXCursor * C, CXString * result) {
+  *result = clang_Cursor_getBriefCommentText(*C);
+}
+
+/* *** Token extraction and manipulation *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html> */
+
+static inline CXToken * wrap_getToken(CXTranslationUnit TU, const CXSourceLocation * Location) {
+  return clang_getToken(TU, *Location);
+}
+
+static inline CXTokenKind wrap_getTokenKind(const CXToken * Token) {
+  return clang_getTokenKind(*Token);
+}
+
+static inline void wrap_getTokenSpelling(CXTranslationUnit TU, const CXToken * Token, CXString * result) {
+  *result = clang_getTokenSpelling(TU, *Token);
+}
+
+static inline void wrap_getTokenLocation(CXTranslationUnit TU, const CXToken * Token, CXSourceLocation * result) {
+  *result = clang_getTokenLocation(TU, *Token);
+}
+
+static inline void wrap_getTokenExtent(CXTranslationUnit TU, const CXToken * Token, CXSourceRange * result) {
+  *result = clang_getTokenExtent(TU, *Token);
+}
+
+static inline void wrap_tokenize(CXTranslationUnit TU, const CXSourceRange * Range, CXToken * * Tokens, unsigned * NumTokens) {
+  return clang_tokenize(TU, *Range, Tokens, NumTokens);
+}
+
+/* *** Debugging facilities *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__DEBUG.html> */
+
+static inline void wrap_getCursorKindSpelling(enum CXCursorKind Kind, CXString * result) {
+  *result = clang_getCursorKindSpelling(Kind);
+}
+
+/* OMITTED: void     clang_getDefinitionSpellingAndExtent (CXCursor, const char * * startBuf, const char * * endBuf, unsigned * startLine, unsigned * startColumn, unsigned * endLine, unsigned * endColumn); */
+
+/* OMITTED: void     clang_enableStackTraces (void); */
+
+/* OMITTED: void     clang_executeOnThread (void(*fn)(void *), void * user_data, unsigned stack_size); // NOTE: function pointer syntax not supported by the libclang-bootstrap parser */
+
+/* *** Miscellaneous utility functions *** */
+
+/* <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html> */
+
+static inline void wrap_getClangVersion(CXString * result) {
+  *result = clang_getClangVersion();
+}
+
+/* OMITTED: void               clang_toggleCrashRecovery (unsigned isEnabled); */
+
+/* OMITTED: void               clang_getInclusions (CXTranslationUnit tu, CXInclusionVisitor visitor, CXClientData client_data); */
+
+static inline CXEvalResult wrap_Cursor_Evaluate(const CXCursor * C) {
+  return clang_Cursor_Evaluate(*C);
+}
+
diff --git a/cbits/doxygen_wrappers.h b/cbits/doxygen_wrappers.h
new file mode 100644
--- /dev/null
+++ b/cbits/doxygen_wrappers.h
@@ -0,0 +1,207 @@
+#ifndef DOXYGEN_WRAPPERS_H
+#define DOXYGEN_WRAPPERS_H
+
+#include "libclang_version.h"
+
+/**
+ * Wrappers for the Doxygen API
+ *
+ * All functions that we use are wrapped.  Prefix `clang_` of the actual
+ * function name is replaced with `wrap_`.  This allows us to import the wrapped
+ * function via FFI and define the Haskell function with the actual function
+ * name within the same module.
+ *
+ * Wrapper functions of functions that return values of primitive types keep the
+ * same API.  Wrapper functions of functions that return values of non-primitive
+ * types use a `result` parameter instead.
+ *
+ * The LLVM codebase capitalizes parameter names.  Wrapper functions keep this
+ * convention for such parameters, while `result` is not capitalized.
+ */
+
+#if LIBCLANG_VERSION_MAJOR == 21
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+#include <clang-c/Documentation.h>
+#if LIBCLANG_VERSION_MAJOR == 21
+#pragma GCC diagnostic pop
+#endif
+
+/**
+ * Top-level
+ */
+
+static inline void wrap_Cursor_getParsedComment(const CXCursor* C, CXComment* result) {
+    *result = clang_Cursor_getParsedComment(*C);
+}
+
+static inline enum CXCommentKind wrap_Comment_getKind(const CXComment* Comment) {
+    return clang_Comment_getKind(*Comment);
+}
+
+static inline unsigned wrap_Comment_getNumChildren(const CXComment* Comment) {
+    return clang_Comment_getNumChildren(*Comment);
+}
+
+static inline void wrap_Comment_getChild(const CXComment* Comment, unsigned ChildIdx, CXComment* result) {
+    *result = clang_Comment_getChild(*Comment, ChildIdx);
+}
+
+static inline unsigned wrap_Comment_isWhitespace(const CXComment* Comment) {
+    return clang_Comment_isWhitespace(*Comment);
+}
+
+static inline unsigned wrap_InlineContentComment_hasTrailingNewline(const CXComment* Comment) {
+    return clang_InlineContentComment_hasTrailingNewline(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_Text'
+ */
+
+static inline void wrap_TextComment_getText(const CXComment* Comment, CXString*  result) {
+    *result = clang_TextComment_getText(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_InlineCommand'
+ */
+
+static inline void wrap_InlineCommandComment_getCommandName(const CXComment* Comment, CXString*  result) {
+    *result = clang_InlineCommandComment_getCommandName(*Comment);
+}
+
+static inline enum CXCommentInlineCommandRenderKind wrap_InlineCommandComment_getRenderKind(const CXComment* Comment) {
+    return clang_InlineCommandComment_getRenderKind(*Comment);
+}
+
+static inline unsigned wrap_InlineCommandComment_getNumArgs(const CXComment* Comment) {
+    return clang_InlineCommandComment_getNumArgs(*Comment);
+}
+
+static inline void wrap_InlineCommandComment_getArgText(const CXComment* Comment, unsigned ArgIdx, CXString* result) {
+    *result = clang_InlineCommandComment_getArgText(*Comment, ArgIdx);
+}
+
+/**
+ * Comment type 'CXComment_HTMLStartTag' and 'CXComment_HTMLEndTag'
+ */
+
+static inline void wrap_HTMLTagComment_getTagName(const CXComment* Comment, CXString*  result) {
+    *result = clang_HTMLTagComment_getTagName(*Comment);
+}
+
+static inline unsigned wrap_HTMLStartTagComment_isSelfClosing(const CXComment* Comment) {
+    return clang_HTMLStartTagComment_isSelfClosing(*Comment);
+}
+
+static inline unsigned wrap_HTMLStartTag_getNumAttrs(const CXComment* Comment) {
+    return clang_HTMLStartTag_getNumAttrs(*Comment);
+}
+
+static inline void wrap_HTMLStartTag_getAttrName(const CXComment* Comment, unsigned AttrIdx, CXString*  result) {
+    *result = clang_HTMLStartTag_getAttrName(*Comment, AttrIdx);
+}
+
+static inline void wrap_HTMLStartTag_getAttrValue(const CXComment* Comment, unsigned AttrIdx, CXString*  result) {
+    *result = clang_HTMLStartTag_getAttrValue(*Comment, AttrIdx);
+}
+
+static inline void wrap_HTMLTagComment_getAsString(const CXComment* Comment, CXString*  result) {
+    *result = clang_HTMLTagComment_getAsString(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_BlockCommand'
+ */
+
+static inline void wrap_BlockCommandComment_getCommandName(const CXComment* Comment, CXString*  result) {
+    *result = clang_BlockCommandComment_getCommandName(*Comment);
+}
+
+static inline unsigned wrap_BlockCommandComment_getNumArgs(const CXComment* Comment) {
+    return clang_BlockCommandComment_getNumArgs(*Comment);
+}
+
+static inline void wrap_BlockCommandComment_getArgText(const CXComment* Comment, unsigned ArgIdx, CXString*  result) {
+    *result = clang_BlockCommandComment_getArgText(*Comment, ArgIdx);
+}
+
+static inline void wrap_BlockCommandComment_getParagraph(const CXComment* Comment, CXComment* result) {
+    *result = clang_BlockCommandComment_getParagraph(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_ParamCommand'
+ */
+
+static inline void wrap_ParamCommandComment_getParamName(const CXComment* Comment, CXString*  result) {
+    *result = clang_ParamCommandComment_getParamName(*Comment);
+}
+
+static inline unsigned wrap_ParamCommandComment_isParamIndexValid(const CXComment* Comment) {
+    return clang_ParamCommandComment_isParamIndexValid(*Comment);
+}
+
+static inline unsigned wrap_ParamCommandComment_getParamIndex(const CXComment* Comment) {
+    return clang_ParamCommandComment_getParamIndex(*Comment);
+}
+
+static inline unsigned wrap_ParamCommandComment_isDirectionExplicit(const CXComment* Comment) {
+    return clang_ParamCommandComment_isDirectionExplicit(*Comment);
+}
+
+static inline enum CXCommentParamPassDirection wrap_ParamCommandComment_getDirection(const CXComment* Comment) {
+    return clang_ParamCommandComment_getDirection(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_TParamCommand'
+ */
+
+static inline void wrap_TParamCommandComment_getParamName(const CXComment* Comment, CXString*  result) {
+    *result = clang_TParamCommandComment_getParamName(*Comment);
+}
+
+static inline unsigned wrap_TParamCommandComment_isParamPositionValid(const CXComment* Comment) {
+    return clang_TParamCommandComment_isParamPositionValid(*Comment);
+}
+
+static inline unsigned wrap_TParamCommandComment_getDepth(const CXComment* Comment) {
+    return clang_TParamCommandComment_getDepth(*Comment);
+}
+
+static inline unsigned wrap_TParamCommandComment_getIndex(const CXComment* Comment, unsigned Depth) {
+    return clang_TParamCommandComment_getIndex(*Comment, Depth);
+}
+
+/**
+ * Comment type 'CXComment_VerbatimBlockLine'
+ */
+
+static inline void wrap_VerbatimBlockLineComment_getText(const CXComment* Comment, CXString*  result) {
+    *result = clang_VerbatimBlockLineComment_getText(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_VerbatimLine'
+ */
+
+static inline void wrap_VerbatimLineComment_getText(const CXComment* Comment, CXString*  result) {
+    *result = clang_VerbatimLineComment_getText(*Comment);
+}
+
+/**
+ * Comment type 'CXComment_FullComment'
+ */
+
+static inline void wrap_FullComment_getAsHTML(const CXComment* Comment, CXString*  result) {
+    *result = clang_FullComment_getAsHTML(*Comment);
+}
+
+static inline void wrap_FullComment_getAsXML(const CXComment* Comment, CXString*  result) {
+    *result = clang_FullComment_getAsXML(*Comment);
+}
+
+#endif
diff --git a/cbits/rewrite_wrappers.h b/cbits/rewrite_wrappers.h
new file mode 100644
--- /dev/null
+++ b/cbits/rewrite_wrappers.h
@@ -0,0 +1,23 @@
+#ifndef REWRITE_WRAPPERS_H
+#define REWRITE_WRAPPERS_H
+
+#include "libclang_version.h"
+
+/**
+ * Wrappers for the Rewrite API
+ */
+
+#if LIBCLANG_VERSION_MAJOR == 21
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+#include <clang-c/Rewrite.h>
+#if LIBCLANG_VERSION_MAJOR == 21
+#pragma GCC diagnostic pop
+#endif
+
+static inline void wrap_CXRewriter_insertTextBefore(CXRewriter Rew, const CXSourceLocation *Loc, const char *Insert) {
+    clang_CXRewriter_insertTextBefore(Rew, *Loc, Insert);
+}
+
+#endif
diff --git a/clang-tutorial/clang-tutorial.hs b/clang-tutorial/clang-tutorial.hs
new file mode 100644
--- /dev/null
+++ b/clang-tutorial/clang-tutorial.hs
@@ -0,0 +1,122 @@
+-- * Haskell translation of the @libclang@ tutorial
+--
+-- See <https://clang.llvm.org/docs/LibClang.html>
+module Main (main) where
+
+import Control.Monad
+import Data.Default (Default (def))
+import Data.Text qualified as Text
+import System.Environment
+
+import Clang.Enum.Bitfield
+import Clang.Enum.Simple
+import Clang.LowLevel.Core
+import Clang.Paths
+
+{-------------------------------------------------------------------------------
+  Reproduce the clang tutorial in Haskell
+-------------------------------------------------------------------------------}
+
+tutorial :: FilePath -> IO ()
+tutorial fp = do
+    --
+    -- Obtain a cursor at the root of the translation unit
+    --
+
+    index  <- clang_createIndex DontDisplayDiagnostics
+    unit   <- clang_parseTranslationUnit
+                index
+                (Just $ SourcePath (Text.pack fp))
+                def
+                []
+                (bitfieldEnum [CXTranslationUnit_None])
+    cursor <- clang_getTranslationUnitCursor unit
+
+    --
+    -- Visiting elements of an AST
+    --
+
+    _terminatedPrematurely <- clang_visitChildren
+      cursor -- Root cursor
+      (\current_cursor _parent -> do
+
+        current_display_name <- clang_getCursorDisplayName current_cursor
+        putStrLn $ "Visiting element " ++ show current_display_name
+
+        --
+        -- Extracting information from a Cursor
+        --
+
+        -- Extracting the Cursor kind
+
+        cursor_type        <- clang_getCursorType current_cursor
+        type_kind_spelling <- clang_getTypeKindSpelling (cxtKind cursor_type)
+        putStrLn $ concat [
+            "  "
+          , "Type Kind: " ++ show type_kind_spelling
+          , " (" ++ show (fromSimpleEnum $ cxtKind cursor_type) ++ ")"
+          ]
+
+        when (isPointerType $ cxtKind cursor_type) $ do
+          pointed_to_type          <- clang_getPointeeType(cursor_type)
+          pointed_to_type_spelling <- clang_getTypeSpelling pointed_to_type
+          putStrLn $ "  pointing to type: " ++ show pointed_to_type_spelling
+
+        when (isRecordType $ cxtKind cursor_type) $ do
+          type_spelling <- clang_getTypeSpelling cursor_type
+          putStrLn $ "  namely " ++ show type_spelling
+
+        --
+        -- Retrieving source locations
+        --
+
+        cursor_spelling <- clang_getCursorSpelling current_cursor
+        cursor_range    <- clang_getCursorExtent current_cursor
+        range_start     <- clang_getRangeStart cursor_range
+        range_end       <- clang_getRangeEnd   cursor_range
+        (_, start_line, start_column, _) <-
+          clang_getExpansionLocation range_start
+        (_, end_line, end_column, _) <-
+          clang_getExpansionLocation range_end
+        putStrLn $ concat [
+            "  Cursor " ++ show cursor_spelling
+          , " spanning lines "
+          , show start_line ++ ":" ++ show start_column
+          , " to "
+          , show end_line ++ ":" ++ show end_column
+          ]
+
+        return $ simpleEnum CXChildVisit_Recurse
+      )
+
+    return ()
+
+{-------------------------------------------------------------------------------
+  Classifying types
+-------------------------------------------------------------------------------}
+
+-- | Check if this is a pointer type
+--
+-- Pointer types are types for which we can call 'clang_getPointeeType'.
+isPointerType :: SimpleEnum CXTypeKind -> Bool
+isPointerType = either (const False) aux . fromSimpleEnum
+  where
+    aux :: CXTypeKind -> Bool
+    aux CXType_Pointer         = True
+    aux CXType_LValueReference = True
+    aux CXType_RValueReference = True
+    aux _                      = False
+
+isRecordType :: SimpleEnum CXTypeKind -> Bool
+isRecordType = (== Right CXType_Record) . fromSimpleEnum
+
+{-------------------------------------------------------------------------------
+  Main application
+-------------------------------------------------------------------------------}
+
+main :: IO ()
+main = do
+    args <- getArgs
+    case args of
+        fp : _ -> tutorial fp
+        _      -> return ()
diff --git a/configure b/configure
new file mode 100644
--- /dev/null
+++ b/configure
@@ -0,0 +1,5290 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.73 for libclang-bindings 0.1.0.0.
+#
+#
+# Copyright (C) 1992-1996, 1998-2017, 2020-2026 Free Software Foundation,
+# Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # contradicts POSIX and common usage.  Disable this.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else case e in #(
+  e) case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac ;;
+esac
+fi
+
+
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
+as_nl='
+'
+export as_nl
+IFS=" ""	$as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
+
+# The user is always right.
+if ${PATH_SEPARATOR+false} :; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as 'sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  printf '%s\n' "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+case $# in # ((
+  0) exec $CONFIG_SHELL $as_opts "$as_myself" ;;
+  *) exec $CONFIG_SHELL $as_opts "$as_myself" "$@" ;;
+esac
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed 'exec'.
+printf '%s\n' "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # contradicts POSIX and common usage.  Disable this.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else case e in #(
+  e) case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" )
+then :
+
+else case e in #(
+  e) exitcode=1; echo positional parameters were not saved. ;;
+esac
+fi
+test x\$exitcode = x0 || exit 1
+blah=\$(echo \$(echo blah))
+test x\"\$blah\" = xblah || exit 1
+test -x / || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"
+  if (eval "$as_required") 2>/dev/null
+then :
+  as_have_required=yes
+else case e in #(
+  e) as_have_required=no ;;
+esac
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null
+then :
+
+else case e in #(
+  e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+  as_found=:
+  case $as_dir in #(
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     # Try only shells that exist, to save several forks.
+	     as_shell=$as_dir$as_base
+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		    as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+		   if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null
+then :
+  break 2
+fi
+fi
+	   done;;
+       esac
+  as_found=false
+done
+IFS=$as_save_IFS
+if $as_found
+then :
+
+else case e in #(
+  e) if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null
+then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi ;;
+esac
+fi
+
+
+      if test "x$CONFIG_SHELL" != x
+then :
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+case $# in # ((
+  0) exec $CONFIG_SHELL $as_opts "$as_myself" ;;
+  *) exec $CONFIG_SHELL $as_opts "$as_myself" "$@" ;;
+esac
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed 'exec'.
+printf '%s\n' "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+    if test x$as_have_required = xno
+then :
+  printf '%s\n' "$0: This script requires a shell more modern than all"
+  printf '%s\n' "$0: the shells that I found on your system."
+  if test ${ZSH_VERSION+y} ; then
+    printf '%s\n' "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    printf '%s\n' "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    printf '%s\n' "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi ;;
+esac
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`printf '%s\n' "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+printf '%s\n' X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null
+then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else case e in #(
+  e) as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  } ;;
+esac
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else case e in #(
+  e) as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  } ;;
+esac
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  printf '%s\n' "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+printf '%s\n' X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      t clear
+      :clear
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { printf '%s\n' "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable.
+    # In both cases, we have to default to 'cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated
+
+# Sed expression to map a string onto a valid variable name.
+as_sed_sh="y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+as_tr_sh="eval sed '$as_sed_sh'" # deprecated
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_CONFIG_STATUS=
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='libclang-bindings'
+PACKAGE_TARNAME='libclang-bindings'
+PACKAGE_VERSION='0.1.0.0'
+PACKAGE_STRING='libclang-bindings 0.1.0.0'
+PACKAGE_BUGREPORT=''
+PACKAGE_URL=''
+
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stddef.h>
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_header_c_list=
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+LIBCLANG_VERSION_PATCH
+LIBCLANG_VERSION_MINOR
+LIBCLANG_VERSION_MAJOR
+LIBCLANG_VERSION_STRING
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+CLANG_INCLUDE_DIR
+CLANG_LIB_DIRS
+CLANG_LIB
+LLVM_CONFIG
+LLVM_PATH
+ECHO_T
+ECHO_N
+ECHO_C
+target_alias
+host_alias
+build_alias
+LIBS
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+runstatedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+with_compiler
+with_so
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+LLVM_PATH
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
+  esac
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: '$ac_useropt'"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`printf '%s\n' "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: '$ac_useropt'"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`printf '%s\n' "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: '$ac_useropt'"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`printf '%s\n' "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: '$ac_useropt'"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`printf '%s\n' "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error $? "unrecognized option: '$ac_option'
+Try '$0 --help' for more information"
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: '$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    printf '%s\n' "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      printf '%s\n' "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`printf '%s\n' $ac_prev | sed 's/_/-/g'`
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     printf '%s\n' "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir runstatedir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: '$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+printf '%s\n' X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but 'cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+'configure' configures libclang-bindings 0.1.0.0 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print 'checking ...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for '--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or '..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, 'make install' will install all the files in
+'$ac_default_prefix/bin', '$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than '$ac_default_prefix' using '--prefix',
+for instance '--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root
+                          [DATAROOTDIR/doc/libclang-bindings]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of libclang-bindings 0.1.0.0:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-compiler         Haskell compiler
+
+  --with-so=PATH          shared library to link to
+
+Some influential environment variables:
+  LLVM_PATH   Location of LLVM installation
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+
+Use these variables to override the choices made by 'configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`printf '%s\n' "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`printf '%s\n' "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for configure.gnu first; this name is used for a wrapper for
+    # Metaconfig's "Configure" on case-insensitive file systems.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      printf '%s\n' "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+libclang-bindings configure 0.1.0.0
+generated by GNU Autoconf 2.73
+
+Copyright (C) 2026 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest.beam
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext
+then :
+  ac_retval=0
+else case e in #(
+  e) printf '%s\n' "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1 ;;
+esac
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  eval "$3=yes"
+else case e in #(
+  e) eval "$3=no" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
+esac
+fi
+eval ac_res=\$$3
+	       { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf '%s\n' "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }
+then :
+  ac_retval=0
+else case e in #(
+  e) printf '%s\n' "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1 ;;
+esac
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+printf %s "checking for $2... " >&6; }
+if eval test \${$3+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+   which can conflict with char $2 (void); below.  */
+
+#include <limits.h>
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 (void);
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main (void)
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  eval "$3=yes"
+else case e in #(
+  e) eval "$3=no" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext ;;
+esac
+fi
+eval ac_res=\$$3
+	       { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf '%s\n' "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+ac_configure_args_raw=
+for ac_arg
+do
+  case $ac_arg in
+  *\'*)
+    ac_arg=`printf '%s\n' "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  as_fn_append ac_configure_args_raw " '$ac_arg'"
+done
+
+case $ac_configure_args_raw in
+  *$as_nl*)
+    ac_safe_unquote= ;;
+  *)
+    ac_unsafe_z='|&;<>()$`\\"*?[ ''	' # This string ends in space, tab.
+    ac_unsafe_a="$ac_unsafe_z#~"
+    ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"
+    ac_configure_args_raw=`      printf '%s\n' "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;
+esac
+
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by libclang-bindings $as_me 0.1.0.0, which was
+generated by GNU Autoconf 2.73.  Invocation command line was
+
+  $ $0$ac_configure_args_raw
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    printf '%s\n' "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`printf '%s\n' "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+	ac_must_keep_next=false # Got value, back to normal.
+      else
+	case $ac_arg in
+	  *=* | --config-cache | -C | -disable-* | --disable-* \
+	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+	  | -with-* | --with-* | -without-* | --without-* | --x)
+	    case "$ac_configure_args0 " in
+	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+	    esac
+	    ;;
+	  -* ) ac_must_keep_next=true ;;
+	esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# Dump the cache to stdout.  It can be in a pipe (this is a requirement).
+ac_cache_dump ()
+{
+  # The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+printf '%s\n' "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # 'set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+	"s/'/'\\\\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # 'set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+}
+
+# Print debugging info to stdout.
+ac_dump_debugging_info ()
+{
+  echo
+
+  printf '%s\n' "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+  echo
+  ac_cache_dump
+  echo
+
+  printf '%s\n' "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+  echo
+  for ac_var in $ac_subst_vars
+  do
+    eval ac_val=\$$ac_var
+    case $ac_val in
+    *\'*) ac_val=`printf '%s\n' "$ac_val" | sed "s/'/'\\\\\\\\''/g"`;;
+    esac
+    printf '%s\n' "$ac_var='$ac_val'"
+  done | sort
+  echo
+
+  if test -n "$ac_subst_files"; then
+    printf '%s\n' "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+    echo
+    for ac_var in $ac_subst_files
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'*) ac_val=`printf '%s\n' "$ac_val" | sed "s/'/'\\\\\\\\''/g"`;;
+      esac
+      printf '%s\n' "$ac_var='$ac_val'"
+    done | sort
+    echo
+  fi
+
+  if test -s confdefs.h; then
+    printf '%s\n' "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+    echo
+    cat confdefs.h
+    echo
+  fi
+  test "$ac_signal" != 0 &&
+    printf '%s\n' "$as_me: caught signal $ac_signal"
+  printf '%s\n' "$as_me: exit $exit_status"
+}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.
+ac_exit_trap ()
+{
+  exit_status=
+  # Sanitize IFS.
+  IFS=" ""	$as_nl"
+  # Save into config.log some information that might help in debugging.
+  ac_dump_debugging_info >&5
+  eval "rm -f $ac_clean_CONFIG_STATUS core *.core core.conftest.*" &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+}
+
+trap 'ac_exit_trap $?' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+printf '%s\n' "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+printf '%s\n' "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h
+
+printf '%s\n' "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h
+
+printf '%s\n' "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h
+
+printf '%s\n' "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h
+
+printf '%s\n' "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h
+
+printf '%s\n' "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+if test -n "$CONFIG_SITE"; then
+  ac_site_files="$CONFIG_SITE"
+elif test "x$prefix" != xNONE; then
+  ac_site_files="$prefix/share/config.site $prefix/etc/config.site"
+else
+  ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+fi
+
+for ac_site_file in $ac_site_files
+do
+  case $ac_site_file in #(
+  */*) :
+     ;; #(
+  *) :
+    ac_site_file=./$ac_site_file ;;
+esac
+  if test -f "$ac_site_file" && test -r "$ac_site_file"; then
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+printf '%s\n' "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file" \
+      || { { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See 'config.log' for more details" "$LINENO" 5; }
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+printf '%s\n' "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+printf '%s\n' "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Test code for whether the C compiler supports C23 (global declarations)
+ac_c_conftest_c23_globals='
+/* Does the compiler advertise conformance to C17 or earlier?
+   Although GCC 14 does not do that, even with -std=gnu23,
+   it is close enough, and defines __STDC_VERSION == 202000L.  */
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ <= 201710L
+# error "Compiler advertises conformance to C17 or earlier"
+#endif
+
+// Check alignas.
+char alignas (double) c23_aligned_as_double;
+char alignas (0) c23_no_special_alignment;
+extern char c23_aligned_as_int;
+char alignas (0) alignas (int) c23_aligned_as_int;
+
+// Check alignof.
+enum
+{
+  c23_int_alignment = alignof (int),
+  c23_int_array_alignment = alignof (int[100]),
+  c23_char_alignment = alignof (char)
+};
+static_assert (0 < -alignof (int), "alignof is signed");
+
+int function_with_unnamed_parameter (int) { return 0; }
+
+void c23_noreturn ();
+
+/* Test parsing of string and char UTF-8 literals (including hex escapes).
+   The parens pacify GCC 15.  */
+bool use_u8 = (!sizeof u8"\xFF") == (!u8'\''x'\'');
+
+bool check_that_bool_works = true | false | !nullptr;
+#if !true
+# error "true does not work in #if"
+#endif
+#if false
+#elifdef __STDC_VERSION__
+#else
+# error "#elifdef does not work"
+#endif
+
+#ifndef __has_c_attribute
+# error "__has_c_attribute not defined"
+#endif
+
+#ifndef __has_include
+# error "__has_include not defined"
+#endif
+
+#define LPAREN() (
+#define FORTY_TWO(x) 42
+#define VA_OPT_TEST(r, x, ...) __VA_OPT__ (FORTY_TWO r x))
+static_assert (VA_OPT_TEST (LPAREN (), 0, <:-) == 42);
+
+static_assert (0b101010 == 42);
+static_assert (0B101010 == 42);
+static_assert (0xDEAD'\''BEEF == 3'\''735'\''928'\''559);
+static_assert (0.500'\''000'\''000 == 0.5);
+
+enum unsignedish : unsigned int { uione = 1 };
+static_assert (0 < -uione);
+
+#include <stddef.h>
+constexpr nullptr_t null_pointer = nullptr;
+
+static typeof (1 + 1L) two () { return 2; }
+static long int three () { return 3; }
+'
+
+# Test code for whether the C compiler supports C23 (body of main).
+ac_c_conftest_c23_main='
+  {
+    label_before_declaration:
+      int arr[10] = {};
+      if (arr[0])
+        goto label_before_declaration;
+      if (!arr[0])
+        goto label_at_end_of_block;
+    label_at_end_of_block:
+  }
+  ok |= !null_pointer;
+  ok |= two != three;
+'
+
+# Test code for whether the C compiler supports C23 (complete).
+ac_c_conftest_c23_program="${ac_c_conftest_c23_globals}
+
+int
+main (int, char **)
+{
+  int ok = 0;
+  ${ac_c_conftest_c23_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C89 (global declarations)
+ac_c_conftest_c89_globals='
+/* Do not test the value of __STDC__, because some compilers define it to 0
+   or do not define it, while otherwise adequately conforming.  */
+
+#include <stddef.h>
+#include <stdarg.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh.  */
+struct buf { int x; };
+struct buf * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (char **p, int i)
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* C89 style stringification. */
+#define noexpand_stringify(a) #a
+const char *stringified = noexpand_stringify(arbitrary+token=sequence);
+
+/* C89 style token pasting.  Exercises some of the corner cases that
+   e.g. old MSVC gets wrong, but not very hard. */
+#define noexpand_concat(a,b) a##b
+#define expand_concat(a,b) noexpand_concat(a,b)
+extern int vA;
+extern int vbee;
+#define aye A
+#define bee B
+int *pvA = &expand_concat(v,aye);
+int *pvbee = &noexpand_concat(v,bee);
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not \xHH hex character constants.
+   These do not provoke an error unfortunately, instead are silently treated
+   as an "x".  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously \x00 != x always comes out true, for an
+   array size at least.  It is necessary to write \x00 == 0 to get something
+   that is true only with -std.  */
+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) '\''x'\''
+int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
+               int, int);'
+
+# Test code for whether the C compiler supports C89 (body of main).
+ac_c_conftest_c89_main='
+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
+'
+
+# Test code for whether the C compiler supports C99 (global declarations)
+ac_c_conftest_c99_globals='
+/* Does the compiler advertise C99 conformance? */
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
+# error "Compiler does not advertise C99 conformance"
+#endif
+
+// See if C++-style comments work.
+
+#include <stdbool.h>
+extern int puts (const char *);
+extern int printf (const char *, ...);
+extern int dprintf (int, const char *, ...);
+extern void *malloc (size_t);
+extern void free (void *);
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+// dprintf is used instead of fprintf to avoid needing to declare
+// FILE and stderr, and "aND" is used instead of "and" to work around
+// GCC bug 40564 which is irrelevant here.
+#define debug(...) dprintf (2, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, aND third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  #error "your preprocessor is broken"
+#endif
+#if BIG_OK
+#else
+  #error "your preprocessor is broken"
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static bool
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str = "";
+  int number = 0;
+  float fnumber = 0;
+
+  while (*format)
+    {
+      switch (*format++)
+	{
+	case '\''s'\'': // string
+	  str = va_arg (args_copy, const char *);
+	  break;
+	case '\''d'\'': // int
+	  number = va_arg (args_copy, int);
+	  break;
+	case '\''f'\'': // float
+	  fnumber = va_arg (args_copy, double);
+	  break;
+	default:
+	  break;
+	}
+    }
+  va_end (args_copy);
+  va_end (args);
+
+  return *str && number && fnumber;
+}
+'
+
+# Test code for whether the C compiler supports C99 (body of main).
+ac_c_conftest_c99_main='
+  // Check bool.
+  _Bool success = false;
+  success |= (argc != 0);
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  const char *restrict newvar = "Another string";
+
+  // Check varargs.
+  success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  static struct incomplete_array *volatile incomplete_array_pointer;
+  struct incomplete_array *ia = incomplete_array_pointer;
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+  // Work around memory leak warnings.
+  free (ia);
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  // Do not test for VLAs, as some otherwise-conforming compilers lack them.
+  // C code should instead use __STDC_NO_VLA__; see Autoconf manual.
+
+  // work around unused variable warnings
+  ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''
+	 || ni.number != 58);
+'
+
+# Test code for whether the C compiler supports C11 (global declarations)
+ac_c_conftest_c11_globals='
+/* Does the compiler advertise C11 conformance? */
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
+# error "Compiler does not advertise C11 conformance"
+#endif
+
+// Check _Alignas.
+char _Alignas (double) aligned_as_double;
+char _Alignas (0) no_special_alignment;
+extern char aligned_as_int;
+char _Alignas (0) _Alignas (int) aligned_as_int;
+
+// Check _Alignof.
+enum
+{
+  int_alignment = _Alignof (int),
+  int_array_alignment = _Alignof (int[100]),
+  char_alignment = _Alignof (char)
+};
+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");
+
+// Check _Noreturn.
+int _Noreturn does_not_return (void) { for (;;) continue; }
+
+// Check _Static_assert.
+struct test_static_assert
+{
+  int x;
+  _Static_assert (sizeof (int) <= sizeof (long int),
+                  "_Static_assert does not work in struct");
+  long int y;
+};
+
+// Check UTF-8 literals.
+#define u8 syntax error!
+char const utf8_literal[] = u8"happens to be ASCII" "another string";
+
+// Check duplicate typedefs.
+typedef long *long_ptr;
+typedef long int *long_ptr;
+typedef long_ptr long_ptr;
+
+// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
+struct anonymous
+{
+  union {
+    struct { int i; int j; };
+    struct { int k; long int l; } w;
+  };
+  int m;
+} v1;
+'
+
+# Test code for whether the C compiler supports C11 (body of main).
+ac_c_conftest_c11_main='
+  _Static_assert ((offsetof (struct anonymous, i)
+		   == offsetof (struct anonymous, w.k)),
+		  "Anonymous union alignment botch");
+  v1.i = 2;
+  v1.w.k = 5;
+  ok |= v1.i != 5;
+'
+
+# Test code for whether the C compiler supports C11 (complete).
+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+${ac_c_conftest_c11_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  ${ac_c_conftest_c11_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C99 (complete).
+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}
+${ac_c_conftest_c99_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  ${ac_c_conftest_c99_main}
+  return ok;
+}
+"
+
+# Test code for whether the C compiler supports C89 (complete).
+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}
+
+int
+main (int argc, char **argv)
+{
+  int ok = 0;
+  ${ac_c_conftest_c89_main}
+  return ok;
+}
+"
+
+as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H"
+as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H"
+as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H"
+as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H"
+as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H"
+as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"
+as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"
+as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"
+as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&5
+printf '%s\n' "$as_me: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was not set in the previous run" >&5
+printf '%s\n' "$as_me: error: '$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=
+	for ac_val in x $ac_old_val; do
+	  ac_old_val_w="$ac_old_val_w $ac_val"
+	done
+	ac_new_val_w=
+	for ac_val in x $ac_new_val; do
+	  ac_new_val_w="$ac_new_val_w $ac_val"
+	done
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: '$ac_var' has changed since the previous run:" >&5
+printf '%s\n' "$as_me: error: '$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&5
+printf '%s\n' "$as_me: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ printf '%s\n' "$as_me:${as_lineno-$LINENO}:   former value:  '$ac_old_val'" >&5
+printf '%s\n' "$as_me:   former value:  '$ac_old_val'" >&2;}
+	{ printf '%s\n' "$as_me:${as_lineno-$LINENO}:   current value: '$ac_new_val'" >&5
+printf '%s\n' "$as_me:   current value: '$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`printf '%s\n' "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+printf '%s\n' "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run '${MAKE-make} distclean' and/or 'rm $cache_file'
+	    and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+
+# Determine whether it's possible to make 'echo' print without a newline.
+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed
+# for compatibility with existing Makefiles.
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+# Check whether --with-compiler was given.
+if test ${with_compiler+y}
+then :
+  withval=$with_compiler;
+fi
+
+
+wt_with_so_path='NOT_SET'
+
+# Check whether --with-so was given.
+if test ${with_so+y}
+then :
+  withval=$with_so; wt_with_so_path=$withval
+fi
+
+case "$wt_with_so_path" in
+  /*)
+    if test ! -f "$wt_with_so_path" ; then
+      as_fn_error $? "--with-so file not found: $wt_with_so_path" "$LINENO" 5
+    fi
+    wt_user_lib_dir="$(dirname "$wt_with_so_path")"
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: with library directory: $wt_user_lib_dir" >&5
+printf '%s\n' "$as_me: with library directory: $wt_user_lib_dir" >&6;}
+    wt_with_so_filename="$(basename "$wt_with_so_path")"
+    wt_with_so_lib_1="${wt_with_so_filename#lib}"
+    if test "$wt_with_so_lib_1" = "$wt_with_so_filename" ; then
+      as_fn_error $? "--with-so file does not have lib prefix: $wt_with_so_path" "$LINENO" 5
+    fi
+    wt_user_lib="${wt_with_so_lib_1%.so}"
+    if test "$wt_user_lib" = "$wt_with_so_lib_1" ; then
+      as_fn_error $? "--with-so file does not have .so suffix: $wt_with_so_path" "$LINENO" 5
+    fi
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: with library: $wt_user_lib" >&5
+printf '%s\n' "$as_me: with library: $wt_user_lib" >&6;}
+    ;;
+  'NOT_SET')
+    ;;
+  '')
+    as_fn_error $? "--with-so specified without an argument" "$LINENO" 5
+    ;;
+  *)
+    as_fn_error $? "--with-so path not absolute: $wt_with_so_path" "$LINENO" 5
+    ;;
+esac
+
+
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking LLVM resolution mode" >&5
+printf %s "checking LLVM resolution mode... " >&6; }
+if test -n "$LLVM_PATH" ; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: LLVM_PATH=$LLVM_PATH" >&5
+printf '%s\n' "LLVM_PATH=$LLVM_PATH" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: llvm-config" >&5
+printf '%s\n' "llvm-config" >&6; }
+  # Extract the first word of "llvm-config", so it can be a program name with args.
+set dummy llvm-config; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_path_LLVM_CONFIG+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) case $LLVM_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LLVM_CONFIG="$LLVM_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_path_LLVM_CONFIG="$as_dir$ac_word$ac_exec_ext"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac ;;
+esac
+fi
+LLVM_CONFIG=$ac_cv_path_LLVM_CONFIG
+if test -n "$LLVM_CONFIG"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5
+printf '%s\n' "$LLVM_CONFIG" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+  if test -z "$LLVM_CONFIG" ; then
+    as_fn_error $? "llvm-config not found and LLVM_PATH not set" "$LINENO" 5
+  fi
+fi
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking llvm-config version" >&5
+printf %s "checking llvm-config version... " >&6; }
+if test -n "$LLVM_PATH" ; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: skipped" >&5
+printf '%s\n' "skipped" >&6; }
+else
+  wt_llvm_config_version="$("$LLVM_CONFIG" --version)"
+  if test $? -eq 0 ; then
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $wt_llvm_config_version" >&5
+printf '%s\n' "$wt_llvm_config_version" >&6; }
+  else
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: error" >&5
+printf '%s\n' "error" >&6; }
+    as_fn_error $? "could not run llvm-config" "$LINENO" 5
+  fi
+fi
+
+# WT_PARSE_VERSION(VERSION_STRING)
+#
+# $wt_parse_version_status is set to 0 on success or 1 on failure
+# $wt_parse_version_major is set to the major version on success
+# $wt_parse_version_minor is set to the minor version on success
+# $wt_parse_version_patch is set to the patch version on success
+#
+# NOTE This macro definition should not use dnl comments.
+
+
+if test -n "$wt_llvm_config_version" ; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking Parsing llvm-config version" >&5
+printf %s "checking Parsing llvm-config version... " >&6; }
+
+  wt_parse_version_major=''
+  wt_parse_version_minor=''
+  wt_parse_version_patch=''
+  wt_parse_version_status=0 # SUCCESS
+  wt_parse_version_input="$wt_llvm_config_version"
+  wt_parse_version_state=0 # STATE_START
+  while test -n "$wt_parse_version_input" ; do
+    wt_parse_version_tail="${wt_parse_version_input#?}"
+    wt_parse_version_head="${wt_parse_version_input%${wt_parse_version_tail}}"
+    wt_parse_version_input="$wt_parse_version_tail"
+    case "$wt_parse_version_head" in
+      0|1|2|3|4|5|6|7|8|9) # NOTE [0-9] does not work for some reason
+        case "$wt_parse_version_state" in
+          0) # STATE_START
+            wt_parse_version_major="${wt_parse_version_head}"
+            wt_parse_version_state=1 # STATE_MAJOR
+            ;;
+          1) # STATE_MAJOR
+            wt_parse_version_major="${wt_parse_version_major}${wt_parse_version_head}"
+            ;;
+          2) # STATE_MAJOR_DOT
+            wt_parse_version_minor="${wt_parse_version_head}"
+            wt_parse_version_state=3 # STATE_MINOR
+            ;;
+          3) # STATE_MINOR
+            wt_parse_version_minor="${wt_parse_version_minor}${wt_parse_version_head}"
+            ;;
+          4) # STATE_MINOR_DOT
+            wt_parse_version_patch="${wt_parse_version_head}"
+            wt_parse_version_state=5 # STATE_PATCH
+            ;;
+          5) # STATE_PATCH
+            wt_parse_version_patch="${wt_parse_version_patch}${wt_parse_version_head}"
+            ;;
+        esac
+        ;;
+      .)
+        case "$wt_parse_version_state" in
+          1) # STATE_MAJOR
+            wt_parse_version_state=2 # STATE_MAJOR_DOT
+            ;;
+          3) # STATE_MINOR
+            wt_parse_version_state=4 # STATE_MINOR_DOT
+            ;;
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=6 # STATE_SKIP
+            ;;
+        esac
+        ;;
+      ' ')
+        case "$wt_parse_version_state" in
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=0 # STATE_START
+            ;;
+        esac
+        ;;
+      *)
+        case "$wt_parse_version_state" in
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=6 # STATE_SKIP
+            ;;
+        esac
+        ;;
+    esac
+  done
+  case "$wt_parse_version_state" in
+    5|7) # STATE_PATCH STATE_SUCCESS
+      ;;
+    *)
+      wt_parse_version_status=1 # FAILURE
+      ;;
+  esac
+
+  if test "$wt_parse_version_status" -eq 0 ; then
+    wt_llvm_config_major="$wt_parse_version_major"
+    wt_llvm_config_minor="$wt_parse_version_minor"
+    wt_llvm_config_patch="$wt_parse_version_patch"
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: major=$wt_llvm_config_major minor=$wt_llvm_config_minor patch=$wt_llvm_config_patch" >&5
+printf '%s\n' "major=$wt_llvm_config_major minor=$wt_llvm_config_minor patch=$wt_llvm_config_patch" >&6; }
+  else
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: error" >&5
+printf '%s\n' "error" >&6; }
+    as_fn_error $? "could not parse llvm-config version" "$LINENO" 5
+  fi
+fi
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking Clang library" >&5
+printf %s "checking Clang library... " >&6; }
+if test -n "$wt_user_lib" ; then
+  wt_clang_lib="$wt_user_lib"
+else
+  wt_clang_lib='clang'
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $wt_clang_lib" >&5
+printf '%s\n' "$wt_clang_lib" >&6; }
+CLANG_LIB="$wt_clang_lib"
+
+LIBS="${LIBS} -l${wt_clang_lib}"
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking LLVM library directories" >&5
+printf %s "checking LLVM library directories... " >&6; }
+if test -n "$LLVM_PATH" ; then
+  wt_clang_lib_dirs="${LLVM_PATH}/lib"
+else
+  wt_clang_lib_dirs="$("$LLVM_CONFIG" --libdir)"
+fi
+if test -n "$wt_user_lib_dir" && test "$wt_user_lib_dir" != "$wt_clang_lib_dirs"; then
+  LDFLAGS="${LDFLAGS} -L${wt_user_lib_dir} -L${wt_clang_lib_dirs}"
+  wt_clang_lib_dirs="${wt_user_lib_dir} ${wt_clang_lib_dirs}"
+else
+  LDFLAGS="${LDFLAGS} -L${wt_clang_lib_dirs}"
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $wt_clang_lib_dirs" >&5
+printf '%s\n' "$wt_clang_lib_dirs" >&6; }
+CLANG_LIB_DIRS="$wt_clang_lib_dirs"
+
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking LLVM include directory" >&5
+printf %s "checking LLVM include directory... " >&6; }
+if test -n "$LLVM_PATH" ; then
+  wt_clang_include_dir="${LLVM_PATH}/include"
+else
+  wt_clang_include_dir="$("$LLVM_CONFIG" --includedir)"
+fi
+CPPFLAGS="${CPPFLAGS} -I${wt_clang_include_dir}"
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $wt_clang_include_dir" >&5
+printf '%s\n' "$wt_clang_include_dir" >&6; }
+CLANG_INCLUDE_DIR="$wt_clang_include_dir"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf '%s\n' "$CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf '%s\n' "$ac_ct_CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf '%s\n' "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf '%s\n' "$CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@"
+  fi
+fi
+fi ;;
+esac
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf '%s\n' "$CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf '%s\n' "$CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf '%s\n' "$ac_ct_CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf '%s\n' "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.
+set dummy ${ac_tool_prefix}clang; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}clang"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+printf '%s\n' "$CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "clang", so it can be a program name with args.
+set dummy clang; ac_word=$2
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+printf %s "checking for $ac_word... " >&6; }
+if test ${ac_cv_prog_ac_ct_CC+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="clang"
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi ;;
+esac
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+printf '%s\n' "$ac_ct_CC" >&6; }
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+printf '%s\n' "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+fi
+
+
+test -z "$CC" && { { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See 'config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion -version; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+printf %s "checking whether the C compiler works... " >&6; }
+ac_link_default=`printf '%s\n' "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to 'no'.
+# So ignore a value of 'no', otherwise this would lead to 'EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an '-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else case e in #(
+  e) ac_file='' ;;
+esac
+fi
+if test -z "$ac_file"
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf '%s\n' "no" >&6; }
+printf '%s\n' "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See 'config.log' for more details" "$LINENO" 5; }
+else case e in #(
+  e) { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf '%s\n' "yes" >&6; } ;;
+esac
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+printf %s "checking for C compiler default output file name... " >&6; }
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+printf '%s\n' "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+printf %s "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
+  # If both 'conftest.exe' and 'conftest' are 'present' (well, observable)
+# catch 'conftest.exe'.  For instance with Cygwin, 'ls conftest' will
+# work properly (i.e., refer to 'conftest.exe'), while it won't with
+# 'rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else case e in #(
+  e) { { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See 'config.log' for more details" "$LINENO" 5; } ;;
+esac
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+printf '%s\n' "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main (void)
+{
+FILE *f = fopen ("conftest.out", "w");
+ if (!f)
+  return 1;
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+printf %s "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error 77 "cannot run C compiled programs.
+If you meant to cross compile, use '--host'.
+See 'config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+printf '%s\n' "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext \
+  conftest.o conftest.obj conftest.out
+ac_clean_files=$ac_clean_files_save
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+printf %s "checking for suffix of object files... " >&6; }
+if test ${ac_cv_objext+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+printf '%s\n' "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  printf '%s\n' "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else case e in #(
+  e) printf '%s\n' "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See 'config.log' for more details" "$LINENO" 5; } ;;
+esac
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext ;;
+esac
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+printf '%s\n' "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5
+printf %s "checking whether the compiler supports GNU C... " >&6; }
+if test ${ac_cv_c_compiler_gnu+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_compiler_gnu=yes
+else case e in #(
+  e) ac_compiler_gnu=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+ ;;
+esac
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+printf '%s\n' "$ac_cv_c_compiler_gnu" >&6; }
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+y}
+ac_save_CFLAGS=$CFLAGS
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+printf %s "checking whether $CC accepts -g... " >&6; }
+if test ${ac_cv_prog_cc_g+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_g=yes
+else case e in #(
+  e) CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+
+else case e in #(
+  e) ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag ;;
+esac
+fi
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+printf '%s\n' "$ac_cv_prog_cc_g" >&6; }
+if test $ac_test_CFLAGS; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+ac_prog_cc_stdc=no
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C23 features" >&5
+printf %s "checking for $CC option to enable C23 features... " >&6; }
+if test ${ac_cv_prog_cc_c23+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) ac_cv_prog_cc_c23=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c23_program
+_ACEOF
+for ac_arg in '' -std=gnu23
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c23=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c23" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC ;;
+esac
+fi
+
+if test "x$ac_cv_prog_cc_c23" = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf '%s\n' "unsupported" >&6; }
+else case e in #(
+  e) if test "x$ac_cv_prog_cc_c23" = x
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf '%s\n' "none needed" >&6; }
+else case e in #(
+  e) { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c23" >&5
+printf '%s\n' "$ac_cv_prog_cc_c23" >&6; }
+     CC="$CC $ac_cv_prog_cc_c23" ;;
+esac
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c23
+  ac_prog_cc_stdc=c23 ;;
+esac
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5
+printf %s "checking for $CC option to enable C11 features... " >&6; }
+if test ${ac_cv_prog_cc_c11+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) ac_cv_prog_cc_c11=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c11_program
+_ACEOF
+for ac_arg in '' -std=gnu11 -std:c11
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c11=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c11" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC ;;
+esac
+fi
+
+if test "x$ac_cv_prog_cc_c11" = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf '%s\n' "unsupported" >&6; }
+else case e in #(
+  e) if test "x$ac_cv_prog_cc_c11" = x
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf '%s\n' "none needed" >&6; }
+else case e in #(
+  e) { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5
+printf '%s\n' "$ac_cv_prog_cc_c11" >&6; }
+     CC="$CC $ac_cv_prog_cc_c11" ;;
+esac
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11
+  ac_prog_cc_stdc=c11 ;;
+esac
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5
+printf %s "checking for $CC option to enable C99 features... " >&6; }
+if test ${ac_cv_prog_cc_c99+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c99_program
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC ;;
+esac
+fi
+
+if test "x$ac_cv_prog_cc_c99" = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf '%s\n' "unsupported" >&6; }
+else case e in #(
+  e) if test "x$ac_cv_prog_cc_c99" = x
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf '%s\n' "none needed" >&6; }
+else case e in #(
+  e) { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+printf '%s\n' "$ac_cv_prog_cc_c99" >&6; }
+     CC="$CC $ac_cv_prog_cc_c99" ;;
+esac
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+  ac_prog_cc_stdc=c99 ;;
+esac
+fi
+fi
+if test x$ac_prog_cc_stdc = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5
+printf %s "checking for $CC option to enable C89 features... " >&6; }
+if test ${ac_cv_prog_cc_c89+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_c_conftest_c89_program
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"
+then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC ;;
+esac
+fi
+
+if test "x$ac_cv_prog_cc_c89" = xno
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+printf '%s\n' "unsupported" >&6; }
+else case e in #(
+  e) if test "x$ac_cv_prog_cc_c89" = x
+then :
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+printf '%s\n' "none needed" >&6; }
+else case e in #(
+  e) { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+printf '%s\n' "$ac_cv_prog_cc_c89" >&6; }
+     CC="$CC $ac_cv_prog_cc_c89" ;;
+esac
+fi
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+  ac_prog_cc_stdc=c89 ;;
+esac
+fi
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_header= ac_cache=
+for ac_item in $ac_header_c_list
+do
+  if test $ac_cache; then
+    ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default"
+    if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then
+      printf '%s\n' "#define $ac_item 1" >> confdefs.h
+    fi
+    ac_header= ac_cache=
+  elif test $ac_header; then
+    ac_cache=$ac_item
+  else
+    ac_header=$ac_item
+  fi
+done
+
+
+
+
+
+
+
+
+if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes
+then :
+
+printf '%s\n' "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+ac_fn_c_check_header_compile "$LINENO" "clang-c/Index.h" "ac_cv_header_clang_c_Index_h" "$ac_includes_default"
+if test "x$ac_cv_header_clang_c_Index_h" = xyes
+then :
+
+else case e in #(
+  e) as_fn_error $? "Cannot find libclang headers" "$LINENO" 5
+ ;;
+esac
+fi
+
+
+as_ac_Lib=`printf '%s\n' "ac_cv_lib_$wt_clang_lib""_clang_createIndex" | sed "$as_sed_sh"`
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for clang_createIndex in -l$wt_clang_lib" >&5
+printf %s "checking for clang_createIndex in -l$wt_clang_lib... " >&6; }
+if eval test \${$as_ac_Lib+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e) ac_check_lib_save_LIBS=$LIBS
+LIBS="-l$wt_clang_lib  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.
+   The 'extern "C"' is for builds by C++ compilers;
+   although this is not generally supported in C code supporting it here
+   has little cost and some practical benefit (sr 110532).  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clang_createIndex (void);
+int
+main (void)
+{
+return clang_createIndex ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  eval "$as_ac_Lib=yes"
+else case e in #(
+  e) eval "$as_ac_Lib=no" ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS ;;
+esac
+fi
+eval ac_res=\$$as_ac_Lib
+	       { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+printf '%s\n' "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Lib"\" = x"yes"
+then :
+  cat >>confdefs.h <<_ACEOF
+#define `printf '%s\n' "HAVE_LIB$wt_clang_lib" | sed "$as_sed_cpp"` 1
+_ACEOF
+
+  LIBS="-l$wt_clang_lib $LIBS"
+
+else case e in #(
+  e) as_fn_error $? "Cannot link against libclang" "$LINENO" 5
+ ;;
+esac
+fi
+
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking libclang version" >&5
+printf %s "checking libclang version... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+      #include <clang-c/Index.h>
+      #include <stdio.h>
+
+int
+main (void)
+{
+
+      CXString cxstring = clang_getClangVersion();
+      printf("%s\n", clang_getCString(cxstring));
+      clang_disposeString(cxstring);
+
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+  wt_libclang_version=$(./conftest$EXEEXT)
+else case e in #(
+  e) { { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "Unable to determine libclang version
+See 'config.log' for more details" "$LINENO" 5; }
+ ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: $wt_libclang_version" >&5
+printf '%s\n' "$wt_libclang_version" >&6; }
+LIBCLANG_VERSION_STRING="$(echo ${wt_libclang_version} | sed 's/\"/\\\"/g')"
+
+
+
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking Parsing libclang version" >&5
+printf %s "checking Parsing libclang version... " >&6; }
+
+  wt_parse_version_major=''
+  wt_parse_version_minor=''
+  wt_parse_version_patch=''
+  wt_parse_version_status=0 # SUCCESS
+  wt_parse_version_input="$wt_libclang_version"
+  wt_parse_version_state=0 # STATE_START
+  while test -n "$wt_parse_version_input" ; do
+    wt_parse_version_tail="${wt_parse_version_input#?}"
+    wt_parse_version_head="${wt_parse_version_input%${wt_parse_version_tail}}"
+    wt_parse_version_input="$wt_parse_version_tail"
+    case "$wt_parse_version_head" in
+      0|1|2|3|4|5|6|7|8|9) # NOTE [0-9] does not work for some reason
+        case "$wt_parse_version_state" in
+          0) # STATE_START
+            wt_parse_version_major="${wt_parse_version_head}"
+            wt_parse_version_state=1 # STATE_MAJOR
+            ;;
+          1) # STATE_MAJOR
+            wt_parse_version_major="${wt_parse_version_major}${wt_parse_version_head}"
+            ;;
+          2) # STATE_MAJOR_DOT
+            wt_parse_version_minor="${wt_parse_version_head}"
+            wt_parse_version_state=3 # STATE_MINOR
+            ;;
+          3) # STATE_MINOR
+            wt_parse_version_minor="${wt_parse_version_minor}${wt_parse_version_head}"
+            ;;
+          4) # STATE_MINOR_DOT
+            wt_parse_version_patch="${wt_parse_version_head}"
+            wt_parse_version_state=5 # STATE_PATCH
+            ;;
+          5) # STATE_PATCH
+            wt_parse_version_patch="${wt_parse_version_patch}${wt_parse_version_head}"
+            ;;
+        esac
+        ;;
+      .)
+        case "$wt_parse_version_state" in
+          1) # STATE_MAJOR
+            wt_parse_version_state=2 # STATE_MAJOR_DOT
+            ;;
+          3) # STATE_MINOR
+            wt_parse_version_state=4 # STATE_MINOR_DOT
+            ;;
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=6 # STATE_SKIP
+            ;;
+        esac
+        ;;
+      ' ')
+        case "$wt_parse_version_state" in
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=0 # STATE_START
+            ;;
+        esac
+        ;;
+      *)
+        case "$wt_parse_version_state" in
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=6 # STATE_SKIP
+            ;;
+        esac
+        ;;
+    esac
+  done
+  case "$wt_parse_version_state" in
+    5|7) # STATE_PATCH STATE_SUCCESS
+      ;;
+    *)
+      wt_parse_version_status=1 # FAILURE
+      ;;
+  esac
+
+if test "$wt_parse_version_status" -eq 0 ; then
+  wt_libclang_major="$wt_parse_version_major"
+  wt_libclang_minor="$wt_parse_version_minor"
+  wt_libclang_patch="$wt_parse_version_patch"
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: major=$wt_libclang_major minor=$wt_libclang_minor patch=$wt_libclang_patch" >&5
+printf '%s\n' "major=$wt_libclang_major minor=$wt_libclang_minor patch=$wt_libclang_patch" >&6; }
+  LIBCLANG_VERSION_MAJOR=$wt_libclang_major
+
+  LIBCLANG_VERSION_MINOR=$wt_libclang_minor
+
+  LIBCLANG_VERSION_PATCH=$wt_libclang_patch
+
+else
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: result: error" >&5
+printf '%s\n' "error" >&6; }
+  as_fn_error $? "could not parse libclang version" "$LINENO" 5
+fi
+
+if test -n "$wt_llvm_config_version" ; then
+  if test "$wt_libclang_major" -ne "$wt_llvm_config_major" -o "$wt_libclang_minor" -ne "$wt_llvm_config_minor" -o "$wt_libclang_patch" -ne "$wt_llvm_config_patch" ; then
+    { { printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5
+printf '%s\n' "$as_me: error: in '$ac_pwd':" >&2;}
+as_fn_error $? "libclang and llvm-config versions do not match
+See 'config.log' for more details" "$LINENO" 5; }
+  fi
+fi
+
+ac_fn_c_check_func "$LINENO" "clang_isBeforeInTranslationUnit" "ac_cv_func_clang_isBeforeInTranslationUnit"
+if test "x$ac_cv_func_clang_isBeforeInTranslationUnit" = xyes
+then :
+  printf '%s\n' "#define HAVE_CLANG_ISBEFOREINTRANSLATIONUNIT 1" >>confdefs.h
+
+fi
+
+
+ac_config_headers="$ac_config_headers autogen/clang_config.h"
+
+ac_config_files="$ac_config_files libclang-bindings.buildinfo autogen/libclang_version.h autogen/Version_libclang_bindings.hs"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# 'ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* 'ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+ac_cache_dump |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    if test "x$cache_file" != "x/dev/null"; then
+      { printf '%s\n' "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+printf '%s\n' "$as_me: updating cache $cache_file" >&6;}
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+	cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+	  mv -f confcache "$cache_file"$$ &&
+	  mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+	  mv -f confcache "$cache_file" ;;
+	esac
+      fi
+    fi
+  else
+    { printf '%s\n' "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+printf '%s\n' "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`printf '%s\n' "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: "${CONFIG_STATUS=./config.status}"
+case $CONFIG_STATUS in #(
+  -*) :
+    CONFIG_STATUS=./$CONFIG_STATUS ;; #(
+  */*) :
+     ;; #(
+  *) :
+    CONFIG_STATUS=./$CONFIG_STATUS ;;
+esac
+
+ac_write_fail=0
+ac_clean_CONFIG_STATUS='"$CONFIG_STATUS"'
+{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+printf '%s\n' "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >"$CONFIG_STATUS" <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>"$CONFIG_STATUS" <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1
+then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # contradicts POSIX and common usage.  Disable this.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else case e in #(
+  e) case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac ;;
+esac
+fi
+
+
+
+# Reset variables that may have inherited troublesome values from
+# the environment.
+
+# IFS needs to be set, to space, tab, and newline, in precisely that order.
+# (If _AS_PATH_WALK were called with IFS unset, it would have the
+# side effect of setting IFS to empty, thus disabling word splitting.)
+# Quoting is to prevent editors from complaining about space-tab.
+as_nl='
+'
+export as_nl
+IFS=" ""	$as_nl"
+
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# Ensure predictable behavior from utilities with locale-dependent output.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# We cannot yet rely on "unset" to work, but we need these variables
+# to be unset--not just set to an empty or harmless value--now, to
+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh).  This construct
+# also avoids known problems related to "unset" and subshell syntax
+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).
+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH
+do eval test \${$as_var+y} \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+
+# Ensure that fds 0, 1, and 2 are open.
+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi
+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi
+if (exec 3>&2)            ; then :; else exec 2>/dev/null; fi
+
+# The user is always right.
+if ${PATH_SEPARATOR+false} :; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  case $as_dir in #(((
+    '') as_dir=./ ;;
+    */) ;;
+    *) as_dir=$as_dir/ ;;
+  esac
+    test -r "$as_dir$0" && as_myself=$as_dir$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as 'sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  printf '%s\n' "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    printf '%s\n' "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  printf '%s\n' "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null
+then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else case e in #(
+  e) as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  } ;;
+esac
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null
+then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else case e in #(
+  e) as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  } ;;
+esac
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+printf '%s\n' X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable.
+    # In both cases, we have to default to 'cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`printf '%s\n' "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+printf '%s\n' X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"
+as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated
+
+# Sed expression to map a string onto a valid variable name.
+as_sed_sh="y%*+%pp%;s%[^_$as_cr_alnum]%_%g"
+as_tr_sh="eval sed '$as_sed_sh'" # deprecated
+
+
+exec 6>&1
+## ------------------------------------- ##
+## Main body of "$CONFIG_STATUS" script. ##
+## ------------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x "$CONFIG_STATUS" || ac_write_fail=1
+
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by libclang-bindings $as_me 0.1.0.0, which was
+generated by GNU Autoconf 2.73.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+
+_ACEOF
+
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+'$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to the package provider."
+
+_ACEOF
+ac_cs_config=`printf '%s\n' "$ac_configure_args" | sed "$ac_safe_unquote"`
+ac_cs_config_escaped=`printf '%s\n' "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+ac_cs_config='$ac_cs_config_escaped'
+ac_cs_version="\\
+libclang-bindings config.status 0.1.0.0
+configured by $0, generated by GNU Autoconf 2.73,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2026 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+test -n "\$AWK" || {
+  awk '' </dev/null ||
+    as_fn_error \$? "try installing gawk"
+  AWK=awk
+}
+_ACEOF
+
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=?*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    printf '%s\n' "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    printf '%s\n' "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`printf '%s\n' "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`printf '%s\n' "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: '$1'
+Try '$0 --help' for more information.";;
+  --help | --hel | -h )
+    printf '%s\n' "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: '$1'
+Try '$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \printf '%s\n' "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  printf '%s\n' "$ac_log"
+} >&5
+
+_ACEOF
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "autogen/clang_config.h") CONFIG_HEADERS="$CONFIG_HEADERS autogen/clang_config.h" ;;
+    "libclang-bindings.buildinfo") CONFIG_FILES="$CONFIG_FILES libclang-bindings.buildinfo" ;;
+    "autogen/libclang_version.h") CONFIG_FILES="$CONFIG_FILES autogen/libclang_version.h" ;;
+    "autogen/Version_libclang_bindings.hs") CONFIG_FILES="$CONFIG_FILES autogen/Version_libclang_bindings.hs" ;;
+
+  *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files
+  test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to '$tmp'.
+$debug ||
+{
+  tmp= ac_tmp=
+  trap 'exit_status=$?
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with './config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | sed -n '$='`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | sed -n '$='`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>"$CONFIG_STATUS" || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with './config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script 'defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>"$CONFIG_STATUS" || ac_write_fail=1
+
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    suffix = P[macro] D[macro]
+    while (suffix ~ /[\t ]$/) {
+      suffix = substr(suffix, 1, length(suffix) - 1)
+    }
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro suffix
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag '$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$ac_tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain ':'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error 1 "cannot find input file: '$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`printf '%s\n' "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is 'configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  printf '%s\n' "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { printf '%s\n' "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+printf '%s\n' "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`printf '%s\n' "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+printf '%s\n' X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`printf '%s\n' "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`printf '%s\n' "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+_ACEOF
+
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+printf '%s\n' "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when '$srcdir' = '.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>"$CONFIG_STATUS" <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>"$CONFIG_STATUS" <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable 'datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+printf '%s\n' "$as_me: WARNING: $ac_file contains a reference to the variable 'datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
+  case $ac_file in
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      printf '%s\n' "/* $configure_input  */" >&1 \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { printf '%s\n' "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+printf '%s\n' "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    printf '%s\n' "/* $configure_input  */" >&1 \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+ ;;
+
+
+  esac
+
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_CONFIG_STATUS=
+
+test $ac_write_fail = 0 ||
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  case $CONFIG_STATUS in #(
+  -*) :
+    ac_no_opts=-- ;; #(
+  *) :
+    ac_no_opts= ;;
+esac
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $ac_no_opts "$CONFIG_STATUS" $ac_config_status_args ||
+    ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { printf '%s\n' "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+printf '%s\n' "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,317 @@
+AC_PREREQ([2.71])
+AC_INIT([libclang-bindings],[0.1.0.0])
+
+dnl --with-compiler argument: This argument is passed by Cabal, so we have to
+dnl handle it.  We do not use it, so we ignore the passed value.
+AC_ARG_WITH(
+  [compiler],
+  [AS_HELP_STRING([--with-compiler], [Haskell compiler])]
+)
+
+dnl --with-so argument: This argument allows users to specify the path to a
+dnl shared library file, used to determine extra-libraries and extra-lib-dirs
+dnl on Linux systems.  It is used to work around Cabal linking issues.
+dnl
+dnl If specified, $wt_user_lib_dir and $wt_user_lib are set.
+wt_with_so_path='NOT_SET'
+AC_ARG_WITH(
+  [so],
+  [AS_HELP_STRING([--with-so=PATH], [shared library to link to])],
+  [wt_with_so_path=$withval],
+  []
+)
+case "$wt_with_so_path" in
+  /*)
+    if test ! -f "$wt_with_so_path" ; then
+      AC_MSG_ERROR([--with-so file not found: $wt_with_so_path])
+    fi
+    wt_user_lib_dir="$(dirname "$wt_with_so_path")"
+    AC_MSG_NOTICE([with library directory: $wt_user_lib_dir])
+    wt_with_so_filename="$(basename "$wt_with_so_path")"
+    wt_with_so_lib_1="${wt_with_so_filename#lib}"
+    if test "$wt_with_so_lib_1" = "$wt_with_so_filename" ; then
+      AC_MSG_ERROR([--with-so file does not have lib prefix: $wt_with_so_path])
+    fi
+    wt_user_lib="${wt_with_so_lib_1%.so}"
+    if test "$wt_user_lib" = "$wt_with_so_lib_1" ; then
+      AC_MSG_ERROR([--with-so file does not have .so suffix: $wt_with_so_path])
+    fi
+    AC_MSG_NOTICE([with library: $wt_user_lib])
+    ;;
+  'NOT_SET')
+    ;;
+  '')
+    AC_MSG_ERROR([--with-so specified without an argument])
+    ;;
+  *)
+    AC_MSG_ERROR([--with-so path not absolute: $wt_with_so_path])
+    ;;
+esac
+
+dnl LLVM_PATH variable: This argument allows users to specify the location of
+dnl an LLVM installation, in which case llvm-config is not used.
+AC_ARG_VAR(LLVM_PATH, [Location of LLVM installation])
+
+dnl LLVM resolution:
+dnl 1. Use LLVM_PATH if set
+dnl 2. Use llvm-config in PATH if found
+dnl 3. Fail if LLVM_PATH not set and llvm-config not in PATH
+AC_MSG_CHECKING([LLVM resolution mode])
+if test -n "$LLVM_PATH" ; then
+  AC_MSG_RESULT([LLVM_PATH=$LLVM_PATH])
+else
+  AC_MSG_RESULT([llvm-config])
+  AC_PATH_PROG([LLVM_CONFIG],[llvm-config],[])
+  if test -z "$LLVM_CONFIG" ; then
+    AC_MSG_ERROR([llvm-config not found and LLVM_PATH not set])
+  fi
+fi
+
+dnl If using llvm-config, get the version.  This also checks that we can run
+dnl llvm-config.
+AC_MSG_CHECKING([llvm-config version])
+if test -n "$LLVM_PATH" ; then
+  AC_MSG_RESULT([skipped])
+else
+  wt_llvm_config_version="$("$LLVM_CONFIG" --version)"
+  if test $? -eq 0 ; then
+    AC_MSG_RESULT([$wt_llvm_config_version])
+  else
+    AC_MSG_RESULT([error])
+    AC_MSG_ERROR([could not run llvm-config])
+  fi
+fi
+
+# WT_PARSE_VERSION(VERSION_STRING)
+#
+# $wt_parse_version_status is set to 0 on success or 1 on failure
+# $wt_parse_version_major is set to the major version on success
+# $wt_parse_version_minor is set to the minor version on success
+# $wt_parse_version_patch is set to the patch version on success
+#
+# NOTE This macro definition should not use dnl comments.
+AC_DEFUN([WT_PARSE_VERSION], [
+  wt_parse_version_major=''
+  wt_parse_version_minor=''
+  wt_parse_version_patch=''
+  wt_parse_version_status=0 # SUCCESS
+  wt_parse_version_input="$1"
+  wt_parse_version_state=0 # STATE_START
+  while test -n "$wt_parse_version_input" ; do
+    wt_parse_version_tail="${wt_parse_version_input#?}"
+    wt_parse_version_head="${wt_parse_version_input%${wt_parse_version_tail}}"
+    wt_parse_version_input="$wt_parse_version_tail"
+    case "$wt_parse_version_head" in
+      0|1|2|3|4|5|6|7|8|9) # NOTE [0-9] does not work for some reason
+        case "$wt_parse_version_state" in
+          0) # STATE_START
+            wt_parse_version_major="${wt_parse_version_head}"
+            wt_parse_version_state=1 # STATE_MAJOR
+            ;;
+          1) # STATE_MAJOR
+            wt_parse_version_major="${wt_parse_version_major}${wt_parse_version_head}"
+            ;;
+          2) # STATE_MAJOR_DOT
+            wt_parse_version_minor="${wt_parse_version_head}"
+            wt_parse_version_state=3 # STATE_MINOR
+            ;;
+          3) # STATE_MINOR
+            wt_parse_version_minor="${wt_parse_version_minor}${wt_parse_version_head}"
+            ;;
+          4) # STATE_MINOR_DOT
+            wt_parse_version_patch="${wt_parse_version_head}"
+            wt_parse_version_state=5 # STATE_PATCH
+            ;;
+          5) # STATE_PATCH
+            wt_parse_version_patch="${wt_parse_version_patch}${wt_parse_version_head}"
+            ;;
+        esac
+        ;;
+      .)
+        case "$wt_parse_version_state" in
+          1) # STATE_MAJOR
+            wt_parse_version_state=2 # STATE_MAJOR_DOT
+            ;;
+          3) # STATE_MINOR
+            wt_parse_version_state=4 # STATE_MINOR_DOT
+            ;;
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=6 # STATE_SKIP
+            ;;
+        esac
+        ;;
+      ' ')
+        case "$wt_parse_version_state" in
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=0 # STATE_START
+            ;;
+        esac
+        ;;
+      *)
+        case "$wt_parse_version_state" in
+          5) # STATE_PATCH
+            wt_parse_version_state=7 # STATE_SUCCESS
+            break
+            ;;
+          *)
+            wt_parse_version_state=6 # STATE_SKIP
+            ;;
+        esac
+        ;;
+    esac
+  done
+  case "$wt_parse_version_state" in
+    5|7) # STATE_PATCH STATE_SUCCESS
+      ;;
+    *)
+      wt_parse_version_status=1 # FAILURE
+      ;;
+  esac
+])
+
+dnl Parse llvm-config version only if using llvm-config
+if test -n "$wt_llvm_config_version" ; then
+  AC_MSG_CHECKING([Parsing llvm-config version])
+  WT_PARSE_VERSION([$wt_llvm_config_version])
+  if test "$wt_parse_version_status" -eq 0 ; then
+    wt_llvm_config_major="$wt_parse_version_major"
+    wt_llvm_config_minor="$wt_parse_version_minor"
+    wt_llvm_config_patch="$wt_parse_version_patch"
+    AC_MSG_RESULT([major=$wt_llvm_config_major minor=$wt_llvm_config_minor patch=$wt_llvm_config_patch])
+  else
+    AC_MSG_RESULT([error])
+    AC_MSG_ERROR([could not parse llvm-config version])
+  fi
+fi
+
+dnl Clang library resolution:
+dnl 1. Use user-specified library if --with-so is used
+dnl 2. Use clang
+AC_MSG_CHECKING([Clang library])
+if test -n "$wt_user_lib" ; then
+  wt_clang_lib="$wt_user_lib"
+else
+  wt_clang_lib='clang'
+fi
+AC_MSG_RESULT([$wt_clang_lib])
+AC_SUBST([CLANG_LIB], ["$wt_clang_lib"])
+dnl LIBS environment variable is set for checks below
+LIBS="${LIBS} -l${wt_clang_lib}"
+
+dnl LLVM library directory resolution:
+dnl 1. Use llvm-config or LLVM_PATH to determine the real library directory
+dnl 2. Append user-specified library directory if --with-so is used
+AC_MSG_CHECKING([LLVM library directories])
+if test -n "$LLVM_PATH" ; then
+  wt_clang_lib_dirs="${LLVM_PATH}/lib"
+else
+  wt_clang_lib_dirs="$("$LLVM_CONFIG" --libdir)"
+fi
+dnl LDFLAGS environment variable is set for checks below
+if test -n "$wt_user_lib_dir" && test "$wt_user_lib_dir" != "$wt_clang_lib_dirs"; then
+  LDFLAGS="${LDFLAGS} -L${wt_user_lib_dir} -L${wt_clang_lib_dirs}"
+  wt_clang_lib_dirs="${wt_user_lib_dir} ${wt_clang_lib_dirs}"
+else
+  LDFLAGS="${LDFLAGS} -L${wt_clang_lib_dirs}"
+fi
+AC_MSG_RESULT($wt_clang_lib_dirs)
+AC_SUBST([CLANG_LIB_DIRS], ["$wt_clang_lib_dirs"])
+
+dnl LLVM include directory resolution logic:
+dnl 1. Use llvm-config or LLVM_PATH to determine the include directory
+AC_MSG_CHECKING([LLVM include directory])
+if test -n "$LLVM_PATH" ; then
+  wt_clang_include_dir="${LLVM_PATH}/include"
+else
+  wt_clang_include_dir="$("$LLVM_CONFIG" --includedir)"
+fi
+dnl CPPFLAGS environment variable is set for checks below
+CPPFLAGS="${CPPFLAGS} -I${wt_clang_include_dir}"
+AC_MSG_RESULT($wt_clang_include_dir)
+AC_SUBST([CLANG_INCLUDE_DIR], ["$wt_clang_include_dir"])
+
+dnl Check C compiler needed for further checks
+AC_PROG_CC
+
+AC_CHECK_HEADER(
+  [clang-c/Index.h],
+  [],
+  [AC_MSG_ERROR([Cannot find libclang headers])]
+)
+
+AC_CHECK_LIB(
+  [$wt_clang_lib],
+  [clang_createIndex],
+  [],
+  [AC_MSG_ERROR([Cannot link against libclang])]
+)
+
+dnl Get the version of the linked libclang shared library.  The version string
+dnl is substituted into a generated Haskell module to provide the "compile-time"
+dnl version.
+AC_MSG_CHECKING([libclang version])
+AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM(
+    [[
+      #include <clang-c/Index.h>
+      #include <stdio.h>
+    ]],
+    [[
+      CXString cxstring = clang_getClangVersion();
+      printf("%s\n", clang_getCString(cxstring));
+      clang_disposeString(cxstring);
+    ]]
+  )],
+  [wt_libclang_version=$(./conftest$EXEEXT)],
+  [AC_MSG_FAILURE([Unable to determine libclang version])]
+)
+AC_MSG_RESULT($wt_libclang_version)
+AC_SUBST(
+  [LIBCLANG_VERSION_STRING],
+  ["$(echo ${wt_libclang_version} | sed 's/\"/\\\"/g')"]
+)
+
+dnl Parse libclang version
+AC_MSG_CHECKING([Parsing libclang version])
+WT_PARSE_VERSION([$wt_libclang_version])
+if test "$wt_parse_version_status" -eq 0 ; then
+  wt_libclang_major="$wt_parse_version_major"
+  wt_libclang_minor="$wt_parse_version_minor"
+  wt_libclang_patch="$wt_parse_version_patch"
+  AC_MSG_RESULT([major=$wt_libclang_major minor=$wt_libclang_minor patch=$wt_libclang_patch])
+  AC_SUBST([LIBCLANG_VERSION_MAJOR], [$wt_libclang_major])
+  AC_SUBST([LIBCLANG_VERSION_MINOR], [$wt_libclang_minor])
+  AC_SUBST([LIBCLANG_VERSION_PATCH], [$wt_libclang_patch])
+else
+  AC_MSG_RESULT([error])
+  AC_MSG_ERROR([could not parse libclang version])
+fi
+
+dnl Check that libclang version matches llvm-config version when using
+dnl llvm-config
+if test -n "$wt_llvm_config_version" ; then
+  if test "$wt_libclang_major" -ne "$wt_llvm_config_major" -o "$wt_libclang_minor" -ne "$wt_llvm_config_minor" -o "$wt_libclang_patch" -ne "$wt_llvm_config_patch" ; then
+    AC_MSG_FAILURE([libclang and llvm-config versions do not match])
+  fi
+fi
+
+dnl clang_isBeforeInTranslationUnit was introduced in Clang version 20.1, but
+dnl CINDEX_VERSION_MINOR was not bumped, so we need to check for it.
+AC_CHECK_FUNCS([clang_isBeforeInTranslationUnit])
+
+dnl Output
+AC_CONFIG_HEADERS([autogen/clang_config.h])
+AC_CONFIG_FILES([
+  libclang-bindings.buildinfo
+  autogen/libclang_version.h
+  autogen/Version_libclang_bindings.hs
+])
+AC_OUTPUT
diff --git a/libclang-bindings.buildinfo.in b/libclang-bindings.buildinfo.in
new file mode 100644
--- /dev/null
+++ b/libclang-bindings.buildinfo.in
@@ -0,0 +1,3 @@
+extra-libraries: @CLANG_LIB@
+extra-lib-dirs:  @CLANG_LIB_DIRS@
+include-dirs:    @CLANG_INCLUDE_DIR@ autogen
diff --git a/libclang-bindings.cabal b/libclang-bindings.cabal
new file mode 100644
--- /dev/null
+++ b/libclang-bindings.cabal
@@ -0,0 +1,210 @@
+cabal-version:      3.0
+name:               libclang-bindings
+version:            0.1.0.0
+license:            BSD-3-Clause
+license-file:       LICENSE
+author:             Well-Typed LLP
+maintainer:         info@well-typed.com
+homepage:           https://github.com/well-typed/libclang-bindings
+bug-reports:        https://github.com/well-typed/libclang-bindings/issues
+category:           Development
+build-type:         Configure
+synopsis:           libclang bindings
+description:
+  Haskell bindings to the LLVM/Clang @libclang@ C API, providing low-level FFI
+  bindings and a higher-level API for parsing and traversing C code.
+
+tested-with:
+  GHC ==9.2.8
+   || ==9.4.8
+   || ==9.6.7
+   || ==9.8.4
+   || ==9.10.3
+   || ==9.12.2
+   || ==9.14.1
+
+extra-source-files:
+  autogen/clang_config.h.in
+  autogen/libclang_version.h.in
+  autogen/Version_libclang_bindings.hs.in
+  cbits/*.c
+  cbits/*.h
+  configure
+  configure.ac
+  libclang-bindings.buildinfo.in
+
+extra-doc-files:
+  CHANGELOG.md
+  README.md
+
+source-repository head
+  type:     git
+  location: https://github.com/well-typed/libclang-bindings
+  subdir:   libclang-bindings
+
+source-repository this
+  type:     git
+  location: https://github.com/well-typed/libclang-bindings
+  subdir:   libclang-bindings
+  tag:      release-0.1.0.0
+
+--------------------------------------------------------------------------------
+-- Configuration
+--
+-- See README.md for documentation about configuration.
+--------------------------------------------------------------------------------
+
+common lang
+  ghc-options:
+    -Wall -Widentities -Wprepositive-qualified-module
+    -Wredundant-constraints -Wunused-packages
+
+  build-depends:      base >=4.16 && <4.23
+  default-language:   GHC2021
+
+  -- We don't provide a shared list of default extension between the library
+  -- and the clang-tutorial example; this way we can ensure that mere
+  -- /usage/ of the library does not result in requirements for enabled
+  -- language extensions.
+  default-extensions:
+
+library
+  import:             lang
+  hs-source-dirs:     src
+  default-extensions:
+    CApiFFI
+    DataKinds
+    DeriveAnyClass
+    DerivingStrategies
+    DerivingVia
+    LambdaCase
+    MagicHash
+    TypeFamilies
+    UnboxedTuples
+    UndecidableInstances
+    UnliftedFFITypes
+    UnliftedNewtypes
+
+  other-extensions:   AllowAmbiguousTypes
+  exposed-modules:
+    Clang.Args
+    Clang.Backtrace
+    Clang.CStandard
+    Clang.Discover
+    Clang.Enum.Bitfield
+    Clang.Enum.Simple
+    Clang.HighLevel
+    Clang.HighLevel.Documentation
+    Clang.HighLevel.Types
+    Clang.Internal.ByValue
+    Clang.LowLevel.Core
+    Clang.LowLevel.Doxygen
+    Clang.Paths
+    Clang.Version
+
+  other-modules:
+    Clang.HighLevel.Declaration
+    Clang.HighLevel.Diagnostics
+    Clang.HighLevel.Evaluate
+    Clang.HighLevel.Fold
+    Clang.HighLevel.SourceLoc
+    Clang.HighLevel.Tokens
+    Clang.HighLevel.Wrappers
+    Clang.Internal.ConstPtr
+    Clang.Internal.CXString
+    Clang.Internal.Exception
+    Clang.Internal.FFI
+    Clang.Internal.Ptr
+    Clang.Internal.Results
+    Clang.LowLevel.Core.Enums
+    Clang.LowLevel.Core.Instances
+    Clang.LowLevel.Core.Pointers
+    Clang.LowLevel.Core.Structs
+    Clang.LowLevel.Doxygen.Enums
+    Clang.LowLevel.Doxygen.Instances
+    Clang.LowLevel.Doxygen.Structs
+    Clang.LowLevel.FFI
+    Clang.Version.Internal
+    Clang.Version.Internal.Check
+    Version_libclang_bindings
+
+  autogen-modules:    Version_libclang_bindings
+
+  -- External dependencies
+  build-depends:
+    , bytestring        >=0.11    && <0.13
+    , data-default      >=0.7     && <0.9
+    , directory         >=1.3.6.2 && <1.4
+    , exceptions        >=0.10    && <0.11
+    , filepath          >=1.4     && <1.6
+    , process           >=1.6     && <1.7
+    , template-haskell  >=2.18    && <2.25
+    , text              >=1.2     && <2.2
+    , transformers      >=0.5     && <0.7
+    , unliftio-core     >=0.2.1   && <0.3
+
+  -- C bindings
+  if impl(ghc <9.4)
+    build-depends: data-array-byte >=0.1.0.1 && <0.2
+
+  include-dirs:       cbits
+  cc-options:         -Wall
+  c-sources:          cbits/clang_wrappers.c
+  build-tool-depends: hsc2hs:hsc2hs
+
+test-suite clang-tutorial
+  import:         lang
+  type:           exitcode-stdio-1.0
+  main-is:        clang-tutorial.hs
+  hs-source-dirs: clang-tutorial
+
+  -- Internal dependencies
+  build-depends:  libclang-bindings
+
+  -- Inherited dependencies
+  build-depends:
+    , data-default
+    , text
+
+test-suite test-clang-bindings
+  import:             lang
+  type:               exitcode-stdio-1.0
+  main-is:            test-clang-bindings.hs
+  hs-source-dirs:     test
+  default-extensions:
+    DeriveAnyClass
+    DerivingStrategies
+    LambdaCase
+
+  other-modules:
+    Test.Discover
+    Test.Meta.IsConcrete
+    Test.Test.Exceptions
+    Test.Util.AST
+    Test.Util.Clang
+    Test.Util.FoldException
+    Test.Util.Input
+    Test.Util.Input.Examples
+    Test.Util.Input.StructForest
+    Test.Util.Shape
+    Test.Version
+
+  -- Internal dependencies
+  build-depends:      libclang-bindings
+
+  -- Inherited dependencies
+  build-depends:
+    , data-default
+    , mtl
+    , text
+
+  -- New dependencies
+  --
+  -- tasty <1.5.4: sequentialTestGroup was deprecated leading to a compilation error
+  build-depends:
+    , containers        >=0.6     && <0.9
+    , directory         >=1.3.6.2 && <1.4
+    , QuickCheck        >=2.14    && <2.18
+    , tasty             >=1.5     && <1.5.4
+    , tasty-hunit       >=0.10    && <0.11
+    , tasty-quickcheck  >=0.11    && <0.12
diff --git a/src/Clang/Args.hs b/src/Clang/Args.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Args.hs
@@ -0,0 +1,33 @@
+module Clang.Args (
+    -- * Clang arguments
+    ClangArgs(..)
+  , InvalidClangArgs(..)
+  ) where
+
+import Control.Exception (Exception)
+import Data.Default (Default (def))
+import Data.String (IsString)
+
+{-------------------------------------------------------------------------------
+  Clang arguments
+-------------------------------------------------------------------------------}
+
+-- | Command-line arguments passed to @libclang@
+--
+-- The order of command-line arguments is significant.
+--
+-- Reference:
+--
+-- * <https://clang.llvm.org/docs/ClangCommandLineReference.html>
+newtype ClangArgs = ClangArgs { unClangArgs :: [String] }
+  deriving stock (Show)
+  deriving newtype (Eq)
+
+instance Default ClangArgs where
+  def = ClangArgs []
+
+-- | Invalid Clang arguments exception
+newtype InvalidClangArgs = InvalidClangArgs String
+  deriving stock (Show)
+  deriving newtype (IsString)
+  deriving anyclass (Exception)
diff --git a/src/Clang/Backtrace.hs b/src/Clang/Backtrace.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Backtrace.hs
@@ -0,0 +1,80 @@
+{-# LANGUAGE CPP #-}
+
+-- | Shim to provide backtrace support
+module Clang.Backtrace (
+    Backtrace
+  , prettyBacktrace
+  , collectBacktrace
+  , CollectedBacktrace(..)
+  ) where
+
+import Control.Exception
+import Control.Monad.IO.Class
+import Data.Typeable
+import GHC.Stack
+
+#if MIN_VERSION_base(4,20,0)
+import Control.Exception.Backtrace
+#endif
+
+{-------------------------------------------------------------------------------
+  Abstract over backtraces
+-------------------------------------------------------------------------------}
+
+#if MIN_VERSION_base(4,20,0)
+
+-- Take advantage of the new backtrace support in ghc 9.10 and up.
+
+newtype Backtrace = WrapStack {
+      unwrapStack :: Backtraces
+    }
+
+instance Show Backtrace where
+  show = prettyBacktrace
+
+prettyBacktrace :: Backtrace -> String
+prettyBacktrace = displayBacktraces . unwrapStack
+
+collectBacktrace :: (MonadIO m, HasCallStack) => m Backtrace
+collectBacktrace = liftIO $ WrapStack <$> collectBacktraces
+
+#else
+
+-- For older ghc (< 9.10), we just use the 'CallStack'.
+
+newtype Backtrace = WrapStack {
+      unwrapStack :: CallStack
+    }
+
+instance Show Backtrace where
+  show = prettyBacktrace
+
+prettyBacktrace :: Backtrace -> String
+prettyBacktrace = prettyCallStack . unwrapStack
+
+collectBacktrace :: (MonadIO m, HasCallStack) => m Backtrace
+collectBacktrace = return $ WrapStack callStack
+
+#endif
+
+{-------------------------------------------------------------------------------
+  Avoid duplicate backtraces
+-------------------------------------------------------------------------------}
+
+-- | Newtype for deriving-via for exceptions that contain explicit stacks
+--
+-- In ghc 9.10 and higher, 'throwIO' will include a backtrace immediately, but
+-- this is not true for older versions. It is therefore useful to include an
+-- explicit backtrace in exceptions, but if we do, we should then not /also/
+-- have @ghc@'s automatic backtrace annotation. Example usage:
+--
+-- > data CallFailed = CallFailed Backtrace
+-- >   deriving stock (Show)
+-- >   deriving Exception via CollectedBacktrace CallFailed
+newtype CollectedBacktrace a = CollectedBacktrace a
+  deriving newtype Show
+
+instance (Show a, Typeable a) => Exception (CollectedBacktrace a) where
+#if MIN_VERSION_base(4,20,0)
+  backtraceDesired _ = False
+#endif
diff --git a/src/Clang/CStandard.hs b/src/Clang/CStandard.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/CStandard.hs
@@ -0,0 +1,162 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Clang.CStandard (
+    -- * C standard
+    ClangCStandard(..)
+  , CStandard(..)
+  , Gnu(..)
+  , MicrosoftCVersion
+    -- * Querying @libclang@
+  , getClangCStandard
+  ) where
+
+import Data.Text (Text)
+import Data.Text qualified as Text
+
+import Clang.Args (ClangArgs)
+import Clang.Enum.Bitfield
+import Clang.Enum.Simple
+import Clang.HighLevel qualified as HighLevel
+import Clang.HighLevel.Types
+import Clang.Internal.Results
+import Clang.LowLevel.Core
+import Clang.Paths
+
+{-------------------------------------------------------------------------------
+  C standard
+-------------------------------------------------------------------------------}
+
+-- | Clang C standard implementation
+--
+-- Reference:
+--
+-- * "C Support in Clang"
+--   <https://clang.llvm.org/c_status.html>
+-- * "Differences between various standard modes" in the clang user manual
+--   <https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes>
+data ClangCStandard =
+    -- | Official C standard, optionally with GNU extensions
+    ClangCStandard CStandard Gnu
+  | -- | Microsoft C
+    ClangCMicrosoft MicrosoftCVersion
+  deriving stock (Eq, Ord, Show)
+
+-- | Official C standards
+data CStandard =
+    C89
+  | C95
+  | C99
+  | C11
+  | C17
+  | C23
+  deriving stock (Bounded, Enum, Eq, Ord, Show)
+
+-- | Enable GNU extensions?
+data Gnu =
+    DisableGnu
+  | EnableGnu
+  deriving stock (Bounded, Enum, Eq, Ord, Show)
+
+-- | Microsoft C version
+type MicrosoftCVersion = Integer
+
+{-------------------------------------------------------------------------------
+  Querying @libclang@
+-------------------------------------------------------------------------------}
+
+-- | Get the Clang C standard for the specified 'ClangArgs'
+--
+-- Reference:
+--
+-- * <https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes>
+-- * <https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html>
+getClangCStandard :: ClangArgs -> IO (Maybe ClangCStandard)
+getClangCStandard = fmap (aux =<<) . getClangCBuiltinMacros
+  where
+    aux ::
+         (Bool, Maybe Integer, Bool, Maybe MicrosoftCVersion)
+      -> Maybe ClangCStandard
+    aux (isStdc, mStdcVersion, isGnu, mMscVer) = case mMscVer of
+      Just mscVer -> Just $ ClangCMicrosoft mscVer
+      Nothing
+        | isStdc ->
+            let gnu'       = if isGnu then EnableGnu else DisableGnu
+                valid std' = Just $ ClangCStandard std' gnu'
+            in  case mStdcVersion of
+                  Nothing     -> valid C89
+                  Just 199409 -> valid C95
+                  Just 199901 -> valid C99
+                  Just 201112 -> valid C11
+                  Just 201710 -> valid C17  -- c17 6~
+                  Just 202000 -> valid C23  -- c2x 14~17
+                  Just 202311 -> valid C23  -- c23 18.1.0~
+                  Just _other -> Nothing
+        | otherwise -> Nothing
+
+-- | Get the values of builtin macros used to determine the Clang C standard
+--
+-- This function gets the values for four macros:
+--
+-- 1. @__STDC__@ ('Bool'), used to detect C89
+-- 2. @__STDC_VERSION__@ ('Integer')
+-- 3. @linux@ ('Bool'), used to detect GNU extensions
+-- 4. @_MSC_VER@ ('Integer'), used to detect Microsoft C
+--
+-- 'Nothing' is returned if there is an error.
+getClangCBuiltinMacros ::
+     ClangArgs
+  -> IO (Maybe (Bool, Maybe Integer, Bool, Maybe MicrosoftCVersion))
+getClangCBuiltinMacros clangArgs =
+    HighLevel.withUnsavedFile filename contents $ \unsavedFile ->
+      HighLevel.withIndex DontDisplayDiagnostics $ \index ->
+        HighLevel.withTranslationUnit2
+          index
+          (Just $ SourcePath (Text.pack filename))
+          clangArgs
+          [unsavedFile]
+          (bitfieldEnum [CXTranslationUnit_None])
+          (const $ return Nothing)
+          (fmap Just . process)
+  where
+    filename :: FilePath
+    filename = "libclang-bindings-version.h"
+
+    contents :: String
+    contents = unlines [
+        "const long long builtin_stdc = __STDC__;"
+      , "const long long builtin_stdc_version = __STDC_VERSION__;"
+      , "const long long builtin_linux = linux;"
+      , "const long long builtin_msc_ver = _MSC_VER;"
+      ]
+
+    process ::
+         CXTranslationUnit
+      -> IO (Bool, Maybe Integer, Bool, Maybe MicrosoftCVersion)
+    process unit = do
+      root <- clang_getTranslationUnitCursor unit
+      kvs  <- HighLevel.clang_visitChildren root visit
+      return
+        ( lookupBool    "builtin_stdc"         kvs
+        , lookupInteger "builtin_stdc_version" kvs
+        , lookupBool    "linux"                kvs
+        , lookupInteger "builtin_msc_ver"      kvs
+        )
+
+    visit :: Fold IO (Text, EvalResult)
+    visit = simpleFold $ \curr -> do
+      kind <- clang_getCursorKind curr
+      case fromSimpleEnum kind of
+        Right CXCursor_VarDecl ->
+          clang_getCursorSpelling curr >>= \name ->
+            HighLevel.clang_evaluate curr >>= \case
+              Just er    -> foldContinueWith (name, er)
+              _otherwise -> foldContinue
+        _otherwise -> foldContinue
+
+    lookupInteger :: Text -> [(Text, EvalResult)] -> Maybe Integer
+    lookupInteger k kvs = case lookup k kvs of
+      Just (EvalResultInteger n) -> Just n
+      _otherwise                 -> Nothing
+
+    lookupBool :: Text -> [(Text, EvalResult)] -> Bool
+    lookupBool k = maybe False cToBool . lookupInteger k
diff --git a/src/Clang/Discover.hs b/src/Clang/Discover.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Discover.hs
@@ -0,0 +1,409 @@
+{-# LANGUAGE CPP #-}
+
+module Clang.Discover (
+    -- * Types
+    BuiltinIncDirConfig(..)
+  , Paths(..)
+  , ClangExe
+  , BuiltinIncDir
+    -- * Trace messages
+  , DiscoverMsg(..)
+    -- * API
+  , getPaths
+  ) where
+
+import Control.Applicative (asum, (<|>))
+import Control.Monad
+import Control.Monad.IO.Class
+import Control.Monad.Trans.Maybe
+import Data.Maybe
+import Data.Text (Text)
+import Data.Text qualified as Text
+import GHC.Exception
+import GHC.Stack
+import System.Directory qualified as Dir
+import System.Environment qualified as Env
+import System.FilePath qualified as FilePath
+import System.Process (readProcess)
+
+#ifdef mingw32_HOST_OS
+import Data.Char qualified as Char
+import System.FilePath.Posix qualified as Posix
+import System.FilePath.Windows qualified as Windows
+#endif
+
+import Clang.Version
+import System.IO.Error
+
+{-------------------------------------------------------------------------------
+  Types
+-------------------------------------------------------------------------------}
+
+-- | Configure builtin include directory automatic configuration
+data BuiltinIncDirConfig =
+    -- | Do not configure the builtin include directory
+    BuiltinIncDirDisable
+
+    -- | Configure the builtin include directory using the resource directory
+    -- from @clang@
+  | BuiltinIncDirClang
+  deriving (Eq, Show)
+
+-- | Discovered path information
+data Paths = Paths {
+    pClangExe      :: Maybe ClangExe
+  , pBuiltinIncDir :: Maybe BuiltinIncDir
+  }
+
+-- | Path to the @clang@ executable
+type ClangExe = FilePath
+
+-- | Path to the builtin include directory
+type BuiltinIncDir = FilePath
+
+{-------------------------------------------------------------------------------
+  Trace messages
+-------------------------------------------------------------------------------}
+
+data DiscoverMsg =
+    -- | @LLVM_PATH@ is not an existing directory (skipped)
+    DiscoverLlvmPathNotFound FilePath
+
+    -- | @llvm-config@ found using @PATH@
+  | DiscoverLlvmConfigPathFound FilePath
+
+    -- | @llvm-config --prefix@ produced unexpected output
+  | DiscoverLlvmConfigPrefixUnexpected String
+
+    -- | IO error calling @llvm-config --prefix@
+  | DiscoverLlvmConfigPrefixIOError IOError
+
+    -- | @clang@ not found
+  | DiscoverClangNotFound
+
+    -- | The @clang@ version does not match the @libclang@ version
+  | DiscoverClangVersionMismatch Text Text
+
+    -- | Builtin include directory not found using @clang@
+  | DiscoverClangIncDirNotFound BuiltinIncDir
+
+    -- | Builtin include directory found using @clang@
+  | DiscoverClangIncDirFound BuiltinIncDir
+
+    -- | @clang@ not found using @LLVM_PATH@
+  | DiscoverLlvmPathClangExeNotFound FilePath
+
+    -- | @clang@ found using @LLVM_PATH@
+  | DiscoverLlvmPathClangExeFound FilePath
+
+    -- | @clang@ not found using @llvm-config@
+  | DiscoverLlvmConfigClangExeNotFound FilePath
+
+    -- | @clang@ found using @llvm-config@
+  | DiscoverLlvmConfigClangExeFound FilePath
+
+    -- | @clang@ found using @PATH@
+  | DiscoverClangPathFound FilePath
+
+    -- | @clang --version@ produced unexpected output
+  | DiscoverClangVersionUnexpected String
+
+    -- | IO error calling @clang --version@
+  | DiscoverClangVersionIOError IOError
+
+    -- | @clang -print-resource-dir@ produced unexpected output
+  | DiscoverClangPrintResourceDirUnexpected String
+
+    -- | IO error calling @clang -print-resource-dir@
+  | DiscoverClangPrintResourceDirIOError IOError
+  deriving stock (Show)
+
+{-------------------------------------------------------------------------------
+  API
+-------------------------------------------------------------------------------}
+
+-- | Try to discover paths for the @clang@ executable, and the builtin include
+-- directory
+--
+-- === Clang executable
+--
+-- The @clang@ executable is run to discover the builtin include directory.
+--
+-- This function tries to determine the path to the @clang@ executable by using
+-- the first successful result of the following strategies:
+--
+-- 1. @${LLVM_PATH}/bin/clang@
+-- 2. @$(llvm-config --prefix)/bin/clang@ (llvm-config is found using PATH)
+-- 3. @clang@ (clang is found using PATH)
+--
+-- === Builtin include directory
+--
+-- LLVM/Clang determines the builtin include directory based on the path of the
+-- @clang@ executable being run. When using @libclang@, there is not enough
+-- information to determine the absolute builtin include directory.
+--
+-- Upstream issues:
+--
+-- * https://github.com/llvm/llvm-project/issues/18150
+-- * https://github.com/llvm/llvm-project/issues/51256
+--
+-- The builtin include directory is in the Clang resource directory, which
+-- contains the executables, headers, and libraries used by the Clang compiler.
+--
+-- When 'BuiltinIncDirClang' is used, this function tries to determine the
+-- builtin include directory using the @clang@ executable discovered as
+-- described above, using @$(clang -print-resource-dir)/include@.
+getPaths ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> BuiltinIncDirConfig
+  -> IO Paths
+getPaths trace config = do
+    mClangExe <- runMaybeT $ findClangExe trace
+    mBuiltinIncDir <- case config of
+      BuiltinIncDirDisable -> return Nothing
+      BuiltinIncDirClang   -> runMaybeT $
+        getBuiltinIncDirWithClang trace (myHoistMaybe mClangExe)
+    let paths = Paths {
+            pClangExe      = mClangExe
+          , pBuiltinIncDir = mBuiltinIncDir
+          }
+    return paths
+  where
+    -- | hoistMaybe was only added in transformers-0.6.0.0
+    myHoistMaybe :: Maybe a -> MaybeT IO a
+    myHoistMaybe = MaybeT . pure
+
+{-------------------------------------------------------------------------------
+  Auxiliary functions
+-------------------------------------------------------------------------------}
+
+-- | Get the builtin include directory using @clang@
+--
+-- @clang -print-resource-dir@ is called to get the resource directory, and the
+-- builtin include directory is the @include@ subdirectory within it.
+getBuiltinIncDirWithClang ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> MaybeT IO ClangExe
+  -> MaybeT IO BuiltinIncDir
+getBuiltinIncDirWithClang trace getExe = do
+    exe <- getExe <|> do
+      liftIO $ trace callStack DiscoverClangNotFound
+      MaybeT $ return Nothing
+    clangVersionString <- getClangVersion trace exe
+    let clangVersion = parseClangVersion clangVersionString
+    unless (isCompatibleClangVersion runtimeClangVersion clangVersion) $ do
+      liftIO $ trace callStack $
+        DiscoverClangVersionMismatch
+          runtimeClangVersionString
+          clangVersionString
+      MaybeT $ return Nothing
+    resourceDir <- getClangResourceDir trace exe
+    ifM
+     trace
+     DiscoverClangIncDirNotFound
+     DiscoverClangIncDirFound
+     Dir.doesDirectoryExist
+     (FilePath.joinPath [resourceDir, "include"])
+
+-- | Find the @clang@ executable
+--
+-- 1. @${LLVM_PATH}/bin/clang@
+-- 2. @$(llvm-config --prefix)/bin/clang@ (llvm-config is found using PATH)
+-- 3. @clang@ (clang is found using PATH)
+findClangExe ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> MaybeT IO ClangExe
+findClangExe trace = asum [auxLlvmPath, auxLlvmConfig, auxPath]
+  where
+    auxLlvmPath :: MaybeT IO ClangExe
+    auxLlvmPath = do
+      prefix <- lookupLlvmPath trace
+      ifM
+        trace
+        DiscoverLlvmPathClangExeNotFound
+        DiscoverLlvmPathClangExeFound
+        Dir.doesFileExist
+        (FilePath.joinPath [prefix, "bin", clangExe])
+
+    auxLlvmConfig :: MaybeT IO ClangExe
+    auxLlvmConfig = do
+      exe <- findLlvmConfigExe trace
+      prefix <- getLlvmConfigPrefix trace exe
+      ifM
+        trace
+        DiscoverLlvmConfigClangExeNotFound
+        DiscoverLlvmConfigClangExeFound
+        Dir.doesFileExist
+        (FilePath.joinPath [prefix, "bin", clangExe])
+
+    auxPath :: MaybeT IO ClangExe
+    auxPath = do
+      exe <- MaybeT $ Dir.findExecutable clangExe
+      liftIO $ trace callStack (DiscoverClangPathFound exe)
+      return exe
+
+-- | @clang@ executable name for the current platform
+clangExe :: FilePath
+clangExe =
+#ifdef mingw32_HOST_OS
+    "clang.exe"
+#else
+    "clang"
+#endif
+
+-- | Lookup @LLVM_PATH@ environment variable
+lookupLlvmPath ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> MaybeT IO FilePath
+lookupLlvmPath trace = do
+    prefix <- MaybeT $ fmap normWinPath <$> Env.lookupEnv "LLVM_PATH"
+    MaybeT $ Dir.doesDirectoryExist prefix >>= \case
+      True  -> return (Just prefix)
+      False -> do
+        trace callStack (DiscoverLlvmPathNotFound prefix)
+        return Nothing
+
+-- | Find the @llvm-config@ executable using @PATH@
+findLlvmConfigExe ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> MaybeT IO FilePath
+findLlvmConfigExe trace = do
+    exe <- MaybeT $ Dir.findExecutable llvmConfigExe
+    liftIO $ trace callStack (DiscoverLlvmConfigPathFound exe)
+    return exe
+
+-- | @llvm-config@ executable name for the current platform
+llvmConfigExe :: FilePath
+llvmConfigExe =
+#ifdef mingw32_HOST_OS
+    "llvm-config.exe"
+#else
+    "llvm-config"
+#endif
+
+-- | Get the prefix from @llvm-config@
+--
+-- This function calls @llvm-config --prefix@ and captures the output.
+getLlvmConfigPrefix ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> FilePath  -- ^ @llvm-config@ path
+  -> MaybeT IO FilePath
+getLlvmConfigPrefix trace exe = MaybeT $
+    checkOutput
+      trace
+      DiscoverLlvmConfigPrefixUnexpected
+      DiscoverLlvmConfigPrefixIOError
+      (fmap normWinPath . parseSingleLine)
+      (readProcess exe ["--prefix"] "")
+
+-- | Get the Clang version from @clang@
+--
+-- This function calls @clang --version@ and captures the output.  The full
+-- version string in the first line is returned.
+getClangVersion ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> FilePath  -- ^ @clang@ path
+  -> MaybeT IO Text
+getClangVersion trace exe = MaybeT $
+    checkOutput
+      trace
+      DiscoverClangVersionUnexpected
+      DiscoverClangVersionIOError
+      (fmap Text.pack . parseFirstLine)
+      (readProcess exe ["--version"] "")
+
+-- | Get the resource directory from @clang@
+--
+-- This function calls @clang -print-resource-dir@ and captures the output.
+getClangResourceDir ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> FilePath  -- ^ @clang@ path
+  -> MaybeT IO FilePath
+getClangResourceDir tracer exe = MaybeT $
+    checkOutput
+      tracer
+      DiscoverClangPrintResourceDirUnexpected
+      DiscoverClangPrintResourceDirIOError
+      (fmap normWinPath . parseSingleLine)
+      (readProcess exe ["-print-resource-dir"] "")
+
+--------------------------------------------------------------------------------
+
+-- | Normalise Windows paths
+--
+-- This is just the identity function on non-Windows platforms.
+normWinPath :: FilePath -> FilePath
+#ifdef mingw32_HOST_OS
+normWinPath path
+    -- | Do not change paths with no @/@ in them
+    | '/' `notElem` path = path
+    | otherwise = case path of
+        -- Convert POSIX absolute paths specifying the Windows drive
+        '/' : drv : '/' : relPath -> Char.toUpper drv : ":\\" ++ aux relPath
+        -- Do not change other POSIX absolute paths
+        '/' : _                   -> path
+        -- Normalise hybrid paths
+        drv : ':' : '/' : relPath -> Char.toUpper drv : ":\\" ++ aux relPath
+        -- Normalise relative paths
+        relPath                   -> aux relPath
+  where
+    aux :: FilePath -> FilePath
+    aux = Windows.joinPath . Posix.splitDirectories
+#else
+normWinPath = id
+#endif
+
+-- | Return a path only if it passes a predicate, tracing result
+ifM ::
+     HasCallStack
+  => (CallStack -> DiscoverMsg -> IO ())
+  -> (FilePath -> DiscoverMsg)  -- ^ not found constructor
+  -> (FilePath -> DiscoverMsg)  -- ^ found constructor
+  -> (FilePath -> IO Bool)           -- ^ predicate
+  -> FilePath                        -- ^ path
+  -> MaybeT IO FilePath
+ifM trace mkNotFound mkFound p path = MaybeT $ p path >>= \case
+    True  -> Just path <$ trace callStack (mkFound    path)
+    False -> Nothing   <$ trace callStack (mkNotFound path)
+
+--------------------------------------------------------------------------------
+
+-- | Run a read action and check the output
+checkOutput ::
+     HasCallStack
+  => (CallStack -> msg -> IO ())
+  -> (String  -> msg)      -- ^ Unexpected output constructor
+  -> (IOError -> msg)      -- ^ Error constructor
+  -> (String  -> Maybe a)  -- ^ Output parser
+  -> IO String             -- ^ Read action
+  -> IO (Maybe a)
+checkOutput trace mkUnexpected mkError parse action =
+    tryIOError action >>= \case
+      Right s -> case parse s of
+        x@Just{} -> return x
+        Nothing  -> Nothing <$ trace callStack (mkUnexpected (abbr s))
+      Left  e -> Nothing <$ trace callStack (mkError e)
+  where
+    -- Abbreviate arbitrarily long strings in trace messages
+    abbr :: String -> String
+    abbr s = case splitAt 60 s of
+      (_, []) -> s
+      (s', _) -> s' ++ " ..."
+
+-- | Parse a single line of output
+parseSingleLine :: String -> Maybe String
+parseSingleLine s = case lines s of
+    [s'] -> Just s'
+    _    -> Nothing
+
+-- | Parse the first line of output
+parseFirstLine :: String -> Maybe String
+parseFirstLine = listToMaybe . lines
diff --git a/src/Clang/Enum/Bitfield.hs b/src/Clang/Enum/Bitfield.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Enum/Bitfield.hs
@@ -0,0 +1,132 @@
+module Clang.Enum.Bitfield (
+    BitfieldEnum(..)
+  , IsSingleFlag(..)
+    -- * API
+  , bitfieldEnum
+  , fromBitfieldEnum
+  , flagIsSet
+  ) where
+
+import Data.Bits
+import Data.Foldable qualified as Foldable
+import Data.Typeable
+import Foreign.C
+import GHC.Generics (Generic)
+import GHC.Show (appPrec1, showSpace)
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Single flags
+--
+-- See 'BitfieldEnum' for discussion.
+class Typeable hs => IsSingleFlag hs where
+  flagToC :: hs -> CUInt
+
+-- | Enum that corresponds to a bitfield
+--
+-- Some C enumerations are defined like this:
+--
+-- > enum Flags {
+-- >   Flag1 = 0x00,
+-- >   Flag2 = 0x01,
+-- >   Flag3 = 0x02,
+-- >   Flag4 = 0x04,
+-- >   Flag5 = 0x08,
+-- >   ..
+-- > };
+--
+-- The intention then is that these flags are ORed together to select multiple
+-- flags. We term this a "bitfield enum": the @flag@ type is intended to be an
+-- ADT with a 'IsSingleFlag' instance, mapping ADT constructors to the values from
+-- the enum. Using @hsc2hs@, such an instance might look like
+--
+-- > data Flags = Flag1 | Flag2 | Flag3 | Flag 4 | Flag5
+-- >
+-- > instance IsSingleFlag Flags where
+-- >   flagToC Flag1 = #const Flag1
+-- >   flagToC Flag2 = #const Flag2
+-- >   flagToC Flag3 = #const Flag3
+-- >   flagToC Flag4 = #const Flag4
+-- >   flagToC Flag5 = #const Flag5
+newtype BitfieldEnum hs = BitfieldEnum CUInt
+  deriving stock (Eq, Ord, Generic)
+
+-- | 'Semigroup' instance corresponds to set union
+instance Semigroup (BitfieldEnum hs) where
+  BitfieldEnum a <> BitfieldEnum b = BitfieldEnum (a .|. b)
+
+-- | 'Monoid' instance corresponds to set union
+--
+-- This means that the neutral element 'mempty' is the empty set.
+instance Monoid (BitfieldEnum hs) where
+  mempty = BitfieldEnum 0
+
+{-------------------------------------------------------------------------------
+  Showing values
+-------------------------------------------------------------------------------}
+
+instance (IsSingleFlag hs, Enum hs, Bounded hs, Show hs)
+      => Show (BitfieldEnum hs) where
+  showsPrec p i = showParen (p >= appPrec1) $
+      either (uncurry showC) showHs $ showBitfieldEnum i
+    where
+      showC :: CUInt -> TypeRep -> ShowS
+      showC c typ =
+            showString "BitfieldEnum @"
+          . showsPrec appPrec1 typ
+          . showSpace
+          . showsPrec appPrec1 c
+
+      showHs :: [hs] -> ShowS
+      showHs hs =
+             showString "simpleEnum "
+           . showsPrec appPrec1 hs
+
+-- | Internal auxiliary for showing 'BitfieldEnum'
+showBitfieldEnum :: forall hs.
+     (IsSingleFlag hs, Enum hs, Bounded hs)
+  => BitfieldEnum hs -> Either (CUInt, TypeRep) [hs]
+showBitfieldEnum =
+    either (Left . showC) Right . fromBitfieldEnum
+  where
+    showC :: CUInt -> (CUInt, TypeRep)
+    showC c = (c, typeRep (Proxy @hs))
+
+{-------------------------------------------------------------------------------
+  API
+-------------------------------------------------------------------------------}
+
+-- | Construct 'BitfieldEnum'
+bitfieldEnum :: IsSingleFlag hs => [hs] -> BitfieldEnum hs
+bitfieldEnum = BitfieldEnum . Foldable.foldl' (.|.) 0 . map flagToC
+
+-- | Check if the given flag is set
+flagIsSet :: IsSingleFlag hs => BitfieldEnum hs -> hs -> Bool
+flagIsSet (BitfieldEnum i) flag = (i .&. flagToC flag) /= 0
+
+-- | All set flags
+--
+-- This is @O(n)@ in the number of constructs of the @flag@ ADT; while that is
+-- technically speaking a constant, making this function @O(1)@, this is still
+-- a relatively expensive function. Consider using 'flagIsSet' instead.
+--
+-- Returns a 'Left' value if some bits in the enum did not correspond to any
+-- known @hs@ flag.
+--
+-- NOTE: The @Enum@ and @Bounded@ instances are simply used to enumerate all
+-- flags. Their definition has no bearing on the generated C code, and can
+-- simply be derived.
+fromBitfieldEnum :: forall hs.
+     (IsSingleFlag hs, Enum hs, Bounded hs)
+  => BitfieldEnum hs -> Either CUInt [hs]
+fromBitfieldEnum i@(BitfieldEnum c)
+  | bitfieldEnum allRecognized == i
+  = Right allRecognized
+
+  | otherwise
+  = Left c
+  where
+    allRecognized :: [hs]
+    allRecognized = [flag | flag <- [minBound .. maxBound], flagIsSet i flag]
diff --git a/src/Clang/Enum/Simple.hs b/src/Clang/Enum/Simple.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Enum/Simple.hs
@@ -0,0 +1,180 @@
+{-# LANGUAGE CPP #-}
+
+module Clang.Enum.Simple (
+    SimpleEnum(..)
+  , IsSimpleEnum(..)
+  , SimpleEnumOutOfRange(..)
+    -- * API
+  , simpleEnum
+  , coerceSimpleEnum
+  , fromSimpleEnum
+  , simpleEnumInRange
+  , unsafeFromSimpleEnum
+  ) where
+
+import Control.Exception
+import Data.Coerce
+import Data.Kind
+import Data.Typeable
+import Foreign.C
+import GHC.Generics (Generic)
+import GHC.Show (appPrec1, showSpace)
+import GHC.Stack
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | ADTs corresponding to simple enums
+--
+-- Instances should satisfy the following laws:
+--
+-- > forall (x :: hs).   simpleFromC (simpleToC x) == Just x
+-- > forall (i :: CInt). if   simpleFromC i == Just x
+-- >                     then simpleToC   x == i
+--
+-- We require 'Typeable' so that we can show the Haskell type in error messages
+-- (since it's the Haskell type that determines the range of the enum).
+--
+-- See 'SimpleEnum' for additional discussion.
+class Typeable hs => IsSimpleEnum (hs :: Type) where
+  -- | Translate Haskell constructor to C value
+  simpleToC :: hs -> CInt
+
+  -- | Translate C value to haskell constructor
+  --
+  -- This returns a 'Maybe' value, because C enums do not restrict the range.
+  -- From Wikipedia (<https://en.wikipedia.org/wiki/C_syntax#Enumerated_type>):
+  --
+  -- > Some compilers warn if an object with enumerated type is assigned a value
+  -- > that is not one of its constants. However, such an object can be assigned
+  -- > any values in the range of their compatible type, and enum constants can
+  -- > be used anywhere an integer is expected. For this reason, enum values are
+  -- > often used in place of preprocessor #define directives to create named
+  -- > constants. Such constants are generally safer to use than macros, since
+  -- > they reside within a specific identifier namespace.
+  --
+  -- This means that a 'Nothing' value is not necessary an error.
+  simpleFromC :: CInt -> Maybe hs
+
+-- | Simple C enums
+--
+-- Suppose we have a simple C enum defined like this:
+--
+-- > enum SomeEnum {
+-- >   Value1,
+-- >   Value2,
+-- >   Value3
+-- > };
+--
+-- Then 'SimpleEnum' can link the underlying 'CInt' to a Haskell ADT. Using
+-- @hsc2hs@, this might look like
+--
+-- > data SomeEnum = Value1 | Value2 | Value3
+-- >
+-- > instance IsSimpleEnum SomeEnum where
+-- >   simpleToC Value1 = #const Value1
+-- >   simpleToC Value2 = #const Value2
+-- >   simpleToC Value3 = #const Value3
+-- >
+-- >   simpleFromC (#const Value1) = Just Value1
+-- >   simpleFromC (#const Value2) = Just Value2
+-- >   simpleFromC (#const Value3) = Just Value3
+-- >
+-- >   simpleFromC _otherwise = Nothing
+newtype SimpleEnum (hs :: Type) = SimpleEnum CInt
+  deriving stock (Eq, Ord, Generic)
+
+{-------------------------------------------------------------------------------
+  Showing values
+-------------------------------------------------------------------------------}
+
+instance (IsSimpleEnum hs, Show hs) => Show (SimpleEnum hs) where
+  showsPrec p i = showParen (p >= appPrec1) $
+      either (uncurry showC) showHs $ showSimpleEnum i
+    where
+      showC :: CInt -> TypeRep -> ShowS
+      showC c typ  =
+            showString "SimpleEnum @"
+          . showsPrec appPrec1 typ
+          . showSpace
+          . showsPrec appPrec1 c
+
+      showHs :: hs -> ShowS
+      showHs hs =
+             showString "simpleEnum "
+           . showsPrec appPrec1 hs
+
+-- | Internal auxiliary for showing 'SimpleEnum'
+showSimpleEnum :: forall hs.
+     IsSimpleEnum hs
+  => SimpleEnum hs -> Either (CInt, TypeRep) hs
+showSimpleEnum =
+    either (Left . showC) Right . fromSimpleEnum
+  where
+    showC :: CInt -> (CInt, TypeRep)
+    showC c = (c, typeRep (Proxy @hs))
+
+{-------------------------------------------------------------------------------
+  API
+-------------------------------------------------------------------------------}
+
+-- | Construct 'SimpleEnum' from Haskell value
+--
+-- > forall (x :: hs). fromSimpleEnum (simpleEnum x) == Right x
+simpleEnum :: IsSimpleEnum hs => hs -> SimpleEnum hs
+simpleEnum = SimpleEnum . simpleToC
+
+-- | Construct 'SimpleEnum' from C value
+--
+-- The 'CInt' may be outside the range of the 'SimpleEnum'.
+--
+-- > forall (y :: CInt). if   fromSimpleEnum (coerceSimpleEnum y) == Right x
+-- >                     then simpleEnum x == coerceSimpleEnum y
+coerceSimpleEnum :: CInt -> SimpleEnum hs
+coerceSimpleEnum = coerce
+
+-- | Underlying C value
+--
+-- Returns the raw 'CInt' if is out of the range of @a@
+fromSimpleEnum :: IsSimpleEnum hs => SimpleEnum hs -> Either CInt hs
+fromSimpleEnum (SimpleEnum i) = maybe (Left i) Right $ simpleFromC i
+
+-- | Is the underlying C value in the range of the Haskell type?
+simpleEnumInRange :: IsSimpleEnum hs => SimpleEnum hs -> Bool
+simpleEnumInRange = either (const False) (const True) . fromSimpleEnum
+
+-- | Like 'fromSimpleEnum', but throws 'SimpleEnumOutOfRange' if out of range
+unsafeFromSimpleEnum :: forall hs.
+     (HasCallStack, IsSimpleEnum hs)
+  => SimpleEnum hs -> hs
+unsafeFromSimpleEnum = either (throw . err) id . fromSimpleEnum
+  where
+    err :: CInt -> SimpleEnumOutOfRange hs
+    err = SimpleEnumOutOfRange callStack
+
+-- | Exception thrown by 'unsafeFromSimpleEnum'
+data SimpleEnumOutOfRange (hs :: Type) = SimpleEnumOutOfRange CallStack CInt
+
+instance IsSimpleEnum hs => Exception (SimpleEnumOutOfRange hs) where
+  displayException (SimpleEnumOutOfRange cs i) = concat [
+        "C value "
+      , show i
+      , " out of range of "
+      , show (typeRep (Proxy @hs))
+      , " at "
+      , prettyCallStack cs
+      ]
+
+#if MIN_VERSION_base(4,20,0)
+  backtraceDesired _ = False
+#endif
+
+instance IsSimpleEnum hs => Show (SimpleEnumOutOfRange hs) where
+  showsPrec p (SimpleEnumOutOfRange cs i) = showParen (p >= appPrec1) $
+        showString "SimpleEnumOutOfRange @"
+      . showsPrec appPrec1 (typeRep (Proxy @hs))
+      . showSpace
+      . showsPrec appPrec1 cs
+      . showSpace
+      . showsPrec appPrec1 i
diff --git a/src/Clang/HighLevel.hs b/src/Clang/HighLevel.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel.hs
@@ -0,0 +1,62 @@
+-- | High-level API to @libclang@
+--
+-- The functions in this module (intentionally) clash with the corresponding
+-- function in "Clang.LowLevel.Core": the hope is that by keeping the names of
+-- corresponding functions the same, the API is easier to use. You may therefore
+-- wish to import this module qualified. Typical usage:
+--
+-- > import Clang.HighLevel qualified as HighLevel
+-- > import Clang.HighLevel.Types
+--
+-- The "Clang.HighLevel.Types" module avoids name clashes and is intended for
+-- unqualified import.
+module Clang.HighLevel (
+    -- * Source locations
+    -- ** Get single location
+    clang_getExpansionLocation
+  , clang_getPresumedLocation
+  , clang_getSpellingLocation
+  , clang_getFileLocation
+    -- ** Pretty-printing
+  , ShowFile(..)
+  , prettySingleLoc
+  , prettyMultiLoc
+  , prettyRangeSingleLoc
+  , prettyRangeMultiLoc
+    -- ** Convenience wrappers
+    -- *** for @CXSourceLocation@
+  , clang_getDiagnosticLocation
+  , clang_getCursorLocation
+  , clang_getCursorLocation'
+  , clang_getTokenLocation
+    -- *** for @CXSourceRange@
+  , clang_getDiagnosticRange
+  , clang_getDiagnosticFixIt
+  , clang_Cursor_getSpellingNameRange
+  , clang_getCursorExtent
+  , clang_getTokenExtent
+    -- * Tokens
+  , clang_tokenize
+    -- * Diagnostics
+  , clang_getDiagnostics
+    -- * Folds
+  , clang_visitChildren
+    -- * Declaration classification
+  , classifyDeclaration
+  , classifyTentativeDefinition
+    -- * General wrappers
+  , withIndex
+  , withTranslationUnit
+  , withTranslationUnit2
+  , withUnsavedFile
+    -- * Evaluation
+  , clang_evaluate
+  ) where
+
+import Clang.HighLevel.Declaration
+import Clang.HighLevel.Diagnostics
+import Clang.HighLevel.Evaluate
+import Clang.HighLevel.Fold
+import Clang.HighLevel.SourceLoc
+import Clang.HighLevel.Tokens
+import Clang.HighLevel.Wrappers
diff --git a/src/Clang/HighLevel/Declaration.hs b/src/Clang/HighLevel/Declaration.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Declaration.hs
@@ -0,0 +1,108 @@
+module Clang.HighLevel.Declaration (
+    -- * Declaration
+    DeclarationClassification(..)
+  , classifyDeclaration
+    -- * Other
+  , classifyTentativeDefinition
+  ) where
+
+import Control.Monad.IO.Class
+
+import Clang.Enum.Simple
+import Clang.LowLevel.Core (CXCursor, CX_StorageClass (..))
+import Clang.LowLevel.Core qualified as LowLevel
+
+{-------------------------------------------------------------------------------
+  Declaration
+-------------------------------------------------------------------------------}
+
+-- | Declaration classification
+--
+-- This classification function is suitable for declarations of functions,
+-- variables, enums, structs, and unions.
+--
+-- Forward declarations and redeclarations can be classified as either
+-- 'DefinitionElsewhere' or 'DefinitionUnavailable'.
+--
+-- <https://en.cppreference.com/w/c/language/struct.html#Forward_declaration>
+--
+-- <https://en.cppreference.com/w/c/language/declarations.html#Redeclaration>
+--
+-- Despite the name, a tentative definition is /not/ classified as a
+-- 'Definition'. Use 'classifyTentativeDefinition' to detect whether a
+-- declaration is a tentative definition.
+--
+-- <https://en.cppreference.com/w/c/language/extern.html#Tentative_definitions>
+data DeclarationClassification =
+    -- | A declaration together with a definition.
+    --
+    -- > int foo (void) { return 1; }; // cursor positioned here
+    --
+    -- <https://en.cppreference.com/w/c/language/declarations.html#Definitions>
+    Definition
+
+    -- | A declaration without definition, but the definition is available
+    -- elsewhere in the translation unit.
+    --
+    -- > struct X; // cursor positioned here
+    -- > struct X { int n; };
+  | DefinitionElsewhere CXCursor
+
+    -- | A declaration without a definition, and there is no definition
+    -- available elsewhere in the translation unit.
+    --
+    -- > extern int x; // cursor positioned here
+  | DefinitionUnavailable
+  deriving stock (Show, Eq)
+
+-- | Classify a declaration
+classifyDeclaration ::
+     MonadIO m
+  => CXCursor  -- ^ Declaration
+  -> m DeclarationClassification
+classifyDeclaration cursor = do
+    defnCursor <- LowLevel.clang_getCursorDefinition cursor
+    isDefnNull <- LowLevel.clang_equalCursors defnCursor LowLevel.nullCursor
+    if isDefnNull
+      then return DefinitionUnavailable
+      else do
+        isCursorDefn <- LowLevel.clang_equalCursors cursor defnCursor
+        return $
+          if isCursorDefn
+            then Definition
+            else DefinitionElsewhere defnCursor
+
+{-------------------------------------------------------------------------------
+  Other
+-------------------------------------------------------------------------------}
+
+-- | Classify whether a declaration of a global variable is a tentative
+-- definition.
+--
+-- NOTE: this function assumes that the cursor points to a global variable
+-- declaration.
+--
+-- A tentative definition is an external declaration without an initializer,
+-- and either without a storage-class specifier or with the specifier static.
+--
+-- A tentative definition is a declaration that may or may not act as a
+-- definition. If an actual external definition is found earlier or later in the
+-- same translation unit, then the tentative definition just acts as a
+-- declaration.
+--
+-- <https://en.cppreference.com/w/c/language/extern.html#Tentative_definitions>
+classifyTentativeDefinition ::
+     MonadIO m
+  => CXCursor
+  -> m Bool
+classifyTentativeDefinition cursor = do
+    initrCursor <- LowLevel.clang_Cursor_getVarDeclInitializer cursor
+    isInitrNull <- LowLevel.clang_equalCursors initrCursor LowLevel.nullCursor
+    if isInitrNull
+      then do
+        storage <- LowLevel.clang_Cursor_getStorageClass cursor
+        case fromSimpleEnum storage of
+          Right CX_SC_Static -> pure True
+          Right CX_SC_None -> pure True
+          _ -> pure False
+      else pure False
diff --git a/src/Clang/HighLevel/Diagnostics.hs b/src/Clang/HighLevel/Diagnostics.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Diagnostics.hs
@@ -0,0 +1,205 @@
+module Clang.HighLevel.Diagnostics (
+    Diagnostic(..)
+  , FixIt(..)
+  , clang_getDiagnostics
+  , diagnosticIsError
+  ) where
+
+import Control.Exception
+import Control.Monad.IO.Class
+import Data.Text (Text)
+import Data.Text qualified as Text
+import Foreign.C
+
+import Clang.Enum.Bitfield
+import Clang.Enum.Simple
+import Clang.HighLevel.SourceLoc (MultiLoc, Range)
+import Clang.HighLevel.SourceLoc qualified as SourceLoc
+import Clang.LowLevel.Core
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+data Diagnostic = Diagnostic {
+      -- | Formatted by @libclang@ in a manner that is suitable for display
+      diagnosticFormatted :: Text
+
+      -- | Severity
+    , diagnosticSeverity :: SimpleEnum CXDiagnosticSeverity
+
+      -- | Source location (where Clang would print the caret @^@)
+    , diagnosticLocation  :: MultiLoc
+
+      -- | Text of the diagnostic
+    , diagnosticSpelling  :: Text
+
+      -- | The command line option that enabled this diagnostic
+    , diagnosticOption :: Maybe Text
+
+      -- | The @libclang@ option to disable this diagnostic
+    , diagnosticDisabledBy :: Maybe Text
+
+      -- | Diagnostic category
+    , diagnosticCategory :: Int
+
+      -- | Rendered category
+    , diagnosticCategoryText :: Text
+
+      -- | Source range associated with the diagnostic
+      --
+      -- A diagnostic's source ranges highlight important elements in the source
+      -- code. On the command line, Clang displays source ranges by underlining
+      -- them with @~@ characters.
+    , diagnosticRanges :: [Range MultiLoc]
+
+      -- | Fix-it hints
+    , diagnosticFixIts :: [FixIt]
+
+      -- | Child diagnostics
+    , diagnosticChildren  :: [Diagnostic]
+    }
+  deriving stock (Show, Eq)
+  deriving anyclass (Exception)
+
+-- | Suggestion to fix the code
+--
+-- Fix-its are described in terms of a source range whose contents should be
+-- replaced by a string. This approach generalizes over three kinds of
+-- operations: removal of source code (the range covers the code to be removed
+-- and the replacement string is empty), replacement of source code (the range
+-- covers the code to be replaced and the replacement string provides the new
+-- code), and insertion (both the start and end of the range point at the
+-- insertion location, and the replacement string provides the text to insert).
+data FixIt = FixIt {
+      -- | Replacement range
+      --
+      -- The replacement range is the source range whose contents will be
+      -- replaced with the returned replacement string. Note that source ranges
+      -- are half-open ranges [a, b), so the source code should be replaced from
+      -- a and up to (but not including) b.
+      fixItRange :: Range MultiLoc
+
+      -- | Text that should replace the source code
+    , fixItReplacement :: Text
+    }
+  deriving stock (Show, Eq)
+
+-- TODO <https://github.com/well-typed/libclang-bindings/issues/73>
+--
+-- Probably separate into Info/Warning/Error (issue #175).
+diagnosticIsError :: Diagnostic -> Bool
+diagnosticIsError diag =
+    case fromSimpleEnum (diagnosticSeverity diag) of
+      Right CXDiagnostic_Error -> True
+      Right CXDiagnostic_Fatal -> True
+      Left _unknownSeverity    -> True
+      Right _otherwise         -> False
+
+{-------------------------------------------------------------------------------
+  Top-level
+-------------------------------------------------------------------------------}
+
+clang_getDiagnostics ::
+     MonadIO m
+  => CXTranslationUnit
+  -> Maybe (BitfieldEnum CXDiagnosticDisplayOptions)
+     -- ^ Display options for constructing 'diagnosticFormatted'
+     --
+     -- If 'Nothing', uses 'clang_defaultDiagnosticDisplayOptions'.
+  -> m [Diagnostic]
+clang_getDiagnostics unit mDisplayOptions = do
+    displayOptions <- case mDisplayOptions of
+                        Just displayOptions -> return displayOptions
+                        Nothing -> clang_defaultDiagnosticDisplayOptions
+    getAll unit clang_getNumDiagnostics $ getDiagnostic displayOptions
+
+{-------------------------------------------------------------------------------
+  Get all diagnostics
+-------------------------------------------------------------------------------}
+
+getDiagnostic ::
+     MonadIO m
+  => BitfieldEnum CXDiagnosticDisplayOptions
+  -> CXTranslationUnit
+  -> CUInt
+  -> m Diagnostic
+getDiagnostic displayOptions unit i = liftIO $
+    bracket (clang_getDiagnostic unit i) clang_disposeDiagnostic $
+      reify displayOptions
+
+getDiagnosticInSet ::
+     MonadIO m
+  => BitfieldEnum CXDiagnosticDisplayOptions
+  -> CXDiagnosticSet
+  -> CUInt
+  -> m Diagnostic
+getDiagnosticInSet displayOptions set i = liftIO $
+    bracket (clang_getDiagnosticInSet set i) clang_disposeDiagnostic $
+      reify displayOptions
+
+reify ::
+     MonadIO m
+  => BitfieldEnum CXDiagnosticDisplayOptions
+  -> CXDiagnostic
+  -> m Diagnostic
+reify displayOptions diag = do
+    diagnosticFormatted    <- clang_formatDiagnostic diag displayOptions
+    diagnosticSeverity     <- clang_getDiagnosticSeverity diag
+    diagnosticLocation     <- SourceLoc.clang_getDiagnosticLocation diag
+    diagnosticSpelling     <- clang_getDiagnosticSpelling diag
+    (mOption, mDisabledBy) <- clang_getDiagnosticOption diag
+    diagnosticCategory     <- fromIntegral <$> clang_getDiagnosticCategory diag
+    diagnosticCategoryText <- clang_getDiagnosticCategoryText diag
+    diagnosticRanges       <- getAll diag clang_getDiagnosticNumRanges $
+                                SourceLoc.clang_getDiagnosticRange
+    diagnosticFixIts       <- getAll diag clang_getDiagnosticNumFixIts $
+                                getDiagnosticFixIt
+    diagnosticChildren     <- getChildDiagnostics displayOptions diag
+    return $ Diagnostic {
+          diagnosticFormatted
+        , diagnosticSeverity
+        , diagnosticLocation
+        , diagnosticSpelling
+        , diagnosticOption     = nonEmpty mOption
+        , diagnosticDisabledBy = nonEmpty mDisabledBy
+        , diagnosticCategory
+        , diagnosticCategoryText
+        , diagnosticRanges
+        , diagnosticFixIts
+        , diagnosticChildren
+        }
+  where
+    nonEmpty :: Text -> Maybe Text
+    nonEmpty bs
+      | Text.null bs = Nothing
+      | otherwise    = Just bs
+
+getChildDiagnostics ::
+     MonadIO m
+  => BitfieldEnum CXDiagnosticDisplayOptions
+  -> CXDiagnostic
+  -> m [Diagnostic]
+getChildDiagnostics displayOptions diag = do
+    set <- clang_getChildDiagnostics diag
+    getAll set clang_getNumDiagnosticsInSet $
+      getDiagnosticInSet displayOptions
+
+getDiagnosticFixIt ::
+     MonadIO m
+  => CXDiagnostic
+  -> CUInt
+  -> m FixIt
+getDiagnosticFixIt diag i =
+    uncurry FixIt <$> SourceLoc.clang_getDiagnosticFixIt diag i
+
+{-------------------------------------------------------------------------------
+  Auxiliary
+-------------------------------------------------------------------------------}
+
+getAll :: Monad m => a -> (a -> m CUInt) -> (a -> CUInt -> m b) -> m [b]
+getAll x getCount getElem = do
+    count <- getCount x
+    if count == 0
+      then return []
+      else mapM (getElem x) [0 .. pred count]
diff --git a/src/Clang/HighLevel/Documentation.hs b/src/Clang/HighLevel/Documentation.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Documentation.hs
@@ -0,0 +1,332 @@
+{-# LANGUAGE RecordWildCards #-}
+
+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
+{-# HLINT ignore "Use panicIO" #-}
+
+module Clang.HighLevel.Documentation (
+    -- * Definition
+    Comment(..)
+  , CommentBlockContent(..)
+  , CommentInlineContent(..)
+  , CXCommentInlineCommandRenderKind(..)
+  , CXCommentParamPassDirection(..)
+    -- * Top-Level
+  , clang_getComment
+  ) where
+
+import Control.Monad
+import Control.Monad.IO.Class
+import Data.Char (isPunctuation)
+import Data.Either
+import Data.Text (Text)
+import Data.Text qualified as Text
+import GHC.Generics (Generic)
+
+import Clang.Enum.Simple
+import Clang.LowLevel.Core
+import Clang.LowLevel.Doxygen
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Reified Clang comment
+--
+-- This type corresponds to a @CXComment_FullComment@ comment.
+--
+-- The @CXComment_Null@ kind is not represented by this type.
+-- @'Maybe' 'Comment'@ is used instead, where a @CXComment_Null@ comment is
+-- represented by 'Nothing'.
+--
+-- The 'ref' type parameter is to be filled by the user. This data type will
+-- allow one to cross reference C identifiers when translating from Doxygen to
+-- Haddocks.
+--
+newtype Comment ref = Comment {
+      -- | Children of a the comment
+      commentChildren :: [CommentBlockContent ref]
+    }
+  deriving stock (Functor, Foldable, Traversable, Show, Eq, Ord, Generic)
+
+-- | Reified Clang comment block content
+data CommentBlockContent ref =
+      Paragraph {
+        paragraphContent :: [CommentInlineContent ref]
+      }
+    | BlockCommand {
+        blockCommandName :: Text
+      , blockCommandArgs :: [Text]
+      , blockCommandParagraph :: [CommentInlineContent ref]
+      }
+    | ParamCommand {
+        paramCommandName                :: Text
+      , paramCommandIndex               :: Maybe Int
+      , paramCommandDirection           :: Maybe CXCommentParamPassDirection
+      , paramCommandIsDirectionExplicit :: Bool
+      , paramCommandContent             :: [CommentBlockContent ref]
+      }
+    | TParamCommand {
+        tParamCommandName     :: Text
+      , tParamCommandPosition :: Maybe [(Int, Int)]
+      , tParamCommandContent  :: [CommentBlockContent ref]
+      }
+    | VerbatimBlockCommand {
+        verbatimBlockLines :: [Text]
+      }
+    | VerbatimLine {
+        verbatimLine :: Text
+      }
+  deriving stock (Functor, Foldable, Traversable, Show, Eq, Ord, Generic)
+
+-- | Reified Clang comment inline content
+data CommentInlineContent ref =
+      TextContent {
+        textContent :: Text
+      }
+    | InlineCommand {
+        inlineCommandName       :: Text
+      , inlineCommandRenderKind :: CXCommentInlineCommandRenderKind
+      , inlineCommandArgs       :: [Text]
+      }
+    | InlineRefCommand {
+        inlineCommandArg :: ref
+      }
+    | HtmlStartTag {
+        htmlStartTagName          :: Text
+      , htmlStartTagIsSelfClosing :: Bool
+      , htmlStartTagAttributes    :: [(Text, Text)]
+      }
+    | HtmlEndTag {
+        htmlEndTagName :: Text
+      }
+  deriving stock (Functor, Foldable, Traversable, Show, Eq, Ord, Generic)
+
+{-------------------------------------------------------------------------------
+  Top-level
+-------------------------------------------------------------------------------}
+
+-- | Reify the Clang comment for a cursor to the Haskell type
+--
+-- An error is thrown when an unexpected comment kind is encountered, such as
+-- block content within inline content.
+clang_getComment :: MonadIO m => CXCursor -> m (Maybe (Comment Text))
+clang_getComment cursor = do
+    comment <- clang_Cursor_getParsedComment cursor
+    eCommentKind <- fromSimpleEnum <$> clang_Comment_getKind comment
+    case eCommentKind of
+      Right CXComment_Null -> pure Nothing
+      Right CXComment_FullComment -> do
+        commentChildren <- getChildren (getBlockContent cursor) comment
+        pure $ Just Comment{..}
+      Right commentKind ->
+        errorWithContext cursor $ "root comment of kind " ++ show commentKind
+      Left n ->
+        errorWithContext cursor $ "root comment with invalid kind " ++ show n
+
+-- | Reify block content
+--
+-- An error is thrown when an unexpected comment kind is encountered.
+getBlockContent ::
+     MonadIO m
+  => CXCursor -- ^ cursor to provide context in error messages
+  -> CXComment
+  -> m (CommentBlockContent Text)
+getBlockContent cursor comment = do
+    eCommentKind <- fromSimpleEnum <$> clang_Comment_getKind comment
+    case eCommentKind of
+      Right CXComment_Paragraph -> do
+        paragraphContent <- concat <$> getChildren (getInlineContent cursor) comment
+        pure Paragraph{..}
+
+      Right CXComment_BlockCommand -> do
+        blockCommandName <- Text.strip <$> clang_BlockCommandComment_getCommandName comment
+        idxs <- getIdxs <$> clang_BlockCommandComment_getNumArgs comment
+        blockCommandArgs <-
+              fmap Text.strip
+          <$> mapM (clang_BlockCommandComment_getArgText comment) idxs
+        blockCommandParagraph <- fmap concat $ getChildren (getInlineContent cursor)
+          =<< clang_BlockCommandComment_getParagraph comment
+        pure BlockCommand{..}
+
+      Right CXComment_ParamCommand -> do
+        paramCommandName <- Text.strip <$> clang_ParamCommandComment_getParamName comment
+        paramCommandIndex <- do
+          isValid <- clang_ParamCommandComment_isParamIndexValid comment
+          if isValid
+            then
+              Just . fromIntegral
+                <$> clang_ParamCommandComment_getParamIndex comment
+            else pure Nothing
+        paramCommandDirection <-
+          either (const Nothing) Just . fromSimpleEnum
+            <$> clang_ParamCommandComment_getDirection comment
+        paramCommandIsDirectionExplicit <-
+          clang_ParamCommandComment_isDirectionExplicit comment
+        paramCommandContent <- getChildren (getBlockContent cursor) comment
+        pure ParamCommand{..}
+
+      Right CXComment_TParamCommand -> do
+        tParamCommandName <- Text.strip <$> clang_TParamCommandComment_getParamName comment
+        tParamCommandPosition <- do
+          isValid <- clang_TParamCommandComment_isParamPositionValid comment
+          if isValid
+            then fmap Just $ do
+              depth <- clang_TParamCommandComment_getDepth comment
+              forM [0 .. depth] $ \d ->
+                (fromIntegral d,) . fromIntegral
+                  <$> clang_TParamCommandComment_getIndex comment d
+            else pure Nothing
+        tParamCommandContent <- getChildren (getBlockContent cursor) comment
+        pure TParamCommand{..}
+
+      Right CXComment_VerbatimBlockCommand -> do
+        verbatimBlockLines <- fmap Text.strip
+                          <$> getChildren (getVerbatimBlockLine cursor) comment
+        pure VerbatimBlockCommand{..}
+
+      Right CXComment_VerbatimLine -> do
+        -- rest of line after misused command becomes a verbatim line
+        verbatimLine <- Text.strip
+                    <$> clang_VerbatimLineComment_getText comment
+        pure VerbatimLine{..}
+
+      Right commentKind -> errorWithContext cursor $
+        "child comment of non-block kind " ++ show commentKind
+
+      Left n ->
+        errorWithContext cursor $ "child comment with invalid kind " ++ show n
+
+-- | Reify inline content
+--
+-- An error is thrown when an unexpected comment kind is encountered.
+getInlineContent ::
+     MonadIO m
+  => CXCursor -- ^ cursor to provide context in error messages
+  -> CXComment
+  -> m [CommentInlineContent Text]
+getInlineContent cursor comment = do
+    eCommentKind <- fromSimpleEnum <$> clang_Comment_getKind comment
+    case eCommentKind of
+      Right CXComment_Text -> do
+        textContent <- Text.strip <$> clang_TextComment_getText comment
+        pure [TextContent{..}]
+
+      Right CXComment_InlineCommand -> do
+        inlineCommandName <- Text.strip <$> clang_InlineCommandComment_getCommandName comment
+        inlineCommandRenderKind <-
+          fromRight CXCommentInlineCommandRenderKind_Normal . fromSimpleEnum
+            <$> clang_InlineCommandComment_getRenderKind comment
+        idxs <- getIdxs <$> clang_InlineCommandComment_getNumArgs comment
+        inlineCommandArgs <-
+              fmap (Text.strip)
+          <$> mapM (clang_InlineCommandComment_getArgText comment) idxs
+        case Text.unpack inlineCommandName of
+          "ref" -> pure $ sanitize inlineCommandArgs
+          _     -> pure [InlineCommand{..}]
+
+      Right CXComment_HTMLStartTag -> do
+        htmlStartTagName <- Text.strip <$> clang_HTMLTagComment_getTagName comment
+        htmlStartTagIsSelfClosing <-
+          clang_HTMLStartTagComment_isSelfClosing comment
+        idxs <- getIdxs <$> clang_HTMLStartTag_getNumAttrs comment
+        htmlStartTagAttributes <- forM idxs $ \idx -> do
+          attrName  <- Text.strip <$> clang_HTMLStartTag_getAttrName  comment idx
+          attrValue <- Text.strip <$> clang_HTMLStartTag_getAttrValue comment idx
+          pure (attrName, attrValue)
+        pure [HtmlStartTag{..}]
+
+      Right CXComment_HTMLEndTag -> do
+        htmlEndTagName <- Text.strip <$> clang_HTMLTagComment_getTagName comment
+        pure [HtmlEndTag{..}]
+
+      Right commentKind -> errorWithContext cursor $
+        "child comment of non-inline kind " ++ show commentKind
+
+      Left n ->
+        errorWithContext cursor $ "child comment with invalid kind " ++ show n
+  where
+    -- | Splits strings to separate punctuation from alphanumeric text.
+    -- for every word, create an InlineRefCommand and for every punctuation
+    -- mark create a TextContent.
+    --
+    -- Example: ["foo,", "bar!"] becomes
+    --          [ InlineRefCommand "foo"
+    --          , TextContent ","
+    --          , InlineRefCommand "bar"
+    --          , TextContent "!"
+    --          ]
+    --          ["test_function,"] becomes
+    --          [InlineRefCommand "test_function", TextContent ","]
+    sanitize :: [Text] -> [CommentInlineContent Text]
+    sanitize = concatMap (splitPunctuation . Text.unpack)
+      where
+        splitPunctuation [] = []
+        splitPunctuation (c:cs)
+          | isPunctuation c
+          , c /= '_'  = TextContent (Text.pack [c]) : splitPunctuation cs
+          | otherwise =
+              case break (\x -> isPunctuation x && x /= '_')  (c:cs) of
+                (word, rest) -> InlineRefCommand (Text.pack word) : splitPunctuation rest
+
+-- | Get a verbatim block line as 'Text'
+--
+-- An error is thrown when an unexpected comment kind is encountered.
+getVerbatimBlockLine ::
+     MonadIO m
+  => CXCursor -- ^ cursor to provide context in error messages
+  -> CXComment
+  -> m Text
+getVerbatimBlockLine cursor comment = do
+    eCommentKind <- fromSimpleEnum <$> clang_Comment_getKind comment
+    case eCommentKind of
+      Right CXComment_VerbatimBlockLine ->
+            Text.strip
+        <$> clang_VerbatimBlockLineComment_getText comment
+
+      Right commentKind -> errorWithContext cursor $
+        "child comment of non-verbatim-block-line kind " ++ show commentKind
+
+      Left n ->
+        errorWithContext cursor $ "child comment with invalid kind " ++ show n
+
+-- | Reify children
+getChildren :: MonadIO m => (CXComment -> m a) -> CXComment -> m [a]
+getChildren f comment = do
+    idxs <- getIdxs <$> clang_Comment_getNumChildren comment
+    mapM (f <=< clang_Comment_getChild comment) idxs
+
+-- | Get indexes (zero-based)
+getIdxs :: (Enum a, Eq a, Num a)
+  => a  -- ^ number of items
+  -> [a]
+getIdxs 0 = []
+getIdxs n = [0 .. n - 1]
+
+{-------------------------------------------------------------------------------
+  Translation
+-------------------------------------------------------------------------------}
+
+-- See "HsBindgen.Backend.Artefact.HsModule.Render"
+
+{-------------------------------------------------------------------------------
+  Auxiliary Functions
+-------------------------------------------------------------------------------}
+
+-- | Throw an error with context information
+errorWithContext ::
+     MonadIO m
+  => CXCursor -- ^ cursor to provide context in error messages
+  -> String   -- ^ error message
+  -> m a
+errorWithContext cursor msg = liftIO $ do
+    displayName <- clang_getCursorDisplayName cursor
+    extent <- clang_getCursorExtent cursor
+    (file, startLine, startCol) <-
+      clang_getPresumedLocation =<< clang_getRangeStart extent
+    (_, endLine, endCol) <-
+      clang_getPresumedLocation =<< clang_getRangeEnd extent
+    fail $ concat
+      [ msg, ": cursor ", show displayName, " in ", show file, " ("
+      , show startLine, ":", show startCol, "-", show endLine, ":"
+      , show endCol, ")"
+      ]
diff --git a/src/Clang/HighLevel/Evaluate.hs b/src/Clang/HighLevel/Evaluate.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Evaluate.hs
@@ -0,0 +1,52 @@
+module Clang.HighLevel.Evaluate (
+    -- * Types
+    EvalResult(..)
+    -- * API
+  , clang_evaluate
+  ) where
+
+import Control.Monad.Catch
+import Control.Monad.IO.Class
+import Foreign.C qualified as C
+
+import Clang.Enum.Simple
+import Clang.LowLevel.Core
+
+{-------------------------------------------------------------------------------
+  Types
+-------------------------------------------------------------------------------}
+
+-- | Evaluation result
+data EvalResult =
+    -- | Result as an 'Integer'
+    EvalResultInteger Integer
+  | -- | Result as a 'C.CDouble'
+    EvalResultCDouble C.CDouble
+  | -- | Result as a 'String'
+    EvalResultString  String
+  deriving stock (Show)
+
+{-------------------------------------------------------------------------------
+  API
+-------------------------------------------------------------------------------}
+
+-- | Evaluate a statement, variable (initializer), or expression
+--
+-- LLVM/Clang documentation is sparse, and enumeration 'CXEvalResultKind'
+-- specifies kinds that do not exactly match the API for getting evaluation
+-- results.  Any use of this function should be tested thoroughly.
+clang_evaluate :: (MonadIO m, MonadMask m) => CXCursor -> m (Maybe EvalResult)
+clang_evaluate cursor =
+    bracket (clang_Cursor_Evaluate cursor) clang_EvalResult_dispose $ \er ->
+      (fromSimpleEnum <$> clang_EvalResult_getKind er) >>= \case
+        Left{} -> return Nothing
+        Right CXEval_UnExposed -> return Nothing
+        Right CXEval_Int -> fmap (Just . EvalResultInteger) $ do
+          isUnsigned <- clang_EvalResult_isUnsignedInt er
+          if isUnsigned
+            then toInteger <$> clang_EvalResult_getAsUnsigned er
+            else toInteger <$> clang_EvalResult_getAsLongLong er
+        Right CXEval_Float ->
+          Just . EvalResultCDouble <$> clang_EvalResult_getAsDouble er
+        Right{} ->
+          Just . EvalResultString <$> clang_EvalResult_getAsStr er
diff --git a/src/Clang/HighLevel/Fold.hs b/src/Clang/HighLevel/Fold.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Fold.hs
@@ -0,0 +1,520 @@
+-- | Higher-level bindings for traversing the API
+--
+-- Intended for unqualified import.
+module Clang.HighLevel.Fold (
+    -- * Folds
+    Fold -- opaque
+  , HandlerResult(..)
+  , Next -- opaque
+    -- * Construction
+  , simpleFold
+  , foldWithHandler
+  , FoldException (..)
+  , foldTry
+    -- * Fold-specific operations
+  , foldBreak
+  , foldBreakWith
+  , foldBreakOpt
+  , foldContinue
+  , foldContinueWith
+  , foldContinueOpt
+  , foldRecurse
+  , foldRecurseWith
+  , foldRecurseOpt
+  , foldRecursePure
+  , foldRecursePureOpt
+    -- * Execution
+  , clang_visitChildren
+  ) where
+
+import Control.Exception (Exception (..))
+import Control.Exception qualified as Base
+import Control.Monad (forM_)
+import Control.Monad.IO.Class (MonadIO, liftIO)
+import Control.Monad.IO.Unlift (MonadUnliftIO (withRunInIO))
+import Data.IORef
+import GHC.Stack
+
+import Clang.Enum.Simple
+import Clang.Internal.Exception
+import Clang.LowLevel.Core hiding (clang_visitChildren)
+import Clang.LowLevel.Core qualified as Core
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Typed fold over the AST
+--
+-- This is similar to @CXCursorVisitor@, but
+--
+-- * we allow for (typed) results
+-- * when recursing into the children of a node, we get to specify a /different/
+--   function
+--
+-- This provides for a much nicer user experience.
+data Fold m a = Fold{
+      foldNext    :: CXCursor -> m (Next m a)
+    , foldHandler :: CXCursor -> ExactException -> m (HandlerResult (Maybe a))
+    }
+
+-- | Construct simple fold
+--
+-- See also 'foldWithHandler'.
+simpleFold :: forall m a. MonadIO m => (CXCursor -> m (Next m a)) -> Fold m a
+simpleFold foldNext =
+    Fold{foldNext, foldHandler}
+  where
+    foldHandler :: CXCursor -> ExactException -> m (HandlerResult (Maybe a))
+    foldHandler _curr _e = return HandlerRethrow
+
+-- | Fold with exception handler
+--
+-- The exception handler is provided a 'CXCursor' pointing to the location in
+-- the AST where the exception was caught.
+--
+-- == Exception handling in folds
+--
+-- Suppose we have a C file that looks like this:
+--
+-- > struct foo {
+-- >   int a;
+-- >   int b;
+-- > };
+-- >
+-- > struct bar {
+-- >   int c;
+-- >   int d;
+-- > };
+-- >
+-- > struct baz {
+-- >   int e;
+-- >   int f;
+-- > };
+--
+-- and suppose we want to define a fold that extracts all struct field names,
+-- so that we end up with
+--
+-- > [["a", "b"], ["c", "d"], ["e", "f"]]
+--
+-- We can write such a fold as follows:
+--
+-- > foldStruct :: Fold IO [Text]
+-- > foldStruct = simpleFold $ \curr -> do
+-- >     kind <- fromSimpleEnum <$> clang_getCursorKind curr
+-- >     case kind of
+-- >       Right CXCursor_StructDecl ->
+-- >         foldRecursePure foldField concat
+-- >       _otherwise ->
+-- >         error $ "unexpected: " ++ show kind
+-- >
+-- > foldField :: Fold IO [Text]
+-- > foldField = simpleFold $ \curr -> do
+-- >     kind <- fromSimpleEnum <$> clang_getCursorKind curr
+-- >     case kind of
+-- >       Right CXCursor_FieldDecl -> do
+-- >         name <- clang_getCursorSpelling curr
+-- >         foldContinueWith [name]
+-- >       _otherwise ->
+-- >         error $ "unexpected: " ++ show kind
+--
+-- Let's consider what happens if 'foldField' throws an exception; for example,
+-- perhaps it throws an exception when it sees the name \"c\":
+--
+-- > data UnexpectedField = UnexpectedField
+-- >
+-- > foldField :: Fold IO [Text]
+-- > foldField = simpleFold $ \curr -> do
+-- >     kind <- fromSimpleEnum <$> clang_getCursorKind curr
+-- >     case kind of
+-- >       Right CXCursor_FieldDecl -> do
+-- >         name <- clang_getCursorSpelling curr
+-- >         if name == "c"
+-- >           then throwIO UnexpectedField
+-- >           else foldContinueWith [name]
+-- >       _otherwise ->
+-- >         error $ "unexpected: " ++ show kind
+--
+-- Perhaps we want to try and recover from this in 'foldStruct', returning the
+-- empty list of fields for that particular struct:
+--
+-- > hasUnexpectedField :: UnexpectedField -> [Text]
+-- > hasUnexpectedField UnexpectedField = []
+-- >
+-- > foldStruct :: Fold IO [Text]
+-- > foldStruct = simpleFold $ \curr ->
+-- >     handle (foldContinueWith . hasUnexpectedField) $ do
+-- >       -- .. body as before
+--
+-- Unfortunately, this will not work (that is, the handler will not catch the
+-- exception). The problem is that 'foldStruct' does not /really/ recurse to
+-- parse the fields: instead, it /returns/ a value which indicates that we are
+-- interested in the children of the node, along with a function that processes
+-- the results of parsing those child nodes (see 'foldRecurseWith').
+--
+-- Instead of using a local exception handler, you must therefore use
+-- 'foldWithHandler':
+--
+-- > foldStruct :: Fold IO [Text]
+-- > foldStruct =
+-- >     foldWithHandler (\_curr -> return . HandlerResult . Just . hasUnexpectedField) $ \curr -> do
+-- >       -- .. body as before
+--
+-- With this handler in place, we will get the expected result
+--
+-- > [["a", "b"], [], ["e", "f"]]
+--
+-- Put another way, 'foldWithHandler' can be used to install an exception handler
+-- which behaves /as if/ the fold truly made recursive calls.
+foldWithHandler :: forall m e a.
+     (MonadIO m, Exception e)
+  => (CXCursor -> e -> m (HandlerResult (Maybe a))) -- ^ Exception handler
+  -> (CXCursor -> m (Next m a))
+  -> Fold m a
+foldWithHandler handler foldNext =
+    Fold{foldNext, foldHandler}
+  where
+    foldHandler :: CXCursor -> ExactException -> m (HandlerResult (Maybe a))
+    foldHandler curr (WrapExactException se) =
+        case fromException se of
+          Just e' -> handler curr e'
+          Nothing -> return HandlerRethrow
+
+-- | An exception that is caught during folding
+data FoldException e = FoldException {
+    -- | The exception proper
+    exception :: e
+    -- | A cursor pointing to the location in the AST where the exception was
+    -- caught
+  , cursor    :: CXCursor
+  }
+  deriving stock Show
+
+-- | Like 'foldWithHandler', but return the caught exception as a value like
+-- 'Control.Exception.try' would.
+foldTry ::
+     forall e m a. (MonadIO m, Exception e)
+  => (CXCursor -> m (Next m a))
+  -> Fold m (Either (FoldException e) a)
+foldTry foldNext = foldWithHandler handler foldNext'
+  where
+    foldNext' ::
+         CXCursor
+      -> m (Next m (Either (FoldException e) a))
+    foldNext' curr = fmap (fmap Right) (foldNext curr)
+
+    handler ::
+         CXCursor
+      -> ExactException
+      -> m (HandlerResult (Maybe (Either (FoldException e) a)))
+    handler curr (WrapExactException se)
+      | Just e <- fromException @e se = do
+          return $ HandlerResult $  Just $ Left $ FoldException {
+              exception = e
+            , cursor = curr
+            }
+      | otherwise = return $ HandlerRethrow
+
+-- | Result of visiting one node
+--
+-- This is the equivalent of 'CXChildVisitResult'
+data Next m a where
+  Break    :: Maybe a -> Next m a
+  Continue :: Maybe a -> Next m a
+  Recurse  :: Fold m b -> ([b] -> m (Maybe a)) -> Next m a
+
+{-------------------------------------------------------------------------------
+  Constructing 'Next' ('Next' itself is intentionally opaque)
+-------------------------------------------------------------------------------}
+
+-- | Stop folding early, without a result
+--
+-- See also 'foldBreakWith' and 'foldBreakOpt'.
+--
+-- NOTE: \"break\" means that the fold is terminated entirely; it does /not/
+-- mean \"break to the immediate parent\".
+--
+-- This is the equivalent of 'CXChildVisit_Break'.
+foldBreak :: Monad m => m (Next m a)
+foldBreak = foldBreakOpt Nothing
+
+-- | Like 'foldBreak', but producing a result
+foldBreakWith :: Monad m => a -> m (Next m a)
+foldBreakWith = foldBreakOpt . Just
+
+-- | Generalization of 'foldBreak' and 'foldBreakWith' with optional result
+foldBreakOpt :: Monad m => Maybe a -> m (Next m a)
+foldBreakOpt = pure . Break
+
+-- | Continue with the next sibling of the current node, without a result
+--
+-- See also 'foldContinueWith' and 'foldContinueOpt'.
+--
+-- This is the equivalent of 'CXChildVisit_Continue'.
+foldContinue :: Monad m => m (Next m a)
+foldContinue = foldContinueOpt Nothing
+
+-- | Like 'foldContinue', but producing a result
+foldContinueWith :: Monad m => a -> m (Next m a)
+foldContinueWith = foldContinueOpt . Just
+
+-- | Generalization of 'foldContinue' and 'foldContinueWith' with optional result
+foldContinueOpt :: Monad m => Maybe a -> m (Next m a)
+foldContinueOpt = pure . Continue
+
+-- | Recurse into the children of the current node, without producing a result
+--
+-- Unlike in the low-level @clang@ interface, each time we recurse we can
+-- use a /different/ fold.
+--
+-- See also 'foldRecurseWith' if you want the results of the recursion.
+--
+-- This is the equivalent of 'CXChildVisit_Recurse'.
+foldRecurse :: Monad m => Fold m () -> m (Next m a)
+foldRecurse fold = foldRecursePureOpt fold (const Nothing)
+
+-- | Like 'foldRecurse', but producing a result
+--
+-- In this case, we must provide a @summarize@ function which turns the results
+-- obtained from processing the children into a result for the parent.
+foldRecurseWith :: Monad m => Fold m b -> ([b] -> m a) -> m (Next m a)
+foldRecurseWith fold summarize = foldRecurseOpt fold (fmap Just . summarize)
+
+-- | Generalization of 'foldRecurseWith' with an /optional/ result
+foldRecurseOpt :: Monad m => Fold m b -> ([b] -> m (Maybe a)) -> m (Next m a)
+foldRecurseOpt fold summarize = pure $ Recurse fold summarize
+
+-- | Pure variant on 'foldRecurseWith'
+foldRecursePure :: Monad m => Fold m b -> ([b] -> a) -> m (Next m a)
+foldRecursePure fold summarize = foldRecurseWith fold (pure . summarize)
+
+-- | Pure variant on 'foldRecurseOpt'
+foldRecursePureOpt :: Monad m => Fold m b -> ([b] -> Maybe a) -> m (Next m a)
+foldRecursePureOpt fold summarize = foldRecurseOpt fold (pure . summarize)
+
+{-------------------------------------------------------------------------------
+  Combinators
+-------------------------------------------------------------------------------}
+
+instance Functor m => Functor (Next m) where
+  fmap f (Break x)     = Break (fmap f x)
+  fmap f (Continue x)  = Continue (fmap f x)
+  fmap f (Recurse r g) = Recurse r (fmap (fmap f) . g)
+
+instance Functor m => Functor (Fold m) where
+  fmap f Fold{foldNext, foldHandler} = Fold{
+        foldNext    = \curr -> fmap (fmap f) $ foldNext curr
+      , foldHandler = \curr -> fmap (fmap (fmap f)) . foldHandler curr
+      }
+
+{-------------------------------------------------------------------------------
+  Internal: partial results
+
+  NOTE: These functions are ultimately called from a Haskel callback called from
+  the clang C library. They do not need to be (nor are) thread safe.
+-------------------------------------------------------------------------------}
+
+type PartialResults a = IORef (Either ExactException [a])
+
+newPartialResults :: IO (PartialResults a)
+newPartialResults = newIORef (Right [])
+
+addPartialResult :: HasCallStack => PartialResults a -> a -> IO ()
+addPartialResult ref x = do
+    mResults <- readIORef ref
+    case mResults of
+      Left  oldErr -> unexpectedException oldErr
+      Right xs     -> writeIORef ref $ Right (x:xs)
+
+recordException :: HasCallStack => PartialResults a -> ExactException -> IO ()
+recordException ref newErr = do
+    mResults <- readIORef ref
+    case mResults of
+      Left  oldErr -> unexpectedException oldErr
+      Right _xs    -> writeIORef ref $ Left newErr
+
+-- | Existing exceptions are impossible
+--
+-- As soon as any partial result throws an exception, we skip over any of the
+-- remaining children, and immediately to the @summarize@ function of the
+-- parent. This means that an existing exception should be impossible.
+--
+-- The use of @error@ here is an exception in its own right, which we don't
+-- propagate (it will be caught in the low-level 'Core.clang_visitChildren'
+-- function). However, that's okay: if this @error@ ever triggers, it indicates
+-- a bug in this infrastructure, which can't really be handlded anyway.
+unexpectedException :: HasCallStack => ExactException -> IO a
+unexpectedException oldErr = error $ concat [
+      "The impossible happened: we break at the first exception, "
+    , "yet here we are: " ++ show oldErr ++ ".\n"
+    , prettyCallStack callStack
+    ]
+
+getPartialResults :: MonadIO m => PartialResults a -> m [a]
+getPartialResults ref = liftIO $ do
+    mResults <- readIORef ref
+    case mResults of
+      Left  e  -> throwExact e
+      Right xs -> return (reverse xs)
+
+partialResultsIsException :: PartialResults a -> IO Bool
+partialResultsIsException ref = do
+    mResults <- readIORef ref
+    case mResults of
+      Left  _e  -> return True
+      Right _xs -> return False
+
+{-------------------------------------------------------------------------------
+  Internal: stack
+-------------------------------------------------------------------------------}
+
+data Processing m a = Processing {
+      -- | The AST node whose children we are processing
+      parent :: CXCursor
+
+      -- | The 'Fold' we are applying at this level
+    , currentFold :: Fold m a
+
+      -- | Results collected so far (in reverse order)
+    , partialResults :: PartialResults a
+    }
+
+data Stack m a where
+  Bottom :: Processing m a -> Stack m a
+  Push   :: Processing m a -> ([a] -> m (Maybe b)) -> Stack m b -> Stack m a
+
+topProcessing :: Stack m a -> Processing m a
+topProcessing (Bottom p)     = p
+topProcessing (Push   p _ _) = p
+
+topParent :: Stack m a -> CXCursor
+topParent = parent . topProcessing
+
+topFold :: Stack m a -> Fold m a
+topFold = currentFold . topProcessing
+
+topResults :: Stack m a -> PartialResults a
+topResults = partialResults . topProcessing
+
+data SomeStack m where
+ SomeStack :: Stack m a -> SomeStack m
+
+initStack ::
+     CXCursor
+  -> Fold m a
+  -> IO (Stack m a)
+initStack root topLevelFold = do
+    partialResults <- newPartialResults
+    let p = Processing {
+            parent      = root
+          , currentFold = topLevelFold
+          , partialResults
+          }
+    return $ Bottom p
+
+push ::
+     CXCursor
+  -> Fold m b
+  -> ([b] -> m (Maybe a))
+  -> Stack m a -> IO (Stack m b)
+push newParent fold summarize stack = do
+    partialResults <- newPartialResults
+    let p = Processing {
+            parent      = newParent
+          , currentFold = fold
+          , partialResults
+          }
+    return $ Push p summarize stack
+
+popUntil :: forall m.
+     MonadIO m
+  => RunInIO m
+  -> IORef (SomeStack m)
+  -> CXCursor -> IO ()
+popUntil runInIO someStack newParent = do
+    SomeStack stack <- liftIO $ readIORef someStack
+    stack' <- loop stack
+    liftIO $ writeIORef someStack stack'
+  where
+    loop :: Stack m a -> IO (SomeStack m)
+    loop stack = do
+        arrived <- clang_equalCursors (topParent stack) newParent
+        if arrived then
+          return $ SomeStack stack
+        else
+          case stack of
+            Bottom _ ->
+              error "popUntil: something has gone horribly wrong"
+            Push p summarize (stack' :: Stack m b) -> do
+              let handler :: ExactException -> m (HandlerResult (Maybe b))
+                  handler = foldHandler (topFold stack') (parent p)
+              mb <- Base.try $
+                handleUnliftUsing runInIO handler $
+                  summarize =<< getPartialResults (partialResults p)
+              case mb of
+                Right Nothing  -> return ()
+                Right (Just b) -> addPartialResult (topResults stack') b
+                Left  ex       -> recordException  (topResults stack') ex
+              loop stack'
+
+{-------------------------------------------------------------------------------
+  Traversal proper
+-------------------------------------------------------------------------------}
+
+-- | Fold the AST
+--
+-- This provides a higher-level API to 'Core.clang_visitChildren', in which
+--
+-- * visitors can return results
+-- * we can specify different visitors at different levels of the AST
+--
+-- See also 'clang_getTranslationUnitCursor'.
+clang_visitChildren :: forall m a.
+     MonadUnliftIO m
+  => CXCursor -> Fold m a -> m [a]
+clang_visitChildren root topLevelFold = withRunInIO $ \runInIO -> do
+    stack     <- initStack root topLevelFold
+    someStack <- newIORef $ SomeStack stack
+    _terminatedEarly <- Core.clang_visitChildren root $ visitor runInIO someStack
+    popUntil runInIO someStack root
+    getPartialResults (topResults stack)
+  where
+    visitor ::
+         RunInIO m
+      -> IORef (SomeStack m)
+      -> CXCursor
+      -> CXCursor
+      -> IO (SimpleEnum CXChildVisitResult)
+    visitor runInIO someStack current parent = do
+        popUntil runInIO someStack parent
+        SomeStack (stack :: Stack m x) <- readIORef someStack
+
+        let foldHandler    :: CXCursor -> ExactException -> m (HandlerResult (Maybe x))
+            foldNext       :: CXCursor -> m (Next m x)
+            partialResults :: PartialResults x
+            Processing{
+                currentFold = Fold{foldHandler, foldNext}
+              , partialResults
+              } = topProcessing stack
+
+        previousException <- partialResultsIsException partialResults
+        if previousException then
+          return $ simpleEnum CXChildVisit_Continue
+        else do
+          next <- Base.try $
+            handleUnliftUsing runInIO (fmap (fmap Continue) . foldHandler current) $
+              foldNext current
+          case next of
+            Right (Break ma) -> do
+              forM_ ma $ addPartialResult partialResults
+              return $ simpleEnum CXChildVisit_Break
+            Right (Continue ma) -> do
+              forM_ ma $ addPartialResult partialResults
+              return $ simpleEnum CXChildVisit_Continue
+            Right (Recurse fold summarize) -> do
+              stack' <- push current fold summarize stack
+              writeIORef someStack $ SomeStack stack'
+              return $ simpleEnum CXChildVisit_Recurse
+            Left ex -> do
+              recordException partialResults ex
+              return $ simpleEnum CXChildVisit_Continue
diff --git a/src/Clang/HighLevel/SourceLoc.hs b/src/Clang/HighLevel/SourceLoc.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/SourceLoc.hs
@@ -0,0 +1,446 @@
+-- | Utilities for working with source locations
+module Clang.HighLevel.SourceLoc (
+    -- * Definition
+    SingleLoc(..)
+  , MultiLoc(..)
+  , Range(..)
+    -- * Comparisons
+  , compareSingleLoc
+  , rangeContainsLoc
+    -- * Conversion
+  , toMulti
+  , toRange
+  , fromSingle
+  , fromRange
+    -- * Get single location
+  , clang_getExpansionLocation
+  , clang_getPresumedLocation
+  , clang_getSpellingLocation
+  , clang_getFileLocation
+    -- * Pretty-printing
+    --
+    -- We export these separately, because the 'Show' instance also adds quotes
+    -- (in order to produce valid Haskell syntax).
+  , ShowFile(..)
+  , prettySingleLoc
+  , prettyMultiLoc
+  , prettyRangeSingleLoc
+  , prettyRangeMultiLoc
+    -- * Convenience wrappers
+    -- * for @CXSourceLocation@
+  , clang_getDiagnosticLocation
+  , clang_getCursorLocation
+  , clang_getCursorLocation'
+  , clang_getTokenLocation
+    -- ** for @CXSourceRange@
+  , clang_getDiagnosticRange
+  , clang_getDiagnosticFixIt
+  , clang_Cursor_getSpellingNameRange
+  , clang_getCursorExtent
+  , clang_getTokenExtent
+  ) where
+
+import Control.Monad
+import Control.Monad.IO.Class
+import Data.List (intercalate)
+import Data.Text (Text)
+import Foreign.C
+import GHC.Generics (Generic)
+import GHC.Stack
+
+import Clang.LowLevel.Core qualified as Core
+import Clang.Paths
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | A /single/ location in a file
+--
+-- See 'MultiLoc' for additional discussion.
+data SingleLoc = SingleLoc {
+      singleLocPath   :: !SourcePath
+    , singleLocLine   :: !Int
+    , singleLocColumn :: !Int
+    , singleLocOffset :: !Int
+    }
+  deriving stock (Eq, Ord, Generic)
+
+-- | Presumed location
+--
+-- Presumed locations arise from @#line@ directives, and as such don't provide
+-- an offset.
+data PresumedLoc = PresumedLoc {
+      presumedLocPath   :: !SourcePath
+    , presumedLocLine   :: !Int
+    , presumedLocColumn :: !Int
+    }
+  deriving stock (Eq, Ord, Generic)
+
+
+-- | Multiple related source locations
+--
+-- 'Core.CXSourceLocation' in @libclang@ corresponds to @SourceLocation@ in
+-- @clang@, which can actually correspond to /multiple/ source locations in a
+-- file; for example, in a header file such as
+--
+-- > #define M1 int
+-- >
+-- > struct ExampleStruct {
+-- >   M1 m1;
+-- >   ^
+-- > };
+--
+-- then the source location at the caret (@^@) has an \"expansion location\",
+-- which is the position at the caret, and a \"spelling location\", which
+-- corresponds to the location of the @int@ token in the macro definition.
+--
+-- References:
+--
+-- * <https://clang.llvm.org/doxygen/classclang_1_1SourceLocation.html>
+-- * <https://clang.llvm.org/doxygen/classclang_1_1SourceManager.html>
+--   (@getExpansionLoc@, @getSpellingLoc@, @getDecomposedSpellingLoc@)
+data MultiLoc = MultiLoc {
+      -- | Expansion location
+      --
+      -- If the location refers into a macro expansion, this corresponds to the
+      -- location of the macro expansion.
+      --
+      -- See <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gadee4bea0fa34550663e869f48550eb1f>
+      multiLocExpansion :: !SingleLoc
+
+      -- | Presumed location
+      --
+      -- The given source location as specified in a @#line@ directive.
+      --
+      -- See <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#ga03508d9c944feeb3877515a1b08d36f9>
+    , multiLocPresumed :: !(Maybe PresumedLoc)
+
+      -- | Spelling location
+      --
+      -- If the location refers into a macro instantiation, this corresponds to
+      -- the /original/ location of the spelling in the source file.
+      --
+      -- /WARNING/: This field is only populated correctly from @llvm >= 19.1.0@;
+      -- prior to that this is equal to 'multiLocFile'.
+      -- See <https://github.com/llvm/llvm-project/pull/72400>.
+      --
+      -- See <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#ga01f1a342f7807ea742aedd2c61c46fa0>
+    , multiLocSpelling :: !(Maybe SingleLoc)
+
+      -- | File location
+      --
+      -- If the location refers into a macro expansion, this corresponds to the
+      -- location of the macro expansion.
+      -- If the location points at a macro argument, this corresponds to the
+      -- location of the use of the argument.
+      --
+      -- See <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gae0ee9ff0ea04f2446832fc12a7fd2ac8>
+    , multiLocFile :: !(Maybe SingleLoc)
+    }
+  deriving stock (Eq, Ord, Generic)
+
+-- | Range
+--
+-- 'Core.CXSourceRange' corresponds to @SourceRange@ in @clang@
+-- <https://clang.llvm.org/doxygen/classclang_1_1SourceLocation.html>,
+-- and therefore to @Range MultiLoc@; see 'MultiLoc' for additional discussion.
+data Range a = Range {
+      rangeStart :: !a
+    , rangeEnd   :: !a
+    }
+  deriving stock (Eq, Ord, Generic)
+  deriving stock (Functor, Foldable, Traversable)
+
+{-------------------------------------------------------------------------------
+  Comparisons
+-------------------------------------------------------------------------------}
+
+-- | Compare locations
+--
+-- Returns 'Nothing' if the locations aren't in the same file.
+compareSingleLoc :: SingleLoc -> SingleLoc -> Maybe Ordering
+compareSingleLoc a b = do
+    guard $ singleLocPath a == singleLocPath b
+    return $
+      compare
+        (singleLocLine a, singleLocColumn a)
+        (singleLocLine b, singleLocColumn b)
+
+-- | Check if a location falls within the given range
+--
+-- Treats the range as half-open, with an inclusive lower bound and exclusive
+-- upper bound (following 'Core.CXSourceRange').
+--
+-- Returns 'Nothing' if the three locations are not all in the same file.
+rangeContainsLoc :: Range SingleLoc -> SingleLoc -> Maybe Bool
+rangeContainsLoc Range{rangeStart, rangeEnd} loc = do
+    afterStart <- (/= LT) <$> compareSingleLoc loc rangeStart
+    beforeEnd  <- (== LT) <$> compareSingleLoc loc rangeEnd
+    return $ afterStart && beforeEnd
+
+{-------------------------------------------------------------------------------
+  Show instances
+
+  Technically speaking the validity of these instances depends on 'IsString'
+  instances which we do not (yet?) define.
+-------------------------------------------------------------------------------}
+
+instance Show SingleLoc         where show = show . prettySingleLoc ShowFile
+instance Show MultiLoc          where show = show . prettyMultiLoc  ShowFile
+instance Show (Range SingleLoc) where show = show . prettyRangeSingleLoc
+instance Show (Range MultiLoc)  where show = show . prettyRangeMultiLoc
+
+deriving stock instance {-# OVERLAPPABLE #-} Show a => Show (Range a)
+
+{-------------------------------------------------------------------------------
+  Pretty-printing
+
+  These instances mimic the behaviour of @SourceLocation::print@ and
+  @SourceRange::print@ in @clang@.
+-------------------------------------------------------------------------------}
+
+data ShowFile = ShowFile | HideFile
+
+prettySingleLoc :: ShowFile -> SingleLoc -> String
+prettySingleLoc showFile loc = case showFile of
+    -- Use space instead of first colon to avoid GHC literate preprocessor mangling
+    ShowFile -> getSourcePath singleLocPath ++ " "
+                  ++ show singleLocLine ++ ":" ++ show singleLocColumn
+    HideFile -> show singleLocLine ++ ":" ++ show singleLocColumn
+  where
+    SingleLoc{singleLocPath, singleLocLine, singleLocColumn} = loc
+
+prettyMultiLoc :: ShowFile -> MultiLoc -> String
+prettyMultiLoc showFile multiLoc =
+    intercalate " " . concat $ [
+        [ prettySingleLoc showFile multiLocExpansion ]
+      , [ "<Presumed=" ++ presumed loc ++ ">" | Just loc <- [multiLocPresumed] ]
+      , [ "<Spelling=" ++ single   loc ++ ">" | Just loc <- [multiLocSpelling] ]
+      , [ "<File="     ++ single   loc ++ ">" | Just loc <- [multiLocFile]     ]
+      ]
+  where
+    MultiLoc{
+        multiLocExpansion
+      , multiLocPresumed
+      , multiLocSpelling
+      , multiLocFile} = multiLoc
+
+    presumed :: PresumedLoc -> [Char]
+    presumed loc = single $ SingleLoc{
+          singleLocPath   = presumedLocPath   loc
+        , singleLocLine   = presumedLocLine   loc
+        , singleLocColumn = presumedLocColumn loc
+        , singleLocOffset = 0 -- not used for pretty-printing
+        }
+
+    single :: SingleLoc -> [Char]
+    single loc =
+        prettySingleLoc
+          (if singleLocPath loc == singleLocPath multiLocExpansion
+             then HideFile
+             else ShowFile)
+          loc
+
+prettyRangeSingleLoc :: Range SingleLoc -> String
+prettyRangeSingleLoc = prettySourceRangeWith
+      singleLocPath
+      prettySingleLoc
+
+prettyRangeMultiLoc :: Range MultiLoc -> String
+prettyRangeMultiLoc =
+    prettySourceRangeWith
+      (singleLocPath . multiLocExpansion)
+      prettyMultiLoc
+
+prettySourceRangeWith ::
+     (a -> SourcePath)
+  -> (ShowFile -> a -> String)
+  -> Range a -> String
+prettySourceRangeWith path pretty Range{rangeStart, rangeEnd} = concat [
+      "<"
+    , pretty ShowFile rangeStart
+    , "-"
+    , pretty
+        (if path rangeStart == path rangeEnd then HideFile else ShowFile)
+        rangeEnd
+    , ">"
+    ]
+
+{-------------------------------------------------------------------------------
+  Conversion
+-------------------------------------------------------------------------------}
+
+toMulti :: MonadIO m => Core.CXSourceLocation -> m MultiLoc
+toMulti location = do
+    expansion <- clang_getExpansionLocation location
+
+    let differentSingle :: SingleLoc -> Maybe SingleLoc
+        differentSingle loc = do
+            guard $ singleLocPath   loc /= singleLocPath expansion
+            guard $ singleLocLine   loc /= singleLocLine expansion
+            guard $ singleLocColumn loc /= singleLocColumn expansion
+            -- We don't compare the file offset
+            return loc
+
+        differentPresumed :: PresumedLoc -> Maybe PresumedLoc
+        differentPresumed loc = do
+            guard $ presumedLocPath   loc /= singleLocPath expansion
+            guard $ presumedLocLine   loc /= singleLocLine expansion
+            guard $ presumedLocColumn loc /= singleLocColumn expansion
+            return loc
+
+    MultiLoc expansion
+      <$> (differentPresumed <$> clang_getPresumedLocation location)
+      <*> (differentSingle   <$> clang_getSpellingLocation location)
+      <*> (differentSingle   <$> clang_getFileLocation     location)
+
+
+toRange :: MonadIO m => Core.CXSourceRange -> m (Range MultiLoc)
+toRange = toRangeWith toMulti
+
+fromSingle ::
+     (MonadIO m, HasCallStack)
+  => Core.CXTranslationUnit -> SingleLoc -> m Core.CXSourceLocation
+fromSingle unit SingleLoc{singleLocPath, singleLocLine, singleLocColumn} = do
+     let SourcePath path = singleLocPath
+     file <- Core.clang_getFile unit path
+     Core.clang_getLocation
+       unit
+       file
+       (fromIntegral singleLocLine)
+       (fromIntegral singleLocColumn)
+
+fromRange ::
+     (MonadIO m, HasCallStack)
+  => Core.CXTranslationUnit -> Range SingleLoc -> m Core.CXSourceRange
+fromRange unit Range{rangeStart, rangeEnd} = do
+    rangeStart' <- fromSingle unit rangeStart
+    rangeEnd'   <- fromSingle unit rangeEnd
+    Core.clang_getRange rangeStart' rangeEnd'
+
+{-------------------------------------------------------------------------------
+  Get single location
+-------------------------------------------------------------------------------}
+
+clang_getExpansionLocation :: MonadIO m => Core.CXSourceLocation -> m SingleLoc
+clang_getExpansionLocation location =
+    toSingle =<< Core.clang_getExpansionLocation location
+
+clang_getPresumedLocation :: MonadIO m => Core.CXSourceLocation -> m PresumedLoc
+clang_getPresumedLocation location =
+    toPresumed <$> Core.clang_getPresumedLocation location
+
+clang_getSpellingLocation :: MonadIO m => Core.CXSourceLocation -> m SingleLoc
+clang_getSpellingLocation location =
+    toSingle =<< Core.clang_getSpellingLocation location
+
+clang_getFileLocation :: MonadIO m => Core.CXSourceLocation -> m SingleLoc
+clang_getFileLocation location =
+    toSingle =<< Core.clang_getFileLocation location
+
+{-------------------------------------------------------------------------------
+  Convenience wrappers for @CXSourceLocation@
+-------------------------------------------------------------------------------}
+
+-- | Retrieve the source location of the given diagnostic.
+clang_getDiagnosticLocation :: MonadIO m => Core.CXDiagnostic -> m MultiLoc
+clang_getDiagnosticLocation diagnostic =
+    toMulti =<< Core.clang_getDiagnosticLocation diagnostic
+
+-- | Retrieve the physical location of the source constructor referenced by the
+-- given cursor.
+clang_getCursorLocation :: MonadIO m => Core.CXCursor -> m MultiLoc
+clang_getCursorLocation cursor =
+    toMulti =<< Core.clang_getCursorLocation cursor
+
+-- | Like 'clang_getCursorLocation', but only retrieve the expansion location
+clang_getCursorLocation' :: MonadIO m => Core.CXCursor -> m SingleLoc
+clang_getCursorLocation' cursor =
+    clang_getExpansionLocation =<< Core.clang_getCursorLocation cursor
+
+-- | Retrieve the source location of the given token.
+clang_getTokenLocation ::
+     MonadIO m
+  => Core.CXTranslationUnit -> Core.CXToken -> m MultiLoc
+clang_getTokenLocation unit token =
+    toMulti =<< Core.clang_getTokenLocation unit token
+
+{-------------------------------------------------------------------------------
+  Convenience wrappers for @CXSourceRange@
+-------------------------------------------------------------------------------}
+
+-- | Retrieve a source range associated with the diagnostic.
+clang_getDiagnosticRange ::
+     MonadIO m
+  => Core.CXDiagnostic -> CUInt -> m (Range MultiLoc)
+clang_getDiagnosticRange diagnostic range =
+    toRange =<< Core.clang_getDiagnosticRange diagnostic range
+
+-- | Retrieve the replacement information for a given fix-it.
+clang_getDiagnosticFixIt ::
+     MonadIO m
+  => Core.CXDiagnostic
+  -> CUInt
+  -> m (Range MultiLoc, Text)
+clang_getDiagnosticFixIt diagnostic fixit = do
+    (range, replacement) <- Core.clang_getDiagnosticFixIt diagnostic fixit
+    (, replacement) <$> toRange range
+
+-- | Retrieve a range for a piece that forms the cursors spelling name.
+clang_Cursor_getSpellingNameRange ::
+     MonadIO m
+  => Core.CXCursor
+  -> CUInt
+  -> CUInt
+  -> m (Maybe (Range MultiLoc))
+clang_Cursor_getSpellingNameRange cursor pieceIndex options = do
+    mRange <- Core.clang_Cursor_getSpellingNameRange cursor pieceIndex options
+    case mRange of
+      Nothing    -> return Nothing
+      Just range -> Just <$> toRangeWith toMulti range
+
+-- | Retrieve the physical extent of the source construct referenced by the
+-- given cursor.
+clang_getCursorExtent :: MonadIO m => Core.CXCursor -> m (Range MultiLoc)
+clang_getCursorExtent cursor =
+    toRange =<< Core.clang_getCursorExtent cursor
+
+-- | Retrieve a source range that covers the given token.
+clang_getTokenExtent ::
+     MonadIO m
+  => Core.CXTranslationUnit
+  -> Core.CXToken
+  -> m (Range MultiLoc)
+clang_getTokenExtent unit token =
+    toRange =<< Core.clang_getTokenExtent unit token
+
+{-------------------------------------------------------------------------------
+  Auxiliary
+-------------------------------------------------------------------------------}
+
+toSingle :: MonadIO m => (Core.CXFile, CUInt, CUInt, CUInt) -> m SingleLoc
+toSingle (file, line, column, offset) = do
+    path <- Core.clang_getFileName file
+    return SingleLoc{
+        singleLocPath   = SourcePath   path
+      , singleLocLine   = fromIntegral line
+      , singleLocColumn = fromIntegral column
+      , singleLocOffset = fromIntegral offset
+      }
+
+toPresumed :: (Text, CUInt, CUInt) -> PresumedLoc
+toPresumed (path, line, column) = PresumedLoc{
+      presumedLocPath   = SourcePath   path
+    , presumedLocLine   = fromIntegral line
+    , presumedLocColumn = fromIntegral column
+    }
+
+toRangeWith ::
+     MonadIO m
+  => (Core.CXSourceLocation -> m a)
+  -> Core.CXSourceRange -> m (Range a)
+toRangeWith f range =
+    Range
+      <$> (f =<< Core.clang_getRangeStart range)
+      <*> (f =<< Core.clang_getRangeEnd   range)
diff --git a/src/Clang/HighLevel/Tokens.hs b/src/Clang/HighLevel/Tokens.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Tokens.hs
@@ -0,0 +1,74 @@
+module Clang.HighLevel.Tokens (
+    Token(..)
+  , TokenSpelling(..)
+  , clang_tokenize
+  ) where
+
+import Control.Exception
+import Control.Monad
+import Control.Monad.IO.Class
+import Data.Text (Text)
+import GHC.Generics (Generic)
+import GHC.Stack
+
+import Clang.Enum.Simple
+import Clang.HighLevel.SourceLoc (MultiLoc, Range, SingleLoc)
+import Clang.HighLevel.SourceLoc qualified as SourceLoc
+import Clang.LowLevel.Core hiding (clang_tokenize)
+import Clang.LowLevel.Core qualified as Core
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+data Token a = Token {
+      tokenKind       :: !(SimpleEnum CXTokenKind)
+    , tokenSpelling   :: !a
+    , tokenExtent     :: !(Range MultiLoc)
+    , tokenCursorKind :: !(SimpleEnum CXCursorKind)
+    }
+  deriving stock (Show, Eq, Ord, Functor, Foldable, Traversable, Generic)
+
+newtype TokenSpelling = TokenSpelling {
+      getTokenSpelling :: Text
+    }
+  deriving stock (Show, Eq, Ord, Generic)
+
+{-------------------------------------------------------------------------------
+  Extraction
+-------------------------------------------------------------------------------}
+
+-- | Get all tokens in the specified range
+clang_tokenize ::
+     (MonadIO m, HasCallStack)
+  => CXTranslationUnit
+  -> Range SingleLoc
+     -- ^ Range
+     --
+     -- We use 'Range' 'SingleLoc' here instead of 'CXSourceRange' in order to
+     -- avoid ambiguity; see 'Clang.HighLevel.SourceLoc.MultiLoc' for discussion.
+  -> m [Token TokenSpelling]
+clang_tokenize unit range = liftIO $ do
+    range' <- SourceLoc.fromRange unit range
+    bracket
+        (Core.clang_tokenize unit range')
+        (uncurry $ Core.clang_disposeTokens unit) $ \(tokens, numTokens) -> do
+      cursors <- clang_annotateTokens unit tokens numTokens
+      forM [0 .. pred numTokens] $ \i -> do
+        cursor <- index_CXCursorArray cursors i
+        toToken unit (index_CXTokenArray tokens i) cursor
+
+toToken ::
+     MonadIO m
+  => CXTranslationUnit -> CXToken -> CXCursor -> m (Token TokenSpelling)
+toToken unit token cursor = do
+    tokenKind       <- clang_getTokenKind token
+    tokenSpelling   <- TokenSpelling <$> clang_getTokenSpelling unit token
+    tokenExtent     <- SourceLoc.clang_getTokenExtent unit token
+    tokenCursorKind <- clang_getCursorKind cursor
+    return Token{
+        tokenKind
+      , tokenSpelling
+      , tokenExtent
+      , tokenCursorKind
+      }
diff --git a/src/Clang/HighLevel/Types.hs b/src/Clang/HighLevel/Types.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Types.hs
@@ -0,0 +1,57 @@
+-- | Types used by the high-level API
+--
+-- Intended for unqualified import; see "Clang.HighLevel" for more detailed
+-- discussion.
+module Clang.HighLevel.Types (
+    -- * Source locations
+    SingleLoc(..)
+  , MultiLoc(..)
+  , Range(..)
+    -- ** Comparisons
+  , compareSingleLoc
+  , rangeContainsLoc
+    -- ** Conversion
+  , toMulti
+  , toRange
+  , fromSingle
+  , fromRange
+    -- * Tokens
+  , Token(..)
+  , TokenSpelling(..)
+    -- * Diagnostics
+  , Diagnostic(..)
+  , FixIt(..)
+  , diagnosticIsError
+    -- * Folds
+  , Fold
+  , HandlerResult(..)
+  , Next
+    -- ** Construction
+  , simpleFold
+  , foldWithHandler
+  , FoldException (..)
+  , foldTry
+    -- ** Fold-specific functionality
+  , foldBreak
+  , foldBreakWith
+  , foldBreakOpt
+  , foldContinue
+  , foldContinueWith
+  , foldContinueOpt
+  , foldRecurse
+  , foldRecurseWith
+  , foldRecurseOpt
+  , foldRecursePure
+  , foldRecursePureOpt
+    -- * Declaration classification
+  , DeclarationClassification(..)
+    -- * Evaluation
+  , EvalResult(..)
+  ) where
+
+import Clang.HighLevel.Declaration
+import Clang.HighLevel.Diagnostics
+import Clang.HighLevel.Evaluate
+import Clang.HighLevel.Fold
+import Clang.HighLevel.SourceLoc
+import Clang.HighLevel.Tokens
diff --git a/src/Clang/HighLevel/Wrappers.hs b/src/Clang/HighLevel/Wrappers.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/HighLevel/Wrappers.hs
@@ -0,0 +1,79 @@
+{-# LANGUAGE RecordWildCards #-}
+
+module Clang.HighLevel.Wrappers (
+    withIndex
+  , withTranslationUnit
+  , withTranslationUnit2
+  , withUnsavedFile
+  ) where
+
+import Control.Monad.Catch
+import Control.Monad.IO.Class
+import Foreign.C.String (withCString, withCStringLen)
+import GHC.Stack (HasCallStack)
+
+import Clang.Args
+import Clang.Enum.Bitfield
+import Clang.Enum.Simple
+import Clang.LowLevel.Core
+import Clang.Paths
+
+-- | Brackets 'clang_createIndex' with 'clang_disposeIndex'
+withIndex ::
+     (MonadIO m, MonadMask m)
+  => DisplayDiagnostics
+  -> (CXIndex -> m a)
+  -> m a
+withIndex diagnostics =
+    bracket (clang_createIndex diagnostics) clang_disposeIndex
+
+-- | Brackets 'clang_parseTranslationUnit' with 'clang_disposeTranslationUnit'
+withTranslationUnit ::
+     (MonadIO m, MonadMask m, HasCallStack)
+  => CXIndex
+  -> Maybe SourcePath
+  -> ClangArgs
+  -> [CXUnsavedFile]
+  -> BitfieldEnum CXTranslationUnit_Flags
+  -> (CXTranslationUnit -> m a)
+  -> m a
+withTranslationUnit index src args unsavedFiles options =
+    bracket
+      (clang_parseTranslationUnit index src args unsavedFiles options)
+      clang_disposeTranslationUnit
+
+-- | Brackets 'clang_parseTranslationUnit2' with 'clang_disposeTranslationUnit'
+withTranslationUnit2 ::
+     (MonadIO m, MonadMask m)
+  => CXIndex
+  -> Maybe SourcePath
+  -> ClangArgs
+  -> [CXUnsavedFile]
+  -> BitfieldEnum CXTranslationUnit_Flags
+  -> (SimpleEnum CXErrorCode -> m a) -- ^ Handle errors
+  -> (CXTranslationUnit      -> m a)
+  -> m a
+withTranslationUnit2 index src args unsavedFiles options onFailure onSuccess =
+    bracket
+      (clang_parseTranslationUnit2 index src args unsavedFiles options)
+      ( \case
+          Right unit -> clang_disposeTranslationUnit unit
+          Left _err  -> return ()
+      )
+      ( \case
+          Right unit -> onSuccess unit
+          Left  err  -> onFailure err
+      )
+
+-- | Constructs a 'CXUnsavedFile', allocating memory for the passed strings
+--
+-- 'cxUnsavedFileLength' is computed from the length of the contents.
+withUnsavedFile ::
+     String -- ^ Filename
+  -> String -- ^ Contents
+  -> (CXUnsavedFile -> IO a) -> IO a
+withUnsavedFile filename contents f =
+    withCString filename $ \cxUnsavedFileFilename ->
+      withCStringLen contents $ \(cxUnsavedFileContents, len) ->
+        let cxUnsavedFileLength = fromIntegral len
+        in  f CXUnsavedFile{..}
diff --git a/src/Clang/Internal/ByValue.hs b/src/Clang/Internal/ByValue.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/ByValue.hs
@@ -0,0 +1,257 @@
+{-# LANGUAGE AllowAmbiguousTypes #-}
+
+-- | Dealing with structs-by-value
+module Clang.Internal.ByValue (
+    OnHaskellHeap(..)
+    -- * Construction
+  , HasKnownSize(..)
+  , copyToHaskellHeap
+    -- * Access
+  , R(..)
+  , LivesOnHaskellHeap -- opaque
+  , onHaskellHeap
+    -- * Preallocation
+  , W(..)
+  , Preallocate(..)
+  , preallocate_
+  , preallocatePair
+  , preallocatePair_
+    -- * Arrays of values
+  , ArrOnHaskellHeap(..)
+  , preallocateArray
+  , indexArrOnHaskellHeap
+  ) where
+
+import Data.Array.Byte (ByteArray (..))
+import Foreign
+import GHC.Exts
+import GHC.IO
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+data OnHaskellHeap tag = OnHaskellHeap ByteArray#
+
+instance Eq (OnHaskellHeap tag) where
+  OnHaskellHeap a == OnHaskellHeap b = ByteArray a == ByteArray b
+
+instance Ord (OnHaskellHeap tag) where
+  compare (OnHaskellHeap a) (OnHaskellHeap b) = compare (ByteArray a) (ByteArray b)
+
+instance Show (OnHaskellHeap tag) where
+  showsPrec d (OnHaskellHeap a) = showsPrec d (ByteArray a)
+
+{-------------------------------------------------------------------------------
+  Construction
+-------------------------------------------------------------------------------}
+
+-- | Structs with known size
+--
+-- Intended for use with a type argument:
+--
+-- > knownSize @CXToken_
+class HasKnownSize tag where
+  knownSize :: Int
+
+copyToHaskellHeap :: forall tag.
+     HasKnownSize tag
+  => Ptr tag -> IO (OnHaskellHeap tag)
+copyToHaskellHeap src = fmap fst $
+    mkByteArray (knownSize @tag) OnHaskellHeap $ \arr -> do
+      let dest :: Ptr tag
+          dest = Ptr (mutableByteArrayContents# arr)
+      copyBytes dest src (knownSize @tag)
+
+{-------------------------------------------------------------------------------
+  Access
+-------------------------------------------------------------------------------}
+
+-- | A read-only byte array
+--
+-- This type is used to hold the bytes of a C struct that is passed by value as
+-- an argument to a C function through the Haskell FFI.
+--
+-- === Example
+--
+-- Let's say we want to generate Haskell bindings for this C code:
+--
+-- > struct S { int x; };
+-- > void foo (struct S x);
+--
+-- The Haskell FFI does not support passing structs by value, so we generate a C
+-- wrapper function that instead takes the struct argument by a pointer,
+-- dereferences the pointer, and passes the struct by-value on to the original
+-- @foo@.
+--
+-- > void foo_wrapper (struct S * x) { foo(*x); };
+--
+-- For the struct, we create a Haskell datatype. We add a foreign import that
+-- binds to the C wrapper function, using 'R'.
+--
+-- > data S {-# CType "struct S" #-} = S { x :: CInt }
+-- > foreign import capi unsafe "foo_wrapper" foo :: R S -> IO ()
+--
+-- We can use 'R' here even though the wrapper function takes a struct pointer,
+-- not a struct value. Any value of type 'R' is passed through the Haskell FFI
+-- as a pointer to the array payload because 'R' is an unlifted FFI type.
+--
+-- <https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html#unlifted-ffi-types>
+type R :: k -> UnliftedType
+newtype R tag = R ByteArray#
+
+-- | Heap-allocated structs
+--
+-- The definition of this class is not exported; instances are expected to be
+-- derived using newtype deriving.
+class LivesOnHaskellHeap a where
+  type Reading a :: UnliftedType
+
+  -- | Get a pointer to a heap-allocated struct
+  --
+  -- This essentially just unwraps the lifted 'OnHaskellHeap' type, but then
+  -- rewrapping it as the unlifted 'R' newtype, to avoid losing type info.
+  onHaskellHeap :: a -> (Reading a -> IO r) -> IO r
+
+instance LivesOnHaskellHeap (OnHaskellHeap tag) where
+  type Reading (OnHaskellHeap tag) = R tag
+  onHaskellHeap (OnHaskellHeap arr) f = f (R arr)
+
+{-------------------------------------------------------------------------------
+  Preallocation
+-------------------------------------------------------------------------------}
+
+-- | A read-write byte array
+--
+-- This type is used to hold the bytes of a C struct that is passed by value as
+-- a result from a C function through the Haskell FFI.
+--
+-- === Example
+--
+-- Let's say we want to generate Haskell bindings for this C code:
+--
+-- > struct S { int x; };
+-- > struct S foo ();
+--
+-- The Haskell FFI does not support passing structs by value, so we generate a C
+-- wrapper function that instead takes an extra struct argument pointer that is
+-- used to hold the struct result value from calling the original @foo@.
+--
+-- > void foo_wrapper (struct S * result) { *result = foo(); };
+--
+-- For the struct, we create a Haskell datatype. We add a foreign import that
+-- binds to the C wrapper function, using 'W'.
+--
+-- > data S {-# CType "struct S" #-} = S { x :: CInt }
+-- > foreign import capi unsafe "foo_wrapper" foo :: W S -> IO ()
+--
+-- We can use 'W' here even though the wrapper function takes a struct pointer,
+-- not a struct value. Any value of type 'W' is passed through the Haskell FFI
+-- as a pointer to the array payload because 'W' is an unlifted FFI type.
+-- Moreover, 'W' can be mutated by the C wrapper function, and the mutation will
+-- be visible in Haskell-land as well.
+--
+-- <https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/ffi.html#unlifted-ffi-types>
+type W :: k -> UnliftedType
+newtype W tag = W (MutableByteArray# RealWorld)
+
+-- | Preallocate a buffer
+--
+-- NOTE: Although we only define one instance of 'Preallocate' here, the
+-- intention is that other instances are defined through newtype deriving, e.g.
+--
+-- > newtype CXType = CXType (OnHaskellHeap CXType_)
+-- >   deriving newtype (LivesOnHaskellHeap, Preallocate, Show)
+--
+-- "Clang.Internal.CXString" also provides another instance.
+class Preallocate a where
+  type Writing a :: UnliftedType
+
+  -- | Preallocate a buffer
+  --
+  -- See 'onHaskellHeap' for rationale.
+  preallocate :: (Writing a -> IO r) -> IO (a, r)
+
+preallocate_ :: Preallocate a => (Writing a -> IO ()) -> IO a
+preallocate_ = fmap fst . preallocate
+
+instance HasKnownSize tag => Preallocate (OnHaskellHeap tag) where
+  type Writing (OnHaskellHeap tag) = W tag
+
+  preallocate :: (W tag -> IO r) -> IO (OnHaskellHeap tag, r)
+  preallocate f =
+      mkByteArray (knownSize @tag) OnHaskellHeap $ \arr ->
+        f (W arr)
+
+-- | Preallocate two values
+--
+-- TODO <https://github.com/well-typed/libclang-bindings/issues/74>
+--
+-- It would be nice to generalize this, but I can't quite figure out how without
+-- introducing a ton of machinery.
+preallocatePair :: forall a b r.
+     (Preallocate a, Preallocate b)
+  => (Writing a -> Writing b -> IO r)
+  -> IO ((a, b), r)
+preallocatePair k = fmap reassoc $
+    preallocate $ \wa ->
+    preallocate $ \wb ->
+      k wa wb
+  where
+    reassoc :: (a, (b, r)) -> ((a, b), r)
+    reassoc (a, (b, r)) = ((a, b), r)
+
+preallocatePair_ ::
+     (Preallocate a, Preallocate b)
+  => (Writing a -> Writing b -> IO ())
+  -> IO (a, b)
+preallocatePair_ = fmap fst . preallocatePair
+
+{-------------------------------------------------------------------------------
+  Arrays of values
+-------------------------------------------------------------------------------}
+
+data ArrOnHaskellHeap tag = ArrOnHaskellHeap ByteArray#
+
+preallocateArray :: forall tag.
+     HasKnownSize tag
+  => Int
+  -> (W tag -> IO ())
+  -> IO (ArrOnHaskellHeap tag)
+preallocateArray n k = fmap (\(a, ()) -> a) $
+    mkByteArray (n * knownSize @tag) ArrOnHaskellHeap $ \arr ->
+      k (W arr)
+
+indexArrOnHaskellHeap :: forall tag.
+     HasKnownSize tag
+  => ArrOnHaskellHeap tag
+  -> Int
+  -> IO (OnHaskellHeap tag)
+indexArrOnHaskellHeap (ArrOnHaskellHeap src) i = fmap (\(a, ()) -> a) $
+    mkByteArray (knownSize @tag) OnHaskellHeap $ \dst ->
+      copyByteArray src (i * knownSize @tag) dst 0 (knownSize @tag)
+
+{-------------------------------------------------------------------------------
+  Internal auxiliary
+-------------------------------------------------------------------------------}
+
+mkByteArray ::
+     Int
+  -> (ByteArray# -> a)
+  -> (MutableByteArray# RealWorld -> IO b)
+  -> IO (a, b)
+mkByteArray (I# sz) wrap fill = IO $ \w0 ->
+    let !(# w1, arr  #) = newPinnedByteArray# sz     w0
+        !(# w2, b    #) = unIO (fill arr)            w1
+        !(# w3, arr' #) = unsafeFreezeByteArray# arr w2
+    in (# w3, (wrap arr', b) #)
+
+copyByteArray ::
+     ByteArray#                   -- ^ source
+  -> Int                          -- ^ source offset
+  -> MutableByteArray# RealWorld  -- ^ destination
+  -> Int                          -- ^ destination offset
+  -> Int                          -- ^ length
+  -> IO ()
+copyByteArray src (I# src_ofs) dst (I# dst_ofs) (I# len) = IO $ \w ->
+    (# copyByteArray# src src_ofs dst dst_ofs len w, () #)
diff --git a/src/Clang/Internal/CXString.hs b/src/Clang/Internal/CXString.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/CXString.hs
@@ -0,0 +1,75 @@
+{-# OPTIONS_GHC -Wno-orphans #-}
+
+-- | Dealing with @CXString@
+--
+-- This has no exports: the Haskell representation of @CXString@ is 'Text'.
+module Clang.Internal.CXString () where
+
+import Control.Exception
+import Data.Text (Text)
+import Data.Text qualified as Text
+import Foreign
+import Foreign.C
+import GHC.Ptr (Ptr (..))
+
+import Clang.Internal.ByValue
+import Clang.Internal.ConstPtr (ConstPtr (unConstPtr))
+import Clang.LowLevel.Core.Instances ()
+import Clang.LowLevel.Core.Structs
+import Clang.LowLevel.FFI
+
+{-------------------------------------------------------------------------------
+  Translation to bytestrings
+
+  TODO <https://github.com/well-typed/libclang-bindings/issues/70>
+
+  We could consider trying to deduplicate.
+-------------------------------------------------------------------------------}
+
+-- | @libclang@ uses UTF-8 internally
+instance Preallocate Text where
+  type Writing Text = W CXString_
+
+  preallocate :: (W CXString_ -> IO b) -> IO (Text, b)
+  preallocate allocStr =
+      bracket
+          (preallocate allocStr)
+          (clang_disposeString . fst) $ \(str, b) -> do
+        cstr@(Ptr addr) <- clang_getCString str
+        if cstr == nullPtr then
+          return (Text.empty, b)
+        else do
+          let !t = Text.unpackCString# addr
+          return (t, b)
+
+{-------------------------------------------------------------------------------
+  Low-level bindings
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__STRING.html>
+-------------------------------------------------------------------------------}
+
+-- | A character string.
+--
+-- The 'CXString' type is used to return strings from the interface when the
+-- ownership of that string might differ from one call to the next. Use
+-- 'clang_getCString' to retrieve the string data and, once finished with the
+-- string data, call 'clang_disposeString' to free the string.
+--
+-- <https://clang.llvm.org/doxygen/structCXString.html>
+newtype CXString = CXString (OnHaskellHeap CXString_)
+  deriving newtype (LivesOnHaskellHeap, Preallocate)
+
+-- | Retrieve the character data associated with the given string.
+--
+-- We use @capi@ together with 'ConstPtr' here to avoid a compiler warning
+-- about qualifying the @const@-ness of @const char *@ (see "Clang.Internal.ConstPtr").
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__STRING.html#gabe1284209a3cd35c92e61a31e9459fe7>
+clang_getCString :: CXString -> IO CString
+clang_getCString str = unConstPtr <$> onHaskellHeap str wrap_getCString
+
+-- | Free the given string.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__STRING.html#gaeff715b329ded18188959fab3066048f>
+clang_disposeString :: CXString -> IO ()
+clang_disposeString str = onHaskellHeap str $ wrap_disposeString
diff --git a/src/Clang/Internal/ConstPtr.hs b/src/Clang/Internal/ConstPtr.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/ConstPtr.hs
@@ -0,0 +1,60 @@
+{-# LANGUAGE RoleAnnotations #-}
+{-# LANGUAGE StandaloneKindSignatures #-}
+{-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE CPP #-}
+
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  GHC.Internal.Foreign.C.ConstPtr
+-- Copyright   :  (c) GHC Developers
+-- License     :  BSD-style (see the file libraries/base/LICENSE)
+--
+-- Maintainer  :  ffi@haskell.org
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- This module provides typed @const@ pointers to foreign data. It is part
+-- of the Foreign Function Interface (FFI).
+--
+-- NOTE: this is a copy of the "Foreign.C.ConstPtr" module from the @base@
+-- package, added here because versions of @base@ before @4.18@ do not provide a
+-- 'ConstPtr' type. When the @base@ version is @4.18@ or higher, the
+-- "Foreign.C.ConstPtr" is re-exported instead. Licenses and copyrights for the
+-- "Foreign.C.ConstPtr" module apply to the current module.
+--
+-----------------------------------------------------------------------------
+
+module Clang.Internal.ConstPtr (
+    ConstPtr(..)
+) where
+
+#if MIN_VERSION_base(4,18,0)
+
+import Foreign.C.ConstPtr (ConstPtr (..))
+
+#else
+
+import Data.Kind (Type)
+import Foreign.Ptr (Ptr)
+import Foreign.Storable (Storable)
+
+-- | A pointer with the C @const@ qualifier. For instance, an argument of type
+-- @ConstPtr CInt@ would be marshalled as @const int*@.
+--
+-- While @const@-ness generally does not matter for @ccall@ imports (since
+-- @const@ and non-@const@ pointers typically have equivalent calling
+-- conventions), it does matter for @capi@ imports. See GHC #22043.
+--
+-- @since base-4.18.0.0
+--
+type ConstPtr :: Type -> Type
+type role ConstPtr phantom
+newtype ConstPtr a = ConstPtr { unConstPtr :: Ptr a }
+    deriving stock (Eq, Ord)
+    deriving newtype Storable
+
+-- doesn't use record syntax
+instance Show (ConstPtr a) where
+    showsPrec d (ConstPtr p) = showParen (d > 10) $ showString "ConstPtr " . showsPrec 11 p
+
+#endif
diff --git a/src/Clang/Internal/Exception.hs b/src/Clang/Internal/Exception.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/Exception.hs
@@ -0,0 +1,89 @@
+{-# LANGUAGE CPP #-}
+module Clang.Internal.Exception (
+    ExactException(..)
+  , throwExact
+  , RunInIO
+  , HandlerResult(..)
+  , handleUnliftUsing
+  ) where
+
+import Control.Exception (Exception (..))
+import Control.Exception qualified as Base
+import Control.Monad.IO.Class (MonadIO (..))
+
+{-------------------------------------------------------------------------------
+  Internal: exception handling
+-------------------------------------------------------------------------------}
+
+-- | Newtype wrapper for throwing this /exact/ exception
+--
+-- In other words, including any exception annotations.
+newtype ExactException = WrapExactException {
+      unwrapExactException :: Base.SomeException
+    }
+  deriving stock (Show)
+
+instance Exception ExactException where
+  fromException    = Just . WrapExactException
+  toException      = unwrapExactException
+  displayException = displayException . unwrapExactException
+#if MIN_VERSION_base(4,20,0)
+  backtraceDesired = const False
+#endif
+
+-- | Type-specialized wrapper around throwIO, to avoid mistakes
+--
+-- Implementation note: does not need a 'HasCallStack' constraint, because
+-- no new backtrace is added.
+throwExact :: ExactException -> IO a
+throwExact = Base.throwIO
+
+type RunInIO m = forall a. m a -> IO a
+
+-- | Exception handler result
+--
+-- This generalizes two functions:
+--
+-- * 'handle' through 'HandlerResult'
+-- * 'onException' through 'HandlerRethrow'
+--
+-- See 'handleUnliftUsing'.
+data HandlerResult a =
+    -- | Handler dealt with the exception and computed a new result
+    HandlerResult a
+
+    -- | Handler dealt with the exception, perhaps freeing some resources,
+    -- and wants to rethrow the original exception.
+    --
+    -- This mimicks the behaviour of 'onException'.
+  | HandlerRethrow
+  deriving stock (Show, Functor)
+
+-- | Generalized 'handle'
+--
+-- If the exception handler throws an exception of its own, instead of returning
+-- a result, a 'WhileHandling' annotation is added to that exception recording
+-- the original exception that was being handled (in GHC >= 9.12).
+--
+-- Implementation note: We do not use @handle@ from @unlift@, as it excludes
+-- async exceptions, and we want it to be up to the exception handler to decide
+-- if it wants to deal with async exceptions or not.
+handleUnliftUsing ::
+     MonadIO n
+  => RunInIO m
+  -> (ExactException -> m (HandlerResult a))
+  -> m a -> n a
+handleUnliftUsing runInIO handler action = liftIO $
+        Base.handle
+          (\e -> Left . (e,) <$> runInIO (handler e))
+          (Right <$> runInIO action)
+    >>= aux
+  where
+    aux :: Either (ExactException, HandlerResult a) a -> IO a
+    aux = \case
+        Right a -> return a
+        Left (e, handlerResult) ->
+          case handlerResult of
+            HandlerResult a -> return a
+            HandlerRethrow  -> throwExact e
+
diff --git a/src/Clang/Internal/FFI.hs b/src/Clang/Internal/FFI.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/FFI.hs
@@ -0,0 +1,39 @@
+-- | Internal utilities for working with the C FFI
+module Clang.Internal.FFI (
+    withArrayOrNull
+  , withCStrings
+  , withOptCString
+  ) where
+
+import Foreign
+import Foreign.C
+
+-- | Alternative to 'withArrayLen' that returns a null pointer when the passed
+-- array is empty
+withArrayOrNull :: Storable a => [a] -> (Ptr a -> Int -> IO r) -> IO r
+withArrayOrNull xs k
+    | null xs   = k nullPtr 0
+    | otherwise =
+        let arrayLength = length xs
+        in  allocaArray arrayLength $ \ptr -> do
+              pokeArray ptr xs
+              k ptr arrayLength
+
+-- | Extension of 'withCString' for multiple CStrings
+withCStrings :: [String] -> (Ptr CString -> CInt -> IO r) -> IO r
+withCStrings = \args k ->
+    allocaArray (length args) $ \arr ->
+      go args $ \args' -> do
+        pokeArray arr args'
+        k arr (fromIntegral $ length args)
+  where
+    go :: [String] -> ([CString] -> IO r) -> IO r
+    go []     k = k []
+    go (x:xs) k = withCString x  $ \x'  ->
+                  go          xs $ \xs' ->
+                  k (x' : xs')
+
+-- | Variation on 'withCString' which uses @NULL@ for 'Nothing'
+withOptCString :: Maybe String -> (CString -> IO a) -> IO a
+withOptCString (Just str) = withCString str
+withOptCString Nothing    = ($ nullPtr)
diff --git a/src/Clang/Internal/Ptr.hs b/src/Clang/Internal/Ptr.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/Ptr.hs
@@ -0,0 +1,15 @@
+-- | Pointer utilities
+module Clang.Internal.Ptr (
+    safeCastPtr
+  ) where
+
+import Data.Coerce (Coercible, coerce)
+import Foreign.Ptr (Ptr, castPtr)
+
+-- | Safely casts a 'Ptr' to a 'Ptr' of a different type.
+safeCastPtr ::
+  forall a b. Coercible a b => Ptr a -> Ptr b
+safeCastPtr = castPtr
+  where
+    _unused :: a -> b
+    _unused = coerce
diff --git a/src/Clang/Internal/Results.hs b/src/Clang/Internal/Results.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Internal/Results.hs
@@ -0,0 +1,120 @@
+{-# LANGUAGE AllowAmbiguousTypes #-}
+
+-- | Utilities for checking the results of C functions
+module Clang.Internal.Results (
+    -- * Failed calls
+    CallFailed(..)
+  , callFailed
+  , callFailedShow
+    -- * Specific conditions
+  , cToBool
+  , ensure
+  , ensureOn
+  , ensureNotNull
+  , checkNotNull
+  , ensureNotInRange
+    -- * Auxiliary
+  , IsNullPtr(..)
+  ) where
+
+import Control.Exception
+import Control.Monad.IO.Class
+import Data.Coerce
+import Foreign
+import GHC.Stack
+
+import Clang.Backtrace
+import Clang.Enum.Simple
+import Clang.LowLevel.Core.Instances ()
+
+{-------------------------------------------------------------------------------
+  Failed calls
+-------------------------------------------------------------------------------}
+
+-- | Call to @libclang@ failed
+--
+-- In @libclang@, being a C framework, errors are returned as values; in order
+-- to ensure that we don't forget to check for these error values, we turn them
+-- into 'CallFailed' exceptions.
+data CallFailed = CallFailed String Backtrace
+  deriving stock (Show)
+  deriving Exception via CollectedBacktrace CallFailed
+
+callFailed :: (MonadIO m, HasCallStack) => String -> m a
+callFailed hint = do
+    stack <- collectBacktrace
+    liftIO $ throwIO $ CallFailed hint stack
+
+callFailedShow :: (MonadIO m, Show hint, HasCallStack) => hint -> m a
+callFailedShow = callFailed . show
+
+{-------------------------------------------------------------------------------
+  Specific conditions
+-------------------------------------------------------------------------------}
+
+cToBool :: (Num a, Eq a) => a -> Bool
+cToBool 0 = False
+cToBool _ = True
+
+-- | Check result for error value
+ensure :: (HasCallStack, Show a) => (a -> Bool) -> IO a -> IO a
+ensure = ensureOn id
+
+-- | Generalization of 'ensure' with an additional translation step
+--
+-- This is useful in cases where the value that should be included in the
+-- exception should not be the original value but the translated one.
+ensureOn :: (HasCallStack, Show b)
+  => (a -> b)
+  -> (b -> Bool)
+  -> IO a -> IO a
+ensureOn f p call = do
+    x <- call
+    if p (f x)
+      then return x
+      else callFailedShow (f x)
+
+-- | Ensure that a function did not return 'nullPtr' (indicating error)
+ensureNotNull ::
+     (HasCallStack, IsNullPtr a, Show a)
+  => IO a -> IO a
+ensureNotNull = ensure (not . isNullPtr)
+
+-- | If the result is 'nullPtr', return 'Nothing'
+checkNotNull :: IsNullPtr a => IO a -> IO (Maybe a)
+checkNotNull call = do
+    ptr <- call
+    return $ if isNullPtr ptr
+               then Nothing
+               else Just ptr
+
+-- | Ensure that the result is not in the range of the specified enum
+--
+-- This is used for functions which return errors from a specified enum, such as
+-- @clang_Type_getSizeOf@, which will return errors from the 'CXTypeLayoutError'
+-- enum.
+--
+-- Intended for use with a type argument:
+--
+-- > ensureNotInRange @CXTypeLayoutError $
+-- >   wrap_Type_getSizeOf typ'
+ensureNotInRange :: forall hs a.
+     (HasCallStack, Integral a, Show hs, IsSimpleEnum hs)
+  => IO a -> IO a
+ensureNotInRange = ensureOn conv (not . simpleEnumInRange)
+  where
+    conv :: a -> SimpleEnum hs
+    conv = coerceSimpleEnum . fromIntegral
+
+{-------------------------------------------------------------------------------
+  Auxiliary
+-------------------------------------------------------------------------------}
+
+class IsNullPtr a where
+  isNullPtr :: a -> Bool
+
+instance IsNullPtr (Ptr a) where
+  isNullPtr ptr = ptr' == nullPtr
+    where
+      ptr' :: Ptr x
+      ptr' = coerce ptr
diff --git a/src/Clang/LowLevel/Core.hs b/src/Clang/LowLevel/Core.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Core.hs
@@ -0,0 +1,2109 @@
+{-# LANGUAGE CPP #-}
+
+-- | Low-level bindings to @libclang@
+--
+-- The goal of these bindings is to provide an API which is as close as possible
+-- to using the C API, whilst taking care of the most annoying low-level details
+-- such as
+--
+-- * callbacks
+-- * bytestrings
+-- * out-parameters
+-- * checking results for errors and throwing exceptions
+-- * etc.
+--
+-- Despite the low-level nature, these bindings should ideally be useable
+-- without imports of @Foreign.*@.
+--
+-- Guidelines:
+--
+-- * The goal of this module is not to be a complete set of bindings for all of
+--   @libclang@, but rather only to the parts that we need. We do include
+--   documentation.
+--
+-- * Structs are left opaque, with provided accessors where necessary. An
+--   accessor for a field @field@ of a type @CXFooBar@ is called @cxfbField@.
+--
+-- * For functions that take structs or return structs by value, we use our own
+--   wrappers from @cbits/clang_wrappers.h@, along with the infrastructure in
+--   "Clang.Internal.ByValue".
+--
+-- Most sections in this module and in the export list correspond to
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html>; see also
+-- <https://clang.llvm.org/doxygen/modules.html> for the full list.
+--
+-- /Note on naming/: When exposing a @libclang@ function called @clang_foo@, we
+-- will call the corresponding Haskell function also @clang_foo@, so that the
+-- Haskell API is as close to the C API as possible. However, the Haskell
+-- function @clang_foo@ does (usually) not bind /directly/ to the C function:
+--
+-- 1. The majority of functions we don't import from @libclang@ directly, but
+--    instead from our custom C wrappers. These C wrapper functions are called
+--    @wrap_foo@, and are imported as such.
+--
+-- 2. For functions for which we don't need a C wrapper, we import the
+--    @libclang@ function as @nowrapper_foo@.
+--
+-- /Note on pointers/: in the public API, all @libclang@ types are opaque.
+-- Internally, they are all newtypes around either 'Ptr' or 'OnHaskellHeap',
+-- depending on whether or not we own the value.
+module Clang.LowLevel.Core (
+    -- * Top-level
+    CXIndex
+  , DisplayDiagnostics(..)
+  , clang_createIndex
+  , clang_disposeIndex
+  , clang_getNumDiagnostics
+  , clang_getDiagnostic
+  , clang_getFileContents
+    -- * Diagnostic reporting
+  , CXDiagnostic
+  , CXDiagnosticSet
+  , CXDiagnosticDisplayOptions(..)
+  , CXDiagnosticSeverity(..)
+  , clang_getNumDiagnosticsInSet
+  , clang_getDiagnosticInSet
+  , clang_disposeDiagnosticSet
+  , clang_getChildDiagnostics
+  , clang_disposeDiagnostic
+  , clang_formatDiagnostic
+  , clang_defaultDiagnosticDisplayOptions
+  , clang_getDiagnosticSeverity
+  , clang_getDiagnosticLocation
+  , clang_getDiagnosticSpelling
+  , clang_getDiagnosticOption
+  , clang_getDiagnosticCategory
+  , clang_getDiagnosticCategoryText
+  , clang_getDiagnosticNumRanges
+  , clang_getDiagnosticRange
+  , clang_getDiagnosticNumFixIts
+  , clang_getDiagnosticFixIt
+    -- * Translation unit manipulation
+  , CXTranslationUnit
+  , CXUnsavedFile(..)
+  , CXTranslationUnit_Flags(..)
+  , CXTargetInfo(..)
+  , CXErrorCode(..)
+  , clang_parseTranslationUnit
+  , clang_parseTranslationUnit2
+  , clang_disposeTranslationUnit
+  , clang_getTranslationUnitTargetInfo
+  , clang_TargetInfo_dispose
+  , clang_TargetInfo_getTriple
+    -- * Cursor manipulations
+  , CXCursor(..)
+  , CXCursorKind(..)
+  , CXTLSKind(..)
+  , CXLinkageKind(..)
+  , CXVisibilityKind(..)
+  , CXAvailabilityKind(..)
+  , clang_getTranslationUnitCursor
+  , clang_equalCursors
+  , clang_getCursorSemanticParent
+  , clang_getCursorLexicalParent
+  , clang_getCursorTLSKind
+  , clang_Cursor_getArgument
+  , clang_getNullCursor
+  , clang_getCursorKind
+  , clang_getCursorKindSpelling
+  , clang_Cursor_getTranslationUnit
+  , clang_isDeclaration
+  , clang_getCursorLinkage
+  , clang_getCursorVisibility
+  , clang_getCursorAvailability
+  , clang_getIncludedFile
+  , clang_Cursor_getVarDeclInitializer
+    -- * Traversing the AST with cursors
+  , CXChildVisitResult(..)
+  , clang_visitChildren
+    -- * Cross-referencing in the AST
+  , clang_getCursorDisplayName
+  , clang_getCursorSpelling
+  , clang_getCursorReferenced
+  , clang_getCursorDefinition
+  , clang_getCanonicalCursor
+  , clang_Cursor_getRawCommentText
+  , clang_Cursor_getBriefCommentText
+  , clang_Cursor_getSpellingNameRange
+  , clang_isCursorDefinition
+  , clang_getCursorPrintingPolicy
+  , clang_getCursorPrettyPrinted
+  , clang_PrintingPolicy_dispose
+    -- * Type information for CXCursors
+  , CXTypeKind(..)
+  , CXTypeLayoutError(..)
+  , CXType(..)
+  , CX_StorageClass(..)
+  , cxtKind
+  , clang_getCursorType
+  , clang_getTypeKindSpelling
+  , clang_getTypeSpelling
+  , clang_getTypedefDeclUnderlyingType
+  , clang_getEnumDeclIntegerType
+  , clang_Cursor_isBitField
+  , clang_getFieldDeclBitWidth
+  , clang_getPointeeType
+  , clang_getElementType
+  , clang_getArrayElementType
+  , clang_getArraySize
+  , clang_Type_getSizeOf
+  , clang_Type_getAlignOf
+  , clang_Type_getOffsetOf
+  , clang_Type_isTransparentTagTypedef
+  , clang_Cursor_getOffsetOfField
+  , clang_Cursor_getStorageClass
+  , clang_Cursor_isAnonymous
+  , clang_Cursor_isAnonymousRecordDecl
+  , clang_getEnumConstantDeclValue
+  , clang_getEnumConstantDeclUnsignedValue
+  , clang_getCanonicalType
+  , clang_getTypedefName
+  , clang_getUnqualifiedType
+  , clang_isConstQualifiedType
+  , clang_isVolatileQualifiedType
+  , clang_isRestrictQualifiedType
+  , clang_getTypeDeclaration
+  , clang_isFunctionTypeVariadic
+  , clang_getResultType
+  , clang_getNumArgTypes
+  , clang_getArgType
+  , clang_Type_getNamedType
+  , clang_Type_getModifiedType
+  , clang_Type_getValueType
+    -- * Evaluation API
+  , CXEvalResultKind(..)
+  , clang_Cursor_Evaluate
+  , clang_EvalResult_getKind
+  , clang_EvalResult_getAsInt
+  , clang_EvalResult_getAsLongLong
+  , clang_EvalResult_isUnsignedInt
+  , clang_EvalResult_getAsUnsigned
+  , clang_EvalResult_getAsDouble
+  , clang_EvalResult_getAsStr
+  , clang_EvalResult_dispose
+    -- * Mapping between cursors and source code
+  , CXSourceRange
+  , clang_getCursorLocation
+  , clang_getCursorExtent
+    -- * Token extraction and manipulation
+  , CXToken
+  , CXTokenKind(..)
+  , clang_getToken
+  , clang_getTokenKind
+  , clang_getTokenSpelling
+  , clang_getTokenLocation
+  , clang_getTokenExtent
+  , clang_tokenize
+  , clang_disposeToken
+  , clang_disposeTokens
+  , index_CXTokenArray
+  , clang_annotateTokens
+  , index_CXCursorArray
+    -- * Physical source locations
+  , CXSourceLocation
+  , CXFile
+  , clang_getRangeStart
+  , clang_getRangeEnd
+  , clang_Range_isNull
+  , clang_getExpansionLocation
+  , clang_getPresumedLocation
+  , clang_getSpellingLocation
+  , clang_isBeforeInTranslationUnit
+  , clang_getFileLocation
+  , clang_getLocation
+  , clang_getRange
+  , clang_getFile
+  , clang_Location_isFromMainFile
+    -- * File manipulation routines
+  , clang_getFileName
+    -- * Debugging
+  , clang_breakpoint
+    -- * Exceptions
+  , CallFailed(..)
+    -- * Rewrite API
+  , clang_CXRewriter_create
+  , clang_CXRewriter_insertTextBefore
+  , clang_CXRewriter_writeMainFileToStdOut
+  , clang_CXRewriter_dispose
+    -- * Auxiliary
+  , IsNullPtr(..)
+  , nullCursor
+  ) where
+
+#include "clang_config.h"
+
+import Control.Exception
+import Control.Monad
+import Control.Monad.IO.Class
+import Data.ByteString.Unsafe qualified as ByteString
+import Data.IORef
+import Data.Text (Text)
+import Data.Text qualified as Text
+import Data.Text.Encoding qualified as Text.Encoding
+import Foreign
+import Foreign.C
+import GHC.Stack
+import System.IO.Unsafe (unsafeDupablePerformIO, unsafePerformIO)
+
+import Clang.Args
+import Clang.Enum.Bitfield
+import Clang.Enum.Simple
+import Clang.Internal.ByValue
+import Clang.Internal.ConstPtr (ConstPtr (ConstPtr, unConstPtr))
+import Clang.Internal.CXString ()
+import Clang.Internal.Exception
+import Clang.Internal.FFI
+import Clang.Internal.Ptr (safeCastPtr)
+import Clang.Internal.Results
+import Clang.LowLevel.Core.Enums
+import Clang.LowLevel.Core.Instances ()
+import Clang.LowLevel.Core.Pointers
+import Clang.LowLevel.Core.Structs
+import Clang.LowLevel.FFI
+import Clang.Paths
+import Clang.Version (requireClangVersion)
+
+{-------------------------------------------------------------------------------
+  Top-level
+
+  <https://clang.llvm.org/doxygen/group__CINDEX.html>
+-------------------------------------------------------------------------------}
+
+data DisplayDiagnostics =
+    DisplayDiagnostics
+  | DontDisplayDiagnostics
+  deriving stock (Show, Eq)
+
+-- | Provides a shared context for creating translation units.
+--
+-- /NOTE/: We are not planning to support precompiled headers, so we omit the
+-- first argument (@excludeDeclarationsFromPCH@).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#ga51eb9b38c18743bf2d824c6230e61f93>
+clang_createIndex ::
+     MonadIO m
+  => DisplayDiagnostics
+  -> m CXIndex
+clang_createIndex diagnostics = liftIO $
+    nowrapper_createIndex 0 diagnostics'
+  where
+    diagnostics' :: CInt
+    diagnostics' =
+        case diagnostics of
+          DisplayDiagnostics     -> 1
+          DontDisplayDiagnostics -> 0
+
+-- | Destroy the given index.
+--
+-- The index must not be destroyed until all of the translation units created
+-- within that index have been destroyed.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#ga166ab73b14be73cbdcae14d62dbab22a>
+clang_disposeIndex :: MonadIO m => CXIndex -> m ()
+clang_disposeIndex cIdx = liftIO $ nowrapper_disposeIndex cIdx
+
+-- | Determine the number of diagnostics produced for the given translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gae9f047b4bbbbb01161478d549b7aab25>
+clang_getNumDiagnostics :: MonadIO m => CXTranslationUnit -> m CUInt
+clang_getNumDiagnostics unit = liftIO $ nowrapper_getNumDiagnostics unit
+
+-- | Retrieve a diagnostic associated with the given translation unit.
+--
+-- Returns the requested diagnostic. This diagnostic must be freed via a call to
+-- 'clang_disposeDiagnostic'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#ga3f54a79e820c2ac9388611e98029afe5>
+clang_getDiagnostic ::
+     MonadIO m
+  => CXTranslationUnit
+     -- ^ the translation unit to query.
+  -> CUInt
+     -- ^ the zero-based diagnostic number to retrieve.
+  -> m CXDiagnostic
+clang_getDiagnostic unit ix = liftIO $ nowrapper_getDiagnostic unit ix
+
+{-------------------------------------------------------------------------------
+  Diagnostic reporting
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html>
+-------------------------------------------------------------------------------}
+
+-- | Determine the number of diagnostics in a 'CXDiagnosticSet'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga44e87e54125e501de0d3bd29161fe26b>
+clang_getNumDiagnosticsInSet :: MonadIO m => CXDiagnosticSet -> m CUInt
+clang_getNumDiagnosticsInSet set = liftIO $
+    nowrapper_getNumDiagnosticsInSet set
+
+-- | Retrieve a diagnostic associated with the given 'CXDiagnosticSet'.
+--
+-- Returns the requested diagnostic. This diagnostic must be freed via a call to
+-- 'clang_disposeDiagnostic'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga997e07d587e02eea7d29874c33c94249>
+clang_getDiagnosticInSet ::
+     MonadIO m
+  => CXDiagnosticSet  -- ^ the CXDiagnosticSet to query.
+  -> CUInt            -- ^ the zero-based diagnostic number to retrieve.
+  -> m CXDiagnostic
+clang_getDiagnosticInSet set ix = liftIO $
+    nowrapper_getDiagnosticInSet set ix
+
+-- | Release a CXDiagnosticSet and all of its contained diagnostics.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga1a1126b07e4dc0b45b0617f3cc848d57>
+clang_disposeDiagnosticSet :: MonadIO m => CXDiagnosticSet -> m ()
+clang_disposeDiagnosticSet set = liftIO $
+    nowrapper_disposeDiagnosticSet set
+
+-- | Retrieve the child diagnostics of a CXDiagnostic.
+--
+-- This 'CXDiagnosticSet' does not need to be released by
+-- 'clang_disposeDiagnosticSet'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga1aa24f925b34bb988dc3ea06ec27dcda>
+clang_getChildDiagnostics :: MonadIO m => CXDiagnostic -> m CXDiagnosticSet
+clang_getChildDiagnostics diagnostic = liftIO $
+    nowrapper_getChildDiagnostics diagnostic
+
+-- | Destroy a diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga07061e0ad7665b7c5ee7253cd1bf4a5c>
+clang_disposeDiagnostic :: MonadIO m => CXDiagnostic -> m ()
+clang_disposeDiagnostic diagnostic = liftIO $
+    nowrapper_disposeDiagnostic diagnostic
+
+-- | Format the given diagnostic in a manner that is suitable for display.
+--
+-- This routine will format the given diagnostic to a string, rendering the
+-- diagnostic according to the various options given. The
+-- 'clang_defaultDiagnosticDisplayOptions' function returns the set of options
+-- that most closely mimics the behavior of the clang compiler.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga455234ab6de0ca12c9ea36f8874060e8>
+clang_formatDiagnostic ::
+     MonadIO m
+  => CXDiagnostic
+  -> BitfieldEnum CXDiagnosticDisplayOptions
+  -> m Text
+clang_formatDiagnostic diagnostic (BitfieldEnum options) = liftIO $
+    preallocate_ $ wrap_formatDiagnostic diagnostic options
+
+-- | Retrieve the set of display options most similar to the default behavior of
+-- the clang compiler.
+--
+-- Returns a set of display options suitable for use with
+-- 'clang_formatDiagnostic'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga5fcf910792541399efd63c62042ce353>
+clang_defaultDiagnosticDisplayOptions ::
+     MonadIO m
+  => m (BitfieldEnum CXDiagnosticDisplayOptions)
+clang_defaultDiagnosticDisplayOptions = liftIO $
+    BitfieldEnum <$> nowrapper_defaultDiagnosticDisplayOptions
+
+-- | Determine the severity of the given diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gaff14261578eb9a2b02084f0cc6b95f9a>
+clang_getDiagnosticSeverity ::
+     MonadIO m
+  => CXDiagnostic
+  -> m (SimpleEnum CXDiagnosticSeverity)
+clang_getDiagnosticSeverity diagnostic = liftIO $
+    nowrapper_getDiagnosticSeverity diagnostic
+
+-- | Retrieve the source location of the given diagnostic.
+--
+-- This location is where Clang would print the caret (@^@) when displaying the
+-- diagnostic on the command line.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gabfcf70ac15bb3e5ae39ef2c5e07c7428>
+clang_getDiagnosticLocation :: MonadIO m => CXDiagnostic -> m CXSourceLocation
+clang_getDiagnosticLocation diagnostic = liftIO $
+    preallocate_ $ wrap_getDiagnosticLocation diagnostic
+
+-- | Retrieve the text of the given diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga34a875e6d06ed4f8d2fc032f850ebbe1>
+clang_getDiagnosticSpelling :: MonadIO m => CXDiagnostic -> m Text
+clang_getDiagnosticSpelling diagnostic = liftIO $
+    preallocate_ $ wrap_getDiagnosticSpelling diagnostic
+
+-- | Retrieve the name of the command-line option that enabled this diagnostic.
+--
+-- Returns a string that contains the command-line option used to enable this
+-- warning, such as @"-Wconversion"@ or @"-pedantic"@, as well as the option
+-- that disables this diagnostic (if any).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga69b094e2cca1cd6f452327dc9204a168>
+clang_getDiagnosticOption :: MonadIO m => CXDiagnostic -> m (Text, Text)
+clang_getDiagnosticOption diagnostic = liftIO $
+    preallocatePair_ $ wrap_getDiagnosticOption diagnostic
+
+-- | Retrieve the category number for this diagnostic.
+--
+-- Diagnostics can be categorized into groups along with other, related
+-- diagnostics (e.g., diagnostics under the same warning flag). This routine
+-- retrieves the category number for the given diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga0ec085bd59b8b6c935eab0e53a1f348f>
+clang_getDiagnosticCategory :: MonadIO m => CXDiagnostic -> m CUInt
+clang_getDiagnosticCategory diagnostic = liftIO $
+    nowrapper_getDiagnosticCategory diagnostic
+
+-- | Retrieve the diagnostic category text for a given diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga6950702b6122f1cd74e1a369605a9f54>
+clang_getDiagnosticCategoryText :: MonadIO m => CXDiagnostic -> m Text
+clang_getDiagnosticCategoryText diagnostic = liftIO $
+    preallocate_ $ wrap_getDiagnosticCategoryText diagnostic
+
+-- | Determine the number of source ranges associated with the given diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga7acbd761f1113ea657022e5708694924>
+clang_getDiagnosticNumRanges :: MonadIO m => CXDiagnostic -> m CUInt
+clang_getDiagnosticNumRanges diagnostic = liftIO $
+    nowrapper_getDiagnosticNumRanges diagnostic
+
+-- | Retrieve a source range associated with the diagnostic.
+--
+-- A diagnostic's source ranges highlight important elements in the source code.
+-- On the command line, Clang displays source ranges by underlining them with
+-- @~@ characters.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gabd440f1577374289ffebe73d9f65b294>
+clang_getDiagnosticRange ::
+     MonadIO m
+  => CXDiagnostic  -- ^ the diagnostic whose range is being extracted.
+  -> CUInt         -- ^ the zero-based index specifying which range to extract
+  -> m CXSourceRange
+clang_getDiagnosticRange diagnostic range = liftIO $
+    preallocate_ $ wrap_getDiagnosticRange diagnostic range
+
+-- | Determine the number of fix-it hints associated with the given diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gafe38dfd661f6ba59df956dfeabece2a2>
+clang_getDiagnosticNumFixIts :: MonadIO m => CXDiagnostic -> m CUInt
+clang_getDiagnosticNumFixIts diagnostic = liftIO $
+    nowrapper_getDiagnosticNumFixIts diagnostic
+
+-- | Retrieve the replacement information for a given fix-it.
+--
+-- Fix-its are described in terms of a source range whose contents should be
+-- replaced by a string. This approach generalizes over three kinds of
+-- operations: removal of source code (the range covers the code to be removed
+-- and the replacement string is empty), replacement of source code (the range
+-- covers the code to be replaced and the replacement string provides the new
+-- code), and insertion (both the start and end of the range point at the
+-- insertion location, and the replacement string provides the text to insert).
+--
+-- Returns the replacement range and a string containing text that should be
+-- replace the source code. The replacement range is the source range whose
+-- contents will be replaced with the returned replacement string. Note that
+-- source ranges are half-open ranges [a, b), so the source code should be
+-- replaced from a and up to (but not including) b.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gadf990bd68112475c5c07b19c1fe3938a>
+clang_getDiagnosticFixIt ::
+     MonadIO m
+  => CXDiagnostic  -- ^ The diagnostic whose fix-its are being queried.
+  -> CUInt         -- ^ The zero-based index of the fix-it.
+  -> m (CXSourceRange, Text)
+clang_getDiagnosticFixIt diagnostic fixit = liftIO $
+    preallocatePair_ $ wrap_getDiagnosticFixIt diagnostic fixit
+
+{-------------------------------------------------------------------------------
+  Translation unit manipulation
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html>
+-------------------------------------------------------------------------------}
+
+-- | Same as 'clang_parseTranslationUnit2', but returns the 'CXTranslationUnit'
+-- instead of an error code.
+--
+-- Throws 'CallFailed' in case of an error.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga2baf83f8c3299788234c8bce55e4472e>
+clang_parseTranslationUnit ::
+     (MonadIO m, HasCallStack)
+  => CXIndex                               -- ^ @CIdx@
+  -> Maybe SourcePath                      -- ^ @source_filename@
+  -> ClangArgs                             -- ^ @command_line_args@
+  -> [CXUnsavedFile]                       -- ^ @unsaved_files@
+  -> BitfieldEnum CXTranslationUnit_Flags  -- ^ @options@
+  -> m CXTranslationUnit
+clang_parseTranslationUnit cIdx src args unsavedFiles (BitfieldEnum options) =
+    liftIO $
+    withOptCString (getSourcePath <$> src) $ \src' ->
+      withCStrings (unClangArgs args) $ \args' numArgs ->
+        withArrayOrNull unsavedFiles $ \unsavedFiles' numUnsavedFiles ->
+          ensureNotNull $
+            nowrapper_parseTranslationUnit
+              cIdx
+              (ConstPtr src')
+              (ConstPtr (safeCastPtr args'))
+              numArgs
+              unsavedFiles'
+              (fromIntegral numUnsavedFiles)
+              options
+
+-- | Parse the given source file and the translation unit corresponding to that
+-- file.
+--
+-- This routine is the main entry point for the Clang C API, providing the
+-- ability to parse a source file into a translation unit that can then be
+-- queried by other functions in the API. This routine accepts a set of
+-- command-line arguments so that the compilation can be configured in the same
+-- way that the compiler is configured on the command line.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga494de0e725c5ae40cbdea5fa6081027d>
+clang_parseTranslationUnit2 ::
+     MonadIO m
+  => CXIndex
+     -- ^ The index object with which the translation unit will be associated.
+  -> Maybe SourcePath
+     -- ^ The name of the source file to load, or 'Nothing' if the source file
+     -- is included in @command_line_args@.
+  -> ClangArgs
+     -- ^ The command-line arguments that would be passed to the clang
+     -- executable if it were being invoked out-of-process.
+     --
+     -- These command-line options will be parsed and will affect how the
+     -- translation unit is parsed. Note that the following options are ignored:
+     -- @'-c'@, @'-emit-ast'@, @'-fsyntax-only'@ (which is the default), and
+     -- @'-o <output file>'@.
+  -> [CXUnsavedFile]
+     -- ^ The files that have not yet been saved to disk but may be required for
+     -- parsing, including the contents of those files.
+     --
+     -- The contents and name of these files (as specified by CXUnsavedFile) are
+     -- copied when necessary, so the client only needs to guarantee their
+     -- validity until the call to this function returns.
+  -> BitfieldEnum CXTranslationUnit_Flags
+     -- ^ Options that affects how the translation unit is managed but not its
+     -- compilation.
+  -> m (Either (SimpleEnum CXErrorCode) CXTranslationUnit)
+clang_parseTranslationUnit2 cIdx src args unsavedFiles (BitfieldEnum options) =
+    liftIO $
+    withOptCString (getSourcePath <$> src) $ \src' ->
+      withCStrings (unClangArgs args) $ \args' numArgs ->
+        withArrayOrNull unsavedFiles $ \unsavedFiles' numUnsavedFiles ->
+          alloca $ \outPtr -> do
+            mError <- nowrapper_parseTranslationUnit2
+              cIdx
+              (ConstPtr src')
+              (ConstPtr (safeCastPtr args'))
+              numArgs
+              unsavedFiles'
+              (fromIntegral numUnsavedFiles)
+              options
+              outPtr
+            case fromSimpleEnum mError of
+              Right Nothing ->
+                Right <$> peek outPtr
+              Right (Just knownError) ->
+                return $ Left (simpleEnum knownError)
+              Left unknownError ->
+                return $ Left (coerceSimpleEnum unknownError)
+
+-- | Destroy the specified CXTranslationUnit object.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#gaee753cb0036ca4ab59e48e3dff5f530a>
+clang_disposeTranslationUnit :: MonadIO m => CXTranslationUnit -> m ()
+clang_disposeTranslationUnit unit = liftIO $
+    nowrapper_disposeTranslationUnit unit
+
+-- | Get target information for this translation unit.
+--
+-- The 'CXTargetInfo' object cannot outlive the 'CXTranslationUnit' object.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga1813b53c06775c354f4797a5ec051948>
+clang_getTranslationUnitTargetInfo :: MonadIO m
+   => CXTranslationUnit -> m CXTargetInfo
+clang_getTranslationUnitTargetInfo unit = liftIO $
+    nowrapper_getTranslationUnitTargetInfo unit
+
+-- | Destroy the 'CXTargetInfo' object.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#gafb00d82420b0101c185b88338567ffd9>
+clang_TargetInfo_dispose :: MonadIO m => CXTargetInfo -> m ()
+clang_TargetInfo_dispose info = liftIO $ nowrapper_TargetInfo_dispose info
+
+--
+-- | Get the normalized target triple as a string.
+--
+-- Throws 'CallFailed' on error.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#ga7ae67e3c8baf6a9852900f6529dce2d0>
+clang_TargetInfo_getTriple ::
+     (MonadIO m, HasCallStack)
+  => CXTargetInfo -> m Text
+clang_TargetInfo_getTriple info = liftIO $ ensure (not . Text.null) $
+    preallocate_ $ wrap_TargetInfo_getTriple info
+
+{-------------------------------------------------------------------------------
+  Cursor manipulations
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html>
+-------------------------------------------------------------------------------}
+
+-- | A cursor representing some element in the abstract syntax tree for a
+-- translation unit.
+--
+-- The cursor abstraction unifies the different kinds of entities in a
+-- program–declaration, statements, expressions, references to declarations,
+-- etc.–under a single "cursor" abstraction with a common set of operations.
+-- Common operation for a cursor include: getting the physical location in a
+-- source file where the cursor points, getting the name associated with a
+-- cursor, and retrieving cursors for any child nodes of a particular cursor.
+--
+-- Cursors can be produced in two specific ways:
+--
+-- * 'clang_getTranslationUnitCursor' produces a cursor for a translation unit,
+--   from which one can use 'clang_visitChildren' to explore the rest of the
+--   translation unit.
+-- * @clang_getCursor@ maps from a physical source location to the entity that
+--   resides at that location, allowing one to map from the source code into
+--   the AST. (Not currently exposed by this library.)
+--
+-- <https://clang.llvm.org/doxygen/structCXCursor.html>
+newtype CXCursor = CXCursor (OnHaskellHeap CXCursor_)
+  deriving newtype (LivesOnHaskellHeap, Preallocate, Show)
+
+-- |
+--
+-- Note: we cannot easily implement cursor comparison directly in Haskell, as it's slightly complicated:
+-- See https://github.com/llvm/llvm-project/blob/4872ecf1cc3cb9c4939a9e6210a9b9e9a9032e9f/clang/tools/libclang/CIndex.cpp#L6529
+instance Eq CXCursor where
+  x == y = unsafeDupablePerformIO $ clang_equalCursors x y
+
+-- | Retrieve the cursor that represents the given translation unit.
+--
+-- The translation unit cursor can be used to start traversing the various
+-- declarations within the given translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gaec6e69127920785e74e4a517423f4391>
+clang_getTranslationUnitCursor :: MonadIO m => CXTranslationUnit -> m CXCursor
+clang_getTranslationUnitCursor unit = liftIO $
+    preallocate_ $ wrap_getTranslationUnitCursor unit
+
+-- | Determine whether two cursors are equivalent.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga98df58f09878710b983b6f3f60f0cba3>
+clang_equalCursors :: MonadIO m => CXCursor -> CXCursor -> m Bool
+clang_equalCursors a b = liftIO $
+    onHaskellHeap a $ \a' ->
+    onHaskellHeap b $ \b' ->
+      cToBool <$> wrap_equalCursors a' b'
+
+-- | Determine the semantic parent of the given cursor.
+--
+-- The semantic parent of a cursor is the cursor that semantically contains the
+-- given cursor. For many declarations, the lexical and semantic parents are
+-- equivalent (the lexical parent is returned by
+-- 'clang_getCursorLexicalParent'). They diverge when declarations or
+-- definitions are provided out-of-line. For example:
+--
+-- > class C {
+-- >  void f();
+-- > };
+-- >
+-- > void C::f() { }
+--
+-- In the out-of-line definition of @C::f@, the semantic parent is the class
+-- @C@, of which this function is a member. The lexical parent is the place
+-- where the declaration actually occurs in the source code; in this case, the
+-- definition occurs in the translation unit. In general, the lexical parent for
+-- a given entity can change without affecting the semantics of the program, and
+-- the lexical parent of different declarations of the same entity may be
+-- different. Changing the semantic parent of a declaration, on the other hand,
+-- can have a major impact on semantics, and redeclarations of a particular
+-- entity should all have the same semantic context.
+--
+-- In the example above, both declarations of @C::f@ have @C@ as their semantic
+-- context, while the lexical context of the first @C::f@ is @C@ and the lexical
+-- context of the second @C::f@ is the translation unit.
+--
+-- For global declarations, the semantic parent is the translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gabc327b200d46781cf30cb84d4af3c877>
+clang_getCursorSemanticParent :: MonadIO m => CXCursor -> m CXCursor
+clang_getCursorSemanticParent cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorSemanticParent cursor'
+
+-- | Determine the lexical parent of the given cursor.
+--
+-- The lexical parent of a cursor is the cursor in which the given cursor was
+-- actually written. For many declarations, the lexical and semantic parents are
+-- equivalent (the semantic parent is returned by
+-- 'clang_getCursorSemanticParent'). They diverge when declarations or
+-- definitions are provided out-of-line. For example:
+--
+-- > class C {
+-- >  void f();
+-- > };
+-- >
+-- > void C::f() { }
+--
+--
+-- In the out-of-line definition of @C::f@, the semantic parent is the class
+-- @C@, of which this function is a member. The lexical parent is the place
+-- where the declaration actually occurs in the source code; in this case, the
+-- definition occurs in the translation unit. In general, the lexical parent for
+-- a given entity can change without affecting the semantics of the program, and
+-- the lexical parent of different declarations of the same entity may be
+-- different. Changing the semantic parent of a declaration, on the other hand,
+-- can have a major impact on semantics, and redeclarations of a particular
+-- entity should all have the same semantic context.
+--
+-- In the example above, both declarations of @C::f@ have @C@ as their semantic
+-- context, while the lexical context of the first @C::f@ is @C@ and the lexical
+-- context of the second @C::f@ is the translation unit.
+--
+-- For declarations written in the global scope, the lexical parent is the
+-- translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gace7a423874d72b3fdc71d6b0f31830dd>
+clang_getCursorLexicalParent :: MonadIO m => CXCursor -> m CXCursor
+clang_getCursorLexicalParent cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorLexicalParent cursor'
+
+-- | Determine the "thread-local storage (TLS) kind" of the declaration referred to by a cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga524e1bd046dfb581484ec50e8f22ae7a>
+clang_getCursorTLSKind :: MonadIO m => CXCursor -> m (SimpleEnum CXTLSKind)
+clang_getCursorTLSKind cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getCursorTLSKind cursor'
+
+clang_Cursor_getArgument :: MonadIO m => CXCursor -> Int -> m CXCursor
+clang_Cursor_getArgument cursor i = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_Cursor_getArgument cursor' (fromIntegral i)
+
+-- | Retrieve the NULL cursor, which represents no entity.
+clang_getNullCursor :: MonadIO m => m CXCursor
+clang_getNullCursor = liftIO $ preallocate_ wrap_getNullCursor
+
+-- | Retrieve the kind of the given cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga018aaf60362cb751e517d9f8620d490c>
+clang_getCursorKind :: MonadIO m => CXCursor -> m (SimpleEnum CXCursorKind)
+clang_getCursorKind cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getCursorKind cursor'
+
+-- | Get spelling of a cursor
+--
+-- NOTE: This is from the @libclang@ \"Debugging facilities\"
+-- (https://clang.llvm.org/doxygen/group__CINDEX__DEBUG.html). This should be
+-- used only for testing and debugging, and should not be relied upon.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DEBUG.html#ga7a4eecfc1b343568cb9ea447cbde08a8>
+clang_getCursorKindSpelling :: MonadIO m => SimpleEnum CXCursorKind -> m Text
+clang_getCursorKindSpelling kind = liftIO $
+    preallocate_ $ wrap_getCursorKindSpelling kind
+
+-- | Returns the translation unit that a cursor originated from.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga529f1504710a41ce358d4e8c3161848d>
+clang_Cursor_getTranslationUnit ::
+     MonadIO m
+  => CXCursor -> m (Maybe CXTranslationUnit)
+clang_Cursor_getTranslationUnit cursor = liftIO $ checkNotNull $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_Cursor_getTranslationUnit cursor'
+
+-- | Determine whether the given cursor kind represents a declaration.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga660aa4846fce0a54e20073ab6a5465a0>
+clang_isDeclaration :: MonadIO m => SimpleEnum CXCursorKind -> m Bool
+clang_isDeclaration kind = liftIO $ cToBool <$> nowrapper_isDeclaration kind
+
+-- | Determine the linkage of the entity referred to by a given cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga359dae25aa1a71176a5e33f3c7ee1740>
+clang_getCursorLinkage :: MonadIO m => CXCursor -> m (SimpleEnum CXLinkageKind)
+clang_getCursorLinkage cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getCursorLinkage cursor'
+
+-- | Describe the visibility of the entity referred to by a cursor.
+--
+-- This returns the default visibility if not explicitly specified by a
+-- visibility attribute. The default visibility may be changed by commandline
+-- arguments.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga935b442bd6bde168cf354b7629b471d8>
+clang_getCursorVisibility :: MonadIO m => CXCursor -> m (SimpleEnum CXVisibilityKind)
+clang_getCursorVisibility cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getCursorVisibility cursor'
+
+-- | Determine the availability of the entity that this cursor refers to, taking
+-- the current target platform into account.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gab44e2a565fa40a0e0fc0f130f618a9b5>
+clang_getCursorAvailability :: MonadIO m => CXCursor -> m (SimpleEnum CXAvailabilityKind)
+clang_getCursorAvailability cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getCursorAvailability cursor'
+
+-- | Retrieve the file that is included by the given inclusion directive cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gaf61979977343e39f21d6ea0b22167514>
+clang_getIncludedFile :: MonadIO m => CXCursor -> m CXFile
+clang_getIncludedFile cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getIncludedFile cursor'
+
+-- | If cursor refers to a variable declaration and it has initializer returns
+-- cursor referring to the initializer otherwise return null cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga74690016573b854df29f33b477872e7d>
+clang_Cursor_getVarDeclInitializer :: MonadIO m => CXCursor -> m CXCursor
+clang_Cursor_getVarDeclInitializer cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_Cursor_getVarDeclInitializer cursor'
+
+{-------------------------------------------------------------------------------
+  Traversing the AST with cursors
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html>
+-------------------------------------------------------------------------------}
+
+-- | Visitor invoked for each cursor found by a traversal.
+--
+-- This is an internal type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html#gabf842c9ee20048b596eb9dfe94bb1570>
+type WrapCXCursorVisitor =
+     Ptr CXCursor_ -- ^ The cursor being visited.
+  -> Ptr CXCursor_ -- ^ The parent of the cursor being visited.
+  -> IO (SimpleEnum CXChildVisitResult)
+     -- ^ The visitor should return one of the 'CXChildVisitResult' values to
+     -- direct 'clang_visitChildren'.
+
+foreign import ccall "wrapper"
+  mkCursorVisitor :: WrapCXCursorVisitor -> IO (FunPtr WrapCXCursorVisitor)
+
+-- | See 'clang_visitChildren' for docs
+--
+-- /NOTE/: This is marked @safe@ rather than @unsafe@ as this calls back into
+-- Haskell.
+foreign import capi safe "clang_wrappers.h wrap_visitChildren"
+  wrap_visitChildren :: R CXCursor_ -> FunPtr WrapCXCursorVisitor -> IO CUInt
+
+-- | Visit the children of a particular cursor.
+--
+-- This function visits all the direct children of the given cursor, invoking
+-- the given visitor function with the cursors of each visited child. The
+-- traversal may be recursive, if the visitor returns 'CXChildVisit_Recurse'.
+-- The traversal may also be ended prematurely, if the visitor returns
+-- 'CXChildVisit_Break'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html#ga5d0a813d937e1a7dcc35f206ad1f7a91>
+clang_visitChildren ::
+     MonadIO m
+  => CXCursor
+     -- ^ @parent@
+     --
+     -- The cursor whose child may be visited. All kinds of cursors can be
+     -- visited, including invalid cursors (which, by definition, have no
+     -- children).
+  -> (    CXCursor
+       -> CXCursor
+       -> IO (SimpleEnum CXChildVisitResult)
+     )
+     -- ^ @visitor@
+     --
+     -- The visitor function that will be invoked for each child of parent.
+     -- It is passed the the cursor being visited and its parent.
+     --
+     -- /NOTE/: We omit the @client_data@ argument from @libclang@, as it is
+     -- not needed in Haskell (the IO action can have arbitrary data in its
+     -- closure).
+  -> m Bool
+     -- ^ 'True' if the traversal was terminated prematurely by the visitor
+     -- returning 'CXChildVisit_Break'.
+clang_visitChildren root visitor = liftIO $ do
+    -- reference cell for a possible exception thrown by 'visitor'.
+    eRef :: IORef (Maybe ExactException) <- newIORef Nothing
+    res  :: Bool <-
+      bracket (mkCursorVisitor $ aux eRef) freeHaskellFunPtr $ \visitor' ->
+        onHaskellHeap root $ \parent' ->
+          (/= 0) <$> wrap_visitChildren parent' visitor'
+    readIORef eRef >>= \case
+      Nothing  -> return res
+      Just exc -> throwExact exc
+  where
+    aux :: IORef (Maybe ExactException) -> WrapCXCursorVisitor
+    aux eRef current parent = do
+        current' <- CXCursor <$> copyToHaskellHeap current
+        parent'  <- CXCursor <$> copyToHaskellHeap parent
+        try (visitor current' parent') >>= \case
+          Left exc -> do
+            writeIORef eRef (Just (exc :: ExactException))
+            return (simpleEnum CXChildVisit_Break)
+          Right x -> return x
+
+{-------------------------------------------------------------------------------
+  Cross-referencing in the AST
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html>
+-------------------------------------------------------------------------------}
+
+
+-- | Retrieve the display name for the entity referenced by this cursor.
+--
+-- The display name contains extra information that helps identify the cursor,
+-- such as the parameters of a function or template or the arguments of a class
+-- template specialization.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gac3eba3224d109a956f9ef96fd4fe5c83>
+clang_getCursorDisplayName :: MonadIO m => CXCursor -> m Text
+clang_getCursorDisplayName cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_$ wrap_getCursorDisplayName cursor'
+
+-- | Retrieve a name for the entity referenced by this cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gaad1c9b2a1c5ef96cebdbc62f1671c763>
+clang_getCursorSpelling :: MonadIO m => CXCursor -> m Text
+clang_getCursorSpelling cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_$ wrap_getCursorSpelling cursor'
+
+-- | For a cursor that is a reference, retrieve a cursor representing the entity
+-- that it references.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gabf059155921552e19fc2abed5b4ff73a>
+clang_getCursorReferenced :: MonadIO m => CXCursor -> m CXCursor
+clang_getCursorReferenced cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorReferenced cursor'
+
+-- | For a cursor that is either a reference to or a declaration of some entity,
+-- retrieve a cursor that describes the definition of that entity.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gafcfbec461e561bf13f1e8540bbbd655b>
+clang_getCursorDefinition :: MonadIO m => CXCursor -> m CXCursor
+clang_getCursorDefinition cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorDefinition cursor'
+
+-- |  Retrieve the canonical cursor corresponding to the given cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gac802826668be9fd40a017523cc7d24fe>
+clang_getCanonicalCursor :: MonadIO m => CXCursor -> m CXCursor
+clang_getCanonicalCursor cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCanonicalCursor cursor'
+
+-- | Given a cursor that represents a declaration, return the associated comment
+-- text, including comment markers.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#ga32905a8b1858e67cf5d28b7ad7150779>
+clang_Cursor_getRawCommentText :: MonadIO m => CXCursor -> m Text
+clang_Cursor_getRawCommentText cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_$ wrap_Cursor_getRawCommentText cursor'
+
+-- | Given a cursor that represents a documentable entity (e.g., declaration),
+-- return the associated brief comment.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#ga6b5282b915d457d728434c0651ea0b8b>
+clang_Cursor_getBriefCommentText :: MonadIO m => CXCursor -> m Text
+clang_Cursor_getBriefCommentText cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_$ wrap_Cursor_getBriefCommentText cursor'
+
+-- | Retrieve a range for a piece that forms the cursors spelling name.
+--
+-- Most of the times there is only one range for the complete spelling but for
+-- Objective-C methods and Objective-C message expressions, there are multiple
+-- pieces for each selector identifier.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#ga251b31de80fd14681edf46f43b0bd03b>
+clang_Cursor_getSpellingNameRange ::
+     MonadIO m
+  => CXCursor
+  -> CUInt
+  -- ^ @pieceIndex@
+  --
+  -- The index of the spelling name piece. If this is greater than the actual
+  -- number of pieces, it will return 'Nothing'.
+  -> CUInt
+  -- ^ @options@
+  --
+  -- Reserved.
+  -> m (Maybe CXSourceRange)
+clang_Cursor_getSpellingNameRange cursor pieceIndex options = liftIO $
+    onHaskellHeap cursor $ \cursor' -> do
+      -- We don't normally do multiple calls in the low-level bindings. However,
+      -- the docs for @clang_Cursor_getSpellingNameRange@ claim that it returns
+      -- NULL when @pieceIndex@ is out of range, but that is impossible: it does
+      -- not return a pointer. We therefore do a \"null range\" check instead.
+      result :: CXSourceRange <- preallocate_ $
+        wrap_Cursor_getSpellingNameRange cursor' pieceIndex options
+      isNull <- clang_Range_isNull result
+      return $ if isNull then Nothing else Just result
+
+-- | Determine whether the declaration pointed to by this cursor is also a
+-- definition of that entity.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#ga6ad05634a73e693217088eaa693f0010>
+clang_isCursorDefinition :: MonadIO m => CXCursor -> m Bool
+clang_isCursorDefinition cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      cToBool <$> wrap_isCursorDefinition cursor'
+
+-- | Retrieve the default policy for the cursor.
+--
+-- The policy should be released after use with clang_PrintingPolicy_dispose.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gaae83c013276d1fff6475566a23d9fffd>
+clang_getCursorPrintingPolicy :: MonadIO m => CXCursor -> m CXPrintingPolicy
+clang_getCursorPrintingPolicy cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getCursorPrintingPolicy cursor'
+
+-- | Pretty print declarations.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#gab9d561cc237ce0d8bfbab80cdd5be216>
+clang_getCursorPrettyPrinted :: MonadIO m => CXCursor -> CXPrintingPolicy -> m Text
+clang_getCursorPrettyPrinted cursor pol = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorPrettyPrinted cursor' pol
+
+-- | Release a printing policy.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#ga81b2a9cac2b0ad4da7086c7fd3d4256f>
+clang_PrintingPolicy_dispose :: MonadIO m => CXPrintingPolicy -> m ()
+clang_PrintingPolicy_dispose pol = liftIO $ nowrapper_PrintingPolicy_dispose pol
+
+{-------------------------------------------------------------------------------
+  Type information for CXCursors
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html>
+-------------------------------------------------------------------------------}
+
+-- | The type of an element in the abstract syntax tree.
+--
+-- <https://clang.llvm.org/doxygen/structCXType.html>
+newtype CXType = CXType (OnHaskellHeap CXType_)
+  deriving newtype (LivesOnHaskellHeap, Preallocate, Show)
+
+instance Eq CXType where
+  x == y = unsafeDupablePerformIO $ clang_equalTypes x y
+
+instance Ord CXType where
+    compare x y = compare 0 $ unsafeDupablePerformIO $ clang_compareTypes x y
+
+foreign import capi unsafe "clang_wrappers.h wrap_cxtKind"
+  wrap_cxtKind :: R CXType_ -> IO (SimpleEnum CXTypeKind)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_compareTypes :: R CXType_ -> R CXType_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getUnqualifiedType :: R CXType_ -> W CXType_ -> IO ()
+
+-- | Extract the @kind@ field from a @CXType@ struct
+--
+-- <https://clang.llvm.org/doxygen/structCXType.html#ab27a7510dc88b0ec80cff04ec89901aa>
+cxtKind :: CXType -> SimpleEnum CXTypeKind
+cxtKind typ = unsafePerformIO $
+    onHaskellHeap typ $ \typ' ->
+      wrap_cxtKind typ'
+
+-- | Retrieve the type of a CXCursor (if any).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaae5702661bb1f2f93038051737de20f4>
+clang_getCursorType :: MonadIO m => CXCursor -> m CXType
+clang_getCursorType cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorType cursor'
+
+-- | Retrieve the spelling of a given CXTypeKind.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga6bd7b366d998fc67f4178236398d0666>
+clang_getTypeKindSpelling :: MonadIO m => SimpleEnum CXTypeKind -> m Text
+clang_getTypeKindSpelling kind = liftIO $
+    preallocate_$ wrap_getTypeKindSpelling kind
+
+-- | Pretty-print the underlying type using the rules of the language of the
+-- translation unit from which it came.
+--
+-- Throws 'CallFailed' if the type is invalid.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gac9d37f61bede521d4f42a6553bcbc09f>
+clang_getTypeSpelling :: (MonadIO m, HasCallStack) => CXType -> m Text
+clang_getTypeSpelling typ = liftIO $ ensure (not . Text.null) $
+     onHaskellHeap typ $ \typ' ->
+       preallocate_$ wrap_getTypeSpelling typ'
+
+-- | Retrieve the underlying type of a typedef declaration.
+--
+-- Throws 'CallFailed' if the cursor does not reference a typedef declaration.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga8de899fc18dc859b6fe3b97309f4fd52>
+clang_getTypedefDeclUnderlyingType ::
+     (MonadIO m, HasCallStack)
+  => CXCursor -> m CXType
+clang_getTypedefDeclUnderlyingType cursor = liftIO $ ensureValidType $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getTypedefDeclUnderlyingType cursor'
+
+-- | Retrieve the integer type of an enum declaration.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga0f5f950bee4e1828b51a41f0eaa951c4>
+clang_getEnumDeclIntegerType ::
+     (MonadIO m, HasCallStack)
+  => CXCursor -> m CXType
+clang_getEnumDeclIntegerType cursor = liftIO $ ensureValidType $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getEnumDeclIntegerType cursor'
+
+-- | Determine if the cursor specifies a record member that is a bit-field.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga750705f6b418b25ca00495b7392c740d>
+clang_Cursor_isBitField :: MonadIO m => CXCursor -> m Bool
+clang_Cursor_isBitField cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      cToBool <$> wrap_Cursor_isBitField cursor'
+
+-- | Return the bit width of a bit-field declaration as an integer.
+--
+-- If the cursor does not reference a bit-field, or if the bit-field's width
+-- expression cannot be evaluated, -1 is returned.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga80bbb872dde5b2f26964081338108f91>
+clang_getFieldDeclBitWidth :: MonadIO m => CXCursor -> m CInt
+clang_getFieldDeclBitWidth cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getFieldDeclBitWidth cursor'
+
+-- | For pointer types, returns the type of the pointee.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaafa3eb34932d8da1358d50ed949ff3ee>
+clang_getPointeeType :: MonadIO m => CXType -> m CXType
+clang_getPointeeType typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getPointeeType typ'
+
+-- | Return the element type of an array, complex, or vector type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gab35027c8bc48fab25f7698a415c93922>
+clang_getElementType :: MonadIO m => CXType -> m CXType
+clang_getElementType typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getElementType typ'
+
+-- | Return the element type of an array type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga718591f4b07d9d4861557a3ed8b29713>
+clang_getArrayElementType :: MonadIO m => CXType -> m CXType
+clang_getArrayElementType typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getArrayElementType typ'
+
+-- | Return the array size of a constant array.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga91521260817054f153b5f1295056192d>
+clang_getArraySize :: (MonadIO m, HasCallStack) => CXType -> m CLLong
+clang_getArraySize typ = liftIO $
+    onHaskellHeap typ $ \typ' -> ensureNotInRange @CXTypeLayoutError $
+      wrap_getArraySize typ'
+
+-- | Return the size of a type in bytes as per @C++[expr.sizeof]@ standard.
+--
+-- Throws 'CallFailed' with 'CXTypeLayoutError' on error.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga027abe334546e80931905f31399d0a8b>
+clang_Type_getSizeOf :: (MonadIO m, HasCallStack) => CXType -> m CLLong
+clang_Type_getSizeOf typ = liftIO $
+    onHaskellHeap typ $ \typ' -> ensureNotInRange @CXTypeLayoutError $
+      wrap_Type_getSizeOf typ'
+
+-- | Return the alignment of a type in bytes as per C++[expr.alignof] standard.
+--
+-- Throws 'CallFailed' with 'CXTypeLayoutError' on error.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaee56de66c69ab5605fe47e7c52497e31>
+clang_Type_getAlignOf :: (MonadIO m, HasCallStack) => CXType -> m CLLong
+clang_Type_getAlignOf typ = liftIO $
+    onHaskellHeap typ $ \typ' -> ensureNotInRange @CXTypeLayoutError $
+      wrap_Type_getAlignOf typ'
+
+-- | Return the offset of a field named S in a record of type T in bits as it
+-- would be returned by offsetof as per C++11[18.2p4].
+--
+-- Throws 'CallFailed' with 'CXTypeLayoutError' on error.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gab543536d5c18efb3e23a1b7903fb494d>
+clang_Type_getOffsetOf :: (MonadIO m, HasCallStack) => CXType -> String -> m CLLong
+clang_Type_getOffsetOf typ fieldName = liftIO $
+    onHaskellHeap typ $ \typ' -> ensureNotInRange @CXTypeLayoutError $
+    withCString fieldName $ \fieldName' ->
+      wrap_Type_getOffsetOf typ' (ConstPtr fieldName')
+
+-- | Determine if a typedef is 'transparent' tag.
+--
+-- A typedef is considered 'transparent' if it shares a name and spelling
+-- location with its underlying tag type, as is the case with the @NS_ENUM@
+-- macro.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga9ac4ecb0e84f25b9f05d54c67353eba0>
+clang_Type_isTransparentTagTypedef :: MonadIO m => CXType -> m Bool
+clang_Type_isTransparentTagTypedef typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      cToBool <$> wrap_Type_isTransparentTagTypedef typ'
+
+-- | Return the offset of the field represented by the Cursor.
+--
+-- Unit: bits
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaa7e0f0ec320c645e971168ac39aa0cab>
+clang_Cursor_getOffsetOfField :: MonadIO m => CXCursor -> m CLLong
+clang_Cursor_getOffsetOfField cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_Cursor_getOffsetOfField cursor'
+
+-- | Returns the storage class for a function or variable declaration.
+--
+-- Throws 'CallFailed' if the passed in Cursor is not a function or variable
+-- declaration.
+--
+-- NOTE: Storage classes cannot be combined.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga230c7904f3878469d772f3e464b9c83d>
+clang_Cursor_getStorageClass ::
+     MonadIO m
+  => CXCursor -> m (SimpleEnum CX_StorageClass)
+clang_Cursor_getStorageClass cursor = liftIO $ ensure (/= coerceSimpleEnum 0) $
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_Cursor_getStorageClass cursor'
+
+-- | Determine whether the given cursor represents an anonymous tag or
+-- namespace.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga6e0d2674d126fd43816ce3a80b592373>
+clang_Cursor_isAnonymous :: MonadIO m => CXCursor -> m Bool
+clang_Cursor_isAnonymous cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      cToBool <$> wrap_Cursor_isAnonymous cursor'
+
+-- | Determine whether the given cursor represents an anonymous record declaration.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga59aaf3b8329a35e400ee3735229a8cb6>
+clang_Cursor_isAnonymousRecordDecl :: MonadIO m => CXCursor -> m Bool
+clang_Cursor_isAnonymousRecordDecl cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      cToBool <$> wrap_Cursor_isAnonymousRecordDecl cursor'
+
+-- | Retrieve the integer value of an enum constant declaration as a signed long
+-- long.
+--
+-- Throws 'CallFailed' if the cursor does not reference an enum constant
+-- declaration.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga6b8585818420e7512feb4c9d209b4f4d>
+clang_getEnumConstantDeclValue ::
+     (MonadIO m, HasCallStack)
+  => CXCursor -> m CLLong
+clang_getEnumConstantDeclValue cursor = liftIO $ do
+    -- The @libclang@ docs state:
+    --
+    -- > If the cursor does not reference an enum constant declaration,
+    -- > LLONG_MIN is returned. Since this is also potentially a valid constant
+    -- > value, the kind of the cursor must be verified before calling this
+    -- > function.
+    cursorKind <- clang_getCursorKind cursor
+    unless (cursorKind == simpleEnum CXCursor_EnumConstantDecl) $
+      callFailedShow cursorKind
+
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getEnumConstantDeclValue cursor'
+
+-- | Retrieve the integer value of an enum constant declaration as an unsigned
+-- value.
+--
+-- Use this instead of 'clang_getEnumConstantDeclValue' when the enum's
+-- underlying type is unsigned, to avoid misinterpreting high bit values as
+-- negative numbers.
+--
+-- Throws 'CallFailed' if the cursor does not reference an enum constant
+-- declaration.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga0da1d74e0112e5a0e69d6fbc6743a1a1>
+clang_getEnumConstantDeclUnsignedValue ::
+     (MonadIO m, HasCallStack)
+  => CXCursor -> m CULLong
+clang_getEnumConstantDeclUnsignedValue cursor = liftIO $ do
+    cursorKind <- clang_getCursorKind cursor
+    unless (cursorKind == simpleEnum CXCursor_EnumConstantDecl) $
+      callFailedShow cursorKind
+    onHaskellHeap cursor $ \cursor' ->
+      wrap_getEnumConstantDeclUnsignedValue cursor'
+
+-- | Determine whether two CXTypes represent the same type.
+clang_equalTypes :: MonadIO m => CXType -> CXType -> m Bool
+clang_equalTypes a b = liftIO $
+    onHaskellHeap a $ \a' ->
+    onHaskellHeap b $ \b' ->
+      cToBool <$> wrap_equalTypes a' b'
+
+clang_compareTypes :: MonadIO m => CXType -> CXType -> m CInt
+clang_compareTypes a b = liftIO $
+    onHaskellHeap a $ \a' ->
+    onHaskellHeap b $ \b' ->
+      wrap_compareTypes a' b'
+
+-- | Return the canonical type for a CXType.
+--
+-- Clang's type system explicitly models typedefs and all the ways a specific
+-- type can be represented. The canonical type is the underlying type with all
+-- the "sugar" removed. For example, if 'T' is a typedef for 'int', the
+-- canonical type for 'T' would be 'int'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaa9815d77adc6823c58be0a0e32010f8c>
+clang_getCanonicalType :: MonadIO m => CXType -> m CXType
+clang_getCanonicalType typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getCanonicalType typ'
+
+-- | Returns the typedef name of the given type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga7b8e66707c7f27550acfc2daeec527ed>
+clang_getTypedefName :: MonadIO m => CXType -> m Text
+clang_getTypedefName arg = liftIO $
+    onHaskellHeap arg $ \arg' ->
+      preallocate_ $ wrap_getTypedefName arg'
+
+-- | Retrieve the unqualified variant of the given type, removing as little sugar as possible.
+--
+-- For example, given the following series of typedefs:
+--
+-- > typedef int Integer;
+-- > typedef const Integer CInteger;
+-- > typedef CInteger DifferenceType;
+--
+-- Executing 'clang_getUnqualifiedType' on a CXType that represents
+-- @DifferenceType@, will desugar to a type representing @Integer@, that has no
+-- qualifiers.
+--
+-- And, executing 'clang_getUnqualifiedType' on the type of the first argument
+-- of the following function declaration:
+--
+-- > void foo(const int);
+--
+-- Will return a type representing @int@, removing the @const@ qualifier.
+--
+-- Sugar over array types is not desugared.
+--
+-- A type can be checked for qualifiers with 'clang_isConstQualifiedType',
+-- 'clang_isVolatileQualifiedType' and 'clang_isRestrictQualifiedType'.
+--
+-- A type that resulted from a call to 'clang_getUnqualifiedType' will return
+-- false for all of the above calls.
+--
+-- Throws 'CallFailed' if the argument is an invalid type.
+--
+-- /NOTE/: Requires @llvm-16@ or higher; throws 'ClangVersionError' otherwise.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga8adac28955bf2f3a5ab1fd316a498334>
+clang_getUnqualifiedType :: MonadIO m => CXType -> m CXType
+clang_getUnqualifiedType typ = liftIO $ do
+    -- clang_getUnqualifiedType was added in Clang 16
+    requireClangVersion (16, 0, 0)
+    -- clang_getUnqualifiedType segfaults when CT is invalid
+    case fromSimpleEnum (cxtKind typ) of
+      e@Left{}                 -> callFailedShow e
+      e@(Right CXType_Invalid) -> callFailedShow e
+      Right{}                  -> pure ()
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getUnqualifiedType typ'
+
+-- | Determine whether a 'CXType' has the @const@ qualifier set, without
+-- looking through typedefs that may have added "const" at a different level.
+--
+-- See also 'clang_getCanonicalType'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga8c3f8029254d5862bcd595d6c8778e5b>
+clang_isConstQualifiedType :: MonadIO m => CXType -> m Bool
+clang_isConstQualifiedType typ = liftIO $ do
+    onHaskellHeap typ $ \typ' ->
+      cToBool <$> wrap_isConstQualifiedType typ'
+
+-- | Determine whether a 'CXType' has the @volatile@ qualifier set, without
+-- looking through typedefs that may have added "volatile" at a different level.
+--
+-- See also 'clang_getCanonicalType'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaac0ac93cded7d1e5c60f539daaed13ec>
+clang_isVolatileQualifiedType :: MonadIO m => CXType -> m Bool
+clang_isVolatileQualifiedType typ = liftIO $ do
+    onHaskellHeap typ $ \typ' ->
+      cToBool <$> wrap_isVolatileQualifiedType typ'
+
+-- | Determine whether a 'CXType' has the @restrict@ qualifier set, without
+-- looking through typedefs that may have added "restrict" at a different level.
+--
+-- See also 'clang_getCanonicalType'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga12375c30c12b0c3ede87492605db1d0c>
+clang_isRestrictQualifiedType :: MonadIO m => CXType -> m Bool
+clang_isRestrictQualifiedType typ = liftIO $ do
+    onHaskellHeap typ $ \typ' ->
+      cToBool <$> wrap_isRestrictQualifiedType typ'
+
+-- | Return the cursor for the declaration of the given type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga0aad74ea93a2f5dea58fd6fc0db8aad4>
+clang_getTypeDeclaration :: MonadIO m => CXType -> m CXCursor
+clang_getTypeDeclaration typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getTypeDeclaration typ'
+
+-- | Check if the CXType is a variadic function type
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga343b2463b0ed4b259739242cf26c3ae2>
+clang_isFunctionTypeVariadic :: MonadIO m => CXType -> m Bool
+clang_isFunctionTypeVariadic typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      cToBool <$> wrap_isFunctionTypeVariadic typ'
+
+-- | Retrieve the return type associated with a function type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga39b4850746f39e17c6b8b4eef3154d85>
+clang_getResultType :: MonadIO m => CXType -> m CXType
+clang_getResultType typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getResultType typ'
+
+-- | Retrieve the number of non-variadic parameters associated with a function type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga705e1a4ed7c7595606fc30ed5d2a6b5a>
+clang_getNumArgTypes :: MonadIO m => CXType -> m CInt
+clang_getNumArgTypes typ = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      wrap_getNumArgTypes typ'
+
+-- | Retrieve the type of a parameter of a function type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga67f60ba4831b1bfd90ab0c1c12adab27>
+clang_getArgType :: MonadIO m => CXType -> CUInt -> m CXType
+clang_getArgType typ n = liftIO $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_getArgType typ' n
+
+-- | Retrieve the type named by the qualified-id.
+--
+-- Throws 'CallFailed' if a non-elaborated type is passed in.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gac6d90c2acdae77f75d8e8288658da463>
+clang_Type_getNamedType :: (MonadIO m, HasCallStack) => CXType -> m CXType
+clang_Type_getNamedType typ = liftIO $ ensureValidType $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_Type_getNamedType typ'
+
+-- | Return the type that was modified by this attributed type.
+--
+-- Throws 'CallFailed' if the type is not an attributed type.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga6fc6ec9bfd9baada2d3fd6022d774675>
+clang_Type_getModifiedType :: (MonadIO m, HasCallStack) => CXType -> m CXType
+clang_Type_getModifiedType typ = liftIO $ ensureValidType $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_Type_getModifiedType typ'
+
+-- | Gets the type contained by this atomic type.
+--
+-- Throws 'CallFailed' if a non-atomic type is passed in.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gae42d9886e0e221df03c4a518d9afb622>
+clang_Type_getValueType :: (MonadIO m, HasCallStack) => CXType -> m CXType
+clang_Type_getValueType typ = liftIO $ ensureValidType $
+    onHaskellHeap typ $ \typ' ->
+      preallocate_ $ wrap_Type_getValueType typ'
+
+{-------------------------------------------------------------------------------
+  Evaluation API
+-------------------------------------------------------------------------------}
+
+-- | If cursor is a statement declaration tries to evaluate the statement and if
+-- its variable, tries to evaluate its initializer, into its corresponding type.
+--
+-- If it's an expression, tries to evaluate the expression.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga6be809ca82538f4a610d9a5b18a10ccb>
+clang_Cursor_Evaluate :: MonadIO m => CXCursor -> m CXEvalResult
+clang_Cursor_Evaluate cursor =
+    liftIO $ onHaskellHeap cursor wrap_Cursor_Evaluate
+
+-- | Returns the kind of the evaluated result.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#gaea912a0620a9c16c1e46fdedf4825955>
+clang_EvalResult_getKind ::
+     MonadIO m
+  => CXEvalResult
+  -> m (SimpleEnum CXEvalResultKind)
+clang_EvalResult_getKind = liftIO . nowrapper_EvalResult_getKind
+
+-- | Returns the evaluation result as integer if the kind is @Int@.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga8abe0404897d93813d98bd07a198caa1>
+clang_EvalResult_getAsInt :: MonadIO m => CXEvalResult -> m CInt
+clang_EvalResult_getAsInt = liftIO . nowrapper_EvalResult_getAsInt
+
+-- | Returns the evaluation result as a @long long integer@ if the kind is
+-- @Int@.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga488b6b6a445be15e80ffe4816b2086c8>
+clang_EvalResult_getAsLongLong :: MonadIO m => CXEvalResult -> m CLLong
+clang_EvalResult_getAsLongLong = liftIO . nowrapper_EvalResult_getAsLongLong
+
+-- | Returns a non-zero value if the kind is @Int@ and the evaluation result
+-- resulted in an unsigned integer.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#gad72ab38051388e5ed607ce5ce890b2ac>
+clang_EvalResult_isUnsignedInt :: MonadIO m => CXEvalResult -> m Bool
+clang_EvalResult_isUnsignedInt =
+    liftIO . fmap cToBool . nowrapper_EvalResult_isUnsignedInt
+
+-- | Returns the evaluation result as an unsigned integer if the kind is @Int@
+-- and @clang_EvalResult_isUnsignedInt@ is non-zero.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga448569d83b25514da4a15e6623d4bf4e>
+clang_EvalResult_getAsUnsigned :: MonadIO m => CXEvalResult -> m CULLong
+clang_EvalResult_getAsUnsigned = liftIO . nowrapper_EvalResult_getAsUnsigned
+
+-- | Returns the evaluation result as @double@ if the kind is @double@.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga6d140616208f61e24e18abf806aa68a7>
+clang_EvalResult_getAsDouble :: MonadIO m => CXEvalResult -> m CDouble
+clang_EvalResult_getAsDouble = liftIO . nowrapper_EvalResult_getAsDouble
+
+-- | Returns the evaluation result as a constant string if the kind is other
+-- than @Int@ or @float@.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#gae387ea1b7a8c2d54a324161a856b77dd>
+clang_EvalResult_getAsStr :: MonadIO m => CXEvalResult -> m String
+clang_EvalResult_getAsStr = liftIO . (peekCString . unConstPtr <=< nowrapper_EvalResult_getAsStr)
+
+-- | Disposes the created @Eval@ memory.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#gaee104dfbff3ee6799ddebb417e968d8a>
+clang_EvalResult_dispose :: MonadIO m => CXEvalResult -> m ()
+clang_EvalResult_dispose = liftIO . nowrapper_EvalResult_dispose
+
+{-------------------------------------------------------------------------------
+  Mapping between cursors and source code
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html>
+-------------------------------------------------------------------------------}
+
+-- | Identifies a half-open character range in the source code.
+--
+-- Use 'clang_getRangeStart' and 'clang_getRangeEnd' to retrieve the starting
+-- and end locations from a source range, respectively.
+--
+-- <https://clang.llvm.org/doxygen/structCXSourceRange.html>
+newtype CXSourceRange = CXSourceRange (OnHaskellHeap CXSourceRange_)
+  deriving newtype (LivesOnHaskellHeap, Preallocate, Show)
+
+-- | Retrieve the physical location of the source constructor referenced by the
+-- given cursor.
+--
+-- The location of a declaration is typically the location of the name of that
+-- declaration, where the name of that declaration would occur if it is unnamed,
+-- or some keyword that introduces that particular declaration. The location of
+-- a reference is where that reference occurs within the source code.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html#gada3d3cbd3a3e83ff64f992617318dfb1>
+clang_getCursorLocation :: MonadIO m => CXCursor -> m CXSourceLocation
+clang_getCursorLocation cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorLocation cursor'
+
+-- | Retrieve the physical extent of the source construct referenced by the
+-- given cursor.
+--
+-- The extent of a cursor starts with the file/line/column pointing at the first
+-- character within the source construct that the cursor refers to and ends with
+-- the last character within that source construct. For a declaration, the
+-- extent covers the declaration itself. For a reference, the extent covers the
+-- location of the reference (e.g., where the referenced entity was actually
+-- used).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html#ga79f6544534ab73c78a8494c4c0bc2840>
+clang_getCursorExtent :: MonadIO m => CXCursor -> m CXSourceRange
+clang_getCursorExtent cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_getCursorExtent cursor'
+
+{-------------------------------------------------------------------------------
+  Token extraction and manipulation
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html>
+-------------------------------------------------------------------------------}
+
+{- Note [CXToken representation]
+
+  Normally we use 'R' and 'W' for structs and unions that are exclusively passed
+  by value. The 'CXToken' struct is awkward because it is passed by value in
+  some cases, and by pointer in other cases. That's why we represent it as a
+  pointer to the struct.
+-}
+
+newtype CXToken = CXToken (Ptr CXToken_)
+  deriving stock (Show)
+  deriving newtype (IsNullPtr)
+
+-- | Get the raw lexical token starting with the given location.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#ga3b41b2c8a34e605a14608927ae544c03>
+clang_getToken ::
+     MonadIO m
+  => CXTranslationUnit -> CXSourceLocation -> m (Maybe CXToken)
+clang_getToken unit loc = liftIO $ checkNotNull $
+    onHaskellHeap loc $ \loc' ->
+      CXToken <$> wrap_getToken unit loc'
+
+-- | Determine the kind of the given token.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#ga83f692a67fe4dbeea779f37c0a3b7f20>
+clang_getTokenKind :: MonadIO m => CXToken -> m (SimpleEnum CXTokenKind)
+clang_getTokenKind (CXToken token) = liftIO $ wrap_getTokenKind token
+
+-- | Determine the spelling of the given token.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#ga1033a25c9d2c59bcbdb23020de0bba2c>
+clang_getTokenSpelling :: MonadIO m => CXTranslationUnit -> CXToken -> m Text
+clang_getTokenSpelling unit (CXToken token) = liftIO $
+    preallocate_ $ wrap_getTokenSpelling unit token
+
+-- | Retrieve the source location of the given token.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#ga76a721514acb4cc523e10a6913d88021>
+clang_getTokenLocation ::
+     MonadIO m
+  => CXTranslationUnit -> CXToken -> m CXSourceLocation
+clang_getTokenLocation unit (CXToken token) = liftIO $
+    preallocate_ $ wrap_getTokenLocation unit token
+
+-- | Retrieve a source range that covers the given token.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#ga5acbc0a2a3c01aa44e1c5c5ccc4e328b>
+clang_getTokenExtent ::
+     MonadIO m
+  => CXTranslationUnit -> CXToken -> m CXSourceRange
+clang_getTokenExtent unit (CXToken token) = liftIO $
+    preallocate_ $ wrap_getTokenExtent unit token
+
+newtype CXTokenArray = CXTokenArray (Ptr CXToken_)
+  deriving newtype (Storable)
+
+-- | Tokenize the source code described by the given range into raw lexical
+-- tokens.
+--
+-- Returns the array of tokens and the number of tokens in the array. The array
+-- must be disposed using 'clang_disposeTokens' before the translation unit is
+-- destroyed.
+clang_tokenize ::
+     MonadIO m
+  => CXTranslationUnit
+  -> CXSourceRange
+  -> m (CXTokenArray, CUInt)
+clang_tokenize unit range = liftIO $
+    onHaskellHeap range $ \range' ->
+      alloca $ \array ->
+      alloca $ \numTokens -> do
+        wrap_tokenize unit range' array numTokens
+        (,) <$> (CXTokenArray <$> peek array) <*> peek numTokens
+
+-- | Free a single token using 'clang_disposeTokens'.
+clang_disposeToken ::
+     MonadIO m
+  => CXTranslationUnit
+  -> CXToken
+  -> m ()
+clang_disposeToken unit (CXToken token) = liftIO $
+    nowrapper_disposeTokens unit token 1
+
+-- | Free the given set of tokens.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#gac5266f6b5fee87c433b696437cab0d13>
+clang_disposeTokens ::
+     MonadIO m
+  => CXTranslationUnit -> CXTokenArray -> CUInt -> m ()
+clang_disposeTokens unit (CXTokenArray tokens) numTokens = liftIO $
+    nowrapper_disposeTokens unit tokens numTokens
+
+-- | Index token array
+--
+-- We do not verify bounds (nor that the array has not already been disposed).
+index_CXTokenArray :: CXTokenArray -> CUInt -> CXToken
+index_CXTokenArray (CXTokenArray array) i = CXToken $
+    array `plusPtr` (fromIntegral i * knownSize @CXToken_)
+
+newtype CXCursorArray = CXCursorArray (ArrOnHaskellHeap CXCursor_)
+
+clang_annotateTokens ::
+     MonadIO m
+  => CXTranslationUnit
+  -> CXTokenArray  -- ^ Tokens to annotate
+  -> CUInt         -- ^ Number of tokens in the array
+  -> m CXCursorArray
+clang_annotateTokens unit (CXTokenArray tokens) numTokens = liftIO $ fmap CXCursorArray $
+    preallocateArray (fromIntegral numTokens) $ \arr ->
+      nowrapper_annotateTokens unit tokens numTokens arr
+
+index_CXCursorArray :: MonadIO m => CXCursorArray -> CUInt -> m CXCursor
+index_CXCursorArray (CXCursorArray arr) i = liftIO $
+    CXCursor <$> indexArrOnHaskellHeap arr (fromIntegral i)
+
+{-------------------------------------------------------------------------------
+  Physical source locations
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html>
+-------------------------------------------------------------------------------}
+
+-- | Identifies a specific source location within a translation unit.
+--
+-- Use 'clang_getExpansionLocation' or 'clang_getSpellingLocation' to map a
+-- source location to a particular file, line, and column.
+--
+-- <https://clang.llvm.org/doxygen/structCXSourceLocation.html>
+newtype CXSourceLocation = CXSourceLocation (OnHaskellHeap CXSourceLocation_)
+  deriving newtype (LivesOnHaskellHeap, Preallocate, Show)
+
+-- | Retrieve a source location representing the first character within a source
+-- range.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gac2cc034e3965739c41662f6ada7ff248>
+clang_getRangeStart :: MonadIO m => CXSourceRange -> m CXSourceLocation
+clang_getRangeStart range = liftIO $
+    onHaskellHeap range $ \range' ->
+      preallocate_ $ wrap_getRangeStart range'
+
+-- | Retrieve a source location representing the last character within a source
+-- range.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gacdb7d3c2b77a06bcc2e83bde3e14c3c0>
+clang_getRangeEnd :: MonadIO m => CXSourceRange -> m CXSourceLocation
+clang_getRangeEnd range = liftIO $
+    onHaskellHeap range $ \range' ->
+      preallocate_ $ wrap_getRangeEnd range'
+
+-- | Check if range is null
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#ga39213a93703e84c0accdba1f618d7fbb>
+clang_Range_isNull :: MonadIO m => CXSourceRange -> m Bool
+clang_Range_isNull range = liftIO $
+    onHaskellHeap range $ \range' ->
+      cToBool <$> wrap_Range_isNull range'
+
+-- | Retrieve the file, line, column, and offset represented by the given source
+-- location.
+--
+-- If the location refers into a macro expansion, retrieves the location of the
+-- macro expansion.
+--
+-- NOTE: this replaces @clang_getInstantiationLocation@ (now legacy).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gadee4bea0fa34550663e869f48550eb1f>
+clang_getExpansionLocation ::
+     MonadIO m
+  => CXSourceLocation
+  -> m (CXFile, CUInt, CUInt, CUInt)
+clang_getExpansionLocation location = liftIO $
+    onHaskellHeap location $ \location' ->
+      alloca $ \file ->
+      alloca $ \line ->
+      alloca $ \column ->
+      alloca $ \offset -> do
+        wrap_getExpansionLocation location' file line column offset
+        (,,,) <$> peek file <*> peek line <*> peek column <*> peek offset
+
+-- | Retrieve the file, line and column represented by the given source
+-- location, as specified in a @#line@ directive.
+--
+-- Note that filenames returned will be for "virtual" files, which don't
+-- necessarily exist on the machine running clang - e.g. when parsing
+-- preprocessed output obtained from a different environment.
+--
+-- Example: given the following source code in a file somefile.c
+--
+-- > #123 "dummy.c" 1
+-- >
+-- > static int func(void)
+-- > {
+-- >     return 0;
+-- > }
+--
+-- the location information returned by this function would be
+--
+-- > File: dummy.c Line: 124 Column: 12
+--
+-- whereas 'clang_getExpansionLocation' would have returned
+--
+-- > File: somefile.c Line: 3 Column: 12
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#ga03508d9c944feeb3877515a1b08d36f9>
+clang_getPresumedLocation ::
+     MonadIO m
+  => CXSourceLocation -> m (Text, CUInt, CUInt)
+clang_getPresumedLocation location = liftIO $
+    onHaskellHeap location $ \location' ->
+      alloca $ \line ->
+      alloca $ \column -> do
+        filename' <- preallocate_ $ \filename ->
+          wrap_getPresumedLocation location' filename line column
+        (filename',,) <$> peek line <*> peek column
+
+-- | Retrieve the file, line, column, and offset represented by the given source
+-- location.
+--
+-- If the location refers into a macro instantiation, return where the location
+-- was originally spelled in the source file.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#ga01f1a342f7807ea742aedd2c61c46fa0>
+clang_getSpellingLocation ::
+     MonadIO m
+  => CXSourceLocation
+  -> m (CXFile, CUInt, CUInt, CUInt)
+clang_getSpellingLocation location = liftIO $
+    onHaskellHeap location $ \location' ->
+      alloca $ \file ->
+      alloca $ \line ->
+      alloca $ \column ->
+      alloca $ \offset -> do
+        wrap_getSpellingLocation location' file line column offset
+        (,,,) <$> peek file <*> peek line <*> peek column <*> peek offset
+
+-- | Determine for two source locations if the first comes strictly before the second one in the source code.
+--
+-- Returns 'True' if the first source location comes strictly before the
+-- second one, 'False' otherwise.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gad0191c9ccd1ba6eeb222b488e458a0f8>
+--
+-- 'clang_isBeforeInTranslationUnit' is not available for Clang versions older than 20.1.
+clang_isBeforeInTranslationUnit ::
+     forall m. MonadIO m
+  => Maybe (CXSourceLocation -> CXSourceLocation -> m Bool)
+#ifdef HAVE_CLANG_ISBEFOREINTRANSLATIONUNIT
+clang_isBeforeInTranslationUnit = Just $ \lhs rhs -> liftIO $
+    onHaskellHeap lhs $ \lhs' ->
+      onHaskellHeap rhs $ \rhs' ->
+        cToBool <$> wrap_isBeforeInTranslationUnit lhs' rhs'
+#else
+clang_isBeforeInTranslationUnit = Nothing
+  where
+    -- Trick the compiler into thinking @MonadIO m@ is not a redundant
+    -- constraint
+    _unused :: ()
+    _unused = const () $ liftIO @m
+#endif
+
+-- | Retrieve the file, line, column, and offset represented by the given source
+-- location.
+--
+-- If the location refers into a macro expansion, return where the macro was
+-- expanded or where the macro argument was written, if the location points at a
+-- macro argument.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gae0ee9ff0ea04f2446832fc12a7fd2ac8>
+clang_getFileLocation ::
+     MonadIO m
+  => CXSourceLocation
+  -> m (CXFile, CUInt, CUInt, CUInt)
+clang_getFileLocation location = liftIO $
+    onHaskellHeap location $ \location' ->
+      alloca $ \file ->
+      alloca $ \line ->
+      alloca $ \column ->
+      alloca $ \offset -> do
+        wrap_getFileLocation location' file line column offset
+        (,,,) <$> peek file <*> peek line <*> peek column <*> peek offset
+
+-- | Retrieves the source location associated with a given file/line/column in a
+-- particular translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#ga86d822034407d60d9e1f36e07cbc0f67>
+clang_getLocation ::
+     MonadIO m
+  => CXTranslationUnit
+  -> CXFile
+  -> CUInt   -- ^ Line
+  -> CUInt   -- ^ Column
+  -> m CXSourceLocation
+clang_getLocation unit file line col = liftIO $
+    preallocate_ $ wrap_getLocation unit file line col
+
+-- | Retrieve a source range given the beginning and ending source locations.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#ga4e2b6d439f72fdee12c2e4dcf4ff1e2f>
+clang_getRange ::
+     MonadIO m
+  => CXSourceLocation -> CXSourceLocation -> m CXSourceRange
+clang_getRange begin end = liftIO $
+    onHaskellHeap begin $ \begin' ->
+    onHaskellHeap end   $ \end' ->
+      preallocate_ $ wrap_getRange begin' end'
+
+-- | Retrieve a file handle within the given translation unit.
+--
+-- Returns the file handle for the named file in the translation unit.
+-- Throws 'CallFailed' if the file was not a part of this translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gaa0554e2ea48ecd217a29314d3cbd2085>
+clang_getFile ::
+     (MonadIO m, HasCallStack)
+  => CXTranslationUnit -> Text -> m CXFile
+clang_getFile unit file = liftIO $ ensureNotNull' $
+    withCString (Text.unpack file) $ \file' ->
+      nowrapper_getFile unit (ConstPtr file')
+  where
+    ensureNotNull' :: IO CXFile -> IO CXFile
+    ensureNotNull' call = do
+        x <- call
+        if not (isNullPtr x)
+          then return x
+          else callFailed $ concat [
+                   show file
+                 , " is not a part of this translation unit"
+                 ]
+
+-- | Check if the given source location is in the main file of the corresponding
+-- translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html#gacb4ca7b858d66f0205797ae84cc4e8f2>
+clang_Location_isFromMainFile :: MonadIO m => CXSourceLocation -> m Bool
+clang_Location_isFromMainFile location = liftIO $
+    onHaskellHeap location $ \location' ->
+      cToBool <$> wrap_Location_isFromMainFile location'
+
+{-------------------------------------------------------------------------------
+  File manipulation routines
+
+  <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html>
+-------------------------------------------------------------------------------}
+
+-- | Retrieve the complete file and path name of the given file.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html#ga626ff6335ab1e0a2b8c8823301225690>
+clang_getFileName :: MonadIO m => CXFile -> m Text
+clang_getFileName file = liftIO $ preallocate_$ wrap_getFileName file
+
+-- | Retrieve the contents of the given file that is loaded in the given
+-- translation unit.
+--
+-- Returns 'Nothing' if the file is not loaded.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#ga66e2b8da5d762063c3ff3f44bf1071a7>
+clang_getFileContents ::
+     MonadIO m
+  => CXTranslationUnit -> CXFile -> m (Maybe Text)
+clang_getFileContents unit file = liftIO $
+    alloca $ \sizePtr -> do
+      cptr <- nowrapper_getFileContents unit file sizePtr
+      let ptr = unConstPtr cptr
+      if ptr == nullPtr then
+        pure Nothing
+      else do
+        size <- peek sizePtr
+        -- Go via ByteString to avoid the intermediate [Char] linked list
+        -- that peekCStringLen + Text.pack would allocate.
+        bs <- ByteString.unsafePackCStringLen (ptr, fromIntegral size)
+        pure . Just $ Text.Encoding.decodeUtf8 bs
+
+{-------------------------------------------------------------------------------
+  Debugging
+-------------------------------------------------------------------------------}
+
+foreign import capi "clang_wrappers.h clang_breakpoint"
+  nowrapper_breakpoint :: IO ()
+
+-- | Debugging breakpoint hook
+--
+-- Every call to @clang_breakpoint@ prints
+--
+-- > clang_breakpoint: <count>
+--
+-- to @stderr@, for an ever increasing @<count>@ (starting at 1). This is useful
+-- for debugging; for example, if you want a breakpoint on the 13th invocation:
+--
+-- > break clang_breakpoint
+-- > ignore 1 12
+clang_breakpoint :: MonadIO m => m ()
+clang_breakpoint = liftIO $ nowrapper_breakpoint
+
+{-------------------------------------------------------------------------------
+  Rewrite API
+-------------------------------------------------------------------------------}
+
+-- | An opaque type representing a Clang rewriter
+--
+-- <https://clang.llvm.org/doxygen/Rewrite_8h.html>
+newtype {-# CType "CXRewriter" #-} CXRewriter = CXRewriter (Ptr ())
+  deriving stock (Show)
+
+foreign import capi unsafe "rewrite_wrappers.h clang_CXRewriter_create"
+  nowrapper_CXRewriter_create :: CXTranslationUnit -> IO CXRewriter
+
+foreign import capi unsafe "rewrite_wrappers.h wrap_CXRewriter_insertTextBefore"
+  wrap_CXRewriter_insertTextBefore ::
+       CXRewriter
+    -> R CXSourceLocation_
+    -> CString
+    -> IO ()
+
+foreign import capi unsafe "rewrite_wrappers.h clang_CXRewriter_writeMainFileToStdOut"
+  nowrapper_CXRewriter_writeMainFileToStdOut :: CXRewriter -> IO ()
+
+foreign import capi unsafe "rewrite_wrappers.h clang_CXRewriter_dispose"
+  nowrapper_CXRewriter_dispose :: CXRewriter -> IO ()
+
+clang_CXRewriter_create :: MonadIO m => CXTranslationUnit -> m CXRewriter
+clang_CXRewriter_create = liftIO . nowrapper_CXRewriter_create
+
+clang_CXRewriter_insertTextBefore ::
+     MonadIO m
+  => CXRewriter
+  -> CXSourceLocation
+  -> Text
+  -> m ()
+clang_CXRewriter_insertTextBefore rewriter loc text = liftIO $
+    onHaskellHeap loc $ \loc' ->
+      withCString (Text.unpack text) $
+        wrap_CXRewriter_insertTextBefore rewriter loc'
+
+clang_CXRewriter_writeMainFileToStdOut :: MonadIO m => CXRewriter -> m ()
+clang_CXRewriter_writeMainFileToStdOut =
+    liftIO . nowrapper_CXRewriter_writeMainFileToStdOut
+
+clang_CXRewriter_dispose :: MonadIO m => CXRewriter -> m ()
+clang_CXRewriter_dispose = liftIO . nowrapper_CXRewriter_dispose
+
+{-------------------------------------------------------------------------------
+  Auxiliary
+-------------------------------------------------------------------------------}
+
+ensureValidType :: HasCallStack => IO CXType -> IO CXType
+ensureValidType = ensure (aux . fromSimpleEnum . cxtKind)
+  where
+    aux :: Either CInt CXTypeKind -> Bool
+    aux (Left _)               = False
+    aux (Right CXType_Invalid) = False
+    aux _otherwise             = True
+
+-- | Memoised call to 'clang_getNullCursor'.
+nullCursor :: CXCursor
+nullCursor = unsafePerformIO clang_getNullCursor
+{-# NOINLINE nullCursor #-}
diff --git a/src/Clang/LowLevel/Core/Enums.hs b/src/Clang/LowLevel/Core/Enums.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Core/Enums.hs
@@ -0,0 +1,1395 @@
+-- | Haskell equivalent of C enums using in @libclang@
+--
+-- This module should only be imported by "Clang.LowLevel.Core".
+module Clang.LowLevel.Core.Enums (
+    CXErrorCode(..)
+  , CXTranslationUnit_Flags(..)
+  , CXTypeKind(..)
+  , CXChildVisitResult(..)
+  , CXTypeLayoutError(..)
+  , CXTokenKind(..)
+  , CXCursorKind(..)
+  , CXDiagnosticDisplayOptions(..)
+  , CXDiagnosticSeverity(..)
+  , CX_StorageClass(..)
+  , CXLinkageKind(..)
+  , CXTLSKind(..)
+  , CXVisibilityKind(..)
+  , CXAvailabilityKind(..)
+  , CXEvalResultKind(..)
+  ) where
+
+import GHC.Generics (Generic)
+
+{-------------------------------------------------------------------------------
+  CXErrorCode
+-------------------------------------------------------------------------------}
+
+-- | Error codes returned by @libclang@ routines.
+--
+-- NOTE: The docs state:
+--
+-- > Zero (CXError_Success) is the only error code indicating success. Other
+-- > error codes, including not yet assigned non-zero values, indicate errors.
+--
+-- Since we want to reserve 'CXErrorCode' for actual errors, we omit
+-- @CXError_Success@, and define 'IsSimpleEnum' for both @CXErrorCode@ and
+-- @Maybe CXErrorCode@.
+data CXErrorCode =
+    -- | A generic error code, no further details are available.
+    --
+    -- Errors of this kind can get their own specific error codes in future
+    -- libclang versions.
+    CXError_Failure
+
+    -- | @libclang@ crashed while performing the requested operation.
+  | CXError_Crashed
+
+    -- | The function detected that the arguments violate the function contract.
+  | CXError_InvalidArguments
+
+    -- | An AST deserialization error has occurred.
+  | CXError_ASTReadError
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXTranslationUnit_Flag
+-------------------------------------------------------------------------------}
+
+-- | Flags that control the creation of translation units.
+--
+-- The enumerators in this enumeration type are meant to be bitwise ORed
+-- together to specify which options should be used when constructing the
+-- translation unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#gab1e4965c1ebe8e41d71e90203a723fe9>
+data CXTranslationUnit_Flags =
+    -- | Used to indicate that no special translation-unit options are needed.
+    CXTranslationUnit_None
+
+    -- | Used to indicate that the parser should construct a "detailed"
+    -- preprocessing record, including all macro definitions and instantiations.
+    --
+    -- Constructing a detailed preprocessing record requires more memory and
+    -- time to parse, since the information contained in the record is usually
+    -- not retained. However, it can be useful for applications that require
+    -- more detailed information about the behavior of the preprocessor.
+  | CXTranslationUnit_DetailedPreprocessingRecord
+
+    -- | Used to indicate that the translation unit is incomplete.
+    --
+    -- When a translation unit is considered "incomplete", semantic analysis
+    -- that is typically performed at the end of the translation unit will be
+    -- suppressed. For example, this suppresses the completion of tentative
+    -- declarations in C and of instantiation of implicitly-instantiation
+    -- function templates in C++. This option is typically used when parsing a
+    -- header with the intent of producing a precompiled header.
+  | CXTranslationUnit_Incomplete
+
+    -- | Used to indicate that the translation unit should be built with an
+    -- implicit precompiled header for the preamble.
+    --
+    -- An implicit precompiled header is used as an optimization when a
+    -- particular translation unit is likely to be reparsed many times when the
+    -- sources aren't changing that often. In this case, an implicit precompiled
+    -- header will be built containing all of the initial includes at the top of
+    -- the main file (what we refer to as the "preamble" of the file). In
+    -- subsequent parses, if the preamble or the files in it have not changed,
+    -- @clang_reparseTranslationUnit@ will re-use the implicit precompiled
+    -- header to improve parsing performance.
+  | CXTranslationUnit_PrecompiledPreamble
+
+    -- | Used to indicate that the translation unit should cache some
+    -- code-completion results with each reparse of the source file.
+    --
+    -- Caching of code-completion results is a performance optimization that
+    -- introduces some overhead to reparsing but improves the performance of
+    -- code-completion operations.
+  | CXTranslationUnit_CacheCompletionResults
+
+    -- | Used to indicate that the translation unit will be serialized with
+    -- @clang_saveTranslationUnit@. (Not currently exposed by this library.)
+    --
+    -- This option is typically used when parsing a header with the intent of
+    -- producing a precompiled header.
+  | CXTranslationUnit_ForSerialization
+
+    -- | Used to indicate that function/method bodies should be skipped while
+    -- parsing.
+    --
+    -- This option can be used to search for declarations/definitions while
+    -- ignoring the usages.
+  | CXTranslationUnit_SkipFunctionBodies
+
+    -- | Used to indicate that brief documentation comments should be included
+    -- into the set of code completions returned from this translation unit.
+  | CXTranslationUnit_IncludeBriefCommentsInCodeCompletion
+
+    -- | Used to indicate that the precompiled preamble should be created on the
+    -- first parse. Otherwise it will be created on the first reparse. This
+    -- trades runtime on the first parse (serializing the preamble takes time)
+    -- for reduced runtime on the second parse (can now reuse the preamble).
+  | CXTranslationUnit_CreatePreambleOnFirstParse
+
+    -- | Do not stop processing when fatal errors are encountered.
+    --
+    -- When fatal errors are encountered while parsing a translation unit,
+    -- semantic analysis is typically stopped early when compiling code. A
+    -- common source for fatal errors are unresolvable include files. For the
+    -- purposes of an IDE, this is undesirable behavior and as much information
+    -- as possible should be reported. Use this flag to enable this behavior.
+  | CXTranslationUnit_KeepGoing
+
+    -- | Sets the preprocessor in a mode for parsing a single file only.
+  | CXTranslationUnit_SingleFileParse
+
+    -- | Used in combination with 'CXTranslationUnit_SkipFunctionBodies' to
+    -- constrain the skipping of function bodies to the preamble.
+    --
+    -- The function bodies of the main file are not skipped.
+  | CXTranslationUnit_LimitSkipFunctionBodiesToPreamble
+
+    -- | Used to indicate that attributed types should be included in CXType.
+  | CXTranslationUnit_IncludeAttributedTypes
+
+    -- | Used to indicate that implicit attributes should be visited.
+  | CXTranslationUnit_VisitImplicitAttributes
+
+    -- | Used to indicate that non-errors from included files should be ignored.
+    --
+    -- If set, @clang_getDiagnosticSetFromTU@ will not report e.g. warnings from
+    -- included files anymore. This speeds up @clang_getDiagnosticSetFromTU@ for
+    -- the case where these warnings are not of interest, as for an IDE for
+    -- example, which typically shows only the diagnostics in the main file.
+    -- (Not currently exposed by this library.)
+  | CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles
+
+    -- | Tells the preprocessor not to skip excluded conditional blocks.
+  | CXTranslationUnit_RetainExcludedConditionalBlocks
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXTypeKind
+-------------------------------------------------------------------------------}
+
+-- | Describes the kind of type
+--
+-- NOTE: This definition is not complete; we omit kinds for
+--
+-- * OpenCL
+-- * HLSL
+-- * BPF/BTF
+--
+-- We don't need them, and by omitting them we are compatible with a larger
+-- range of @libclang@ versions.
+--
+-- NOTE: We omit @CXType_FirstBuiltin@ and @CXType_LastBuiltin@, which are
+-- aliases for the first and last builtin type in the list, respectively. If
+-- we need them, we should define them as separate constants.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaad39de597b13a18882c21860f92b095a>
+data CXTypeKind =
+    -- | Represents an invalid type (e.g., where no type is available).
+    CXType_Invalid
+
+    -- | A type whose specific kind is not exposed via this interface.
+  | CXType_Unexposed
+
+    --
+    -- Builtin types
+    --
+
+  | CXType_Void
+  | CXType_Bool
+  | CXType_Char_U
+  | CXType_UChar
+  | CXType_Char16
+  | CXType_Char32
+  | CXType_UShort
+  | CXType_UInt
+  | CXType_ULong
+  | CXType_ULongLong
+  | CXType_UInt128
+  | CXType_Char_S
+  | CXType_SChar
+  | CXType_WChar
+  | CXType_Short
+  | CXType_Int
+  | CXType_Long
+  | CXType_LongLong
+  | CXType_Int128
+  | CXType_Float
+  | CXType_Double
+  | CXType_LongDouble
+  | CXType_NullPtr
+  | CXType_Overload
+  | CXType_Dependent
+  | CXType_ObjCId
+  | CXType_ObjCClass
+  | CXType_ObjCSel
+  | CXType_Float128
+  | CXType_Half
+  | CXType_Float16
+  | CXType_ShortAccum
+  | CXType_Accum
+  | CXType_LongAccum
+  | CXType_UShortAccum
+  | CXType_UAccum
+  | CXType_ULongAccum
+  | CXType_BFloat16
+  | CXType_Ibm128
+
+  | CXType_Complex
+  | CXType_Pointer
+  | CXType_BlockPointer
+  | CXType_LValueReference
+  | CXType_RValueReference
+  | CXType_Record
+  | CXType_Enum
+  | CXType_Typedef
+  | CXType_ObjCInterface
+  | CXType_ObjCObjectPointer
+  | CXType_FunctionNoProto
+  | CXType_FunctionProto
+  | CXType_ConstantArray
+  | CXType_Vector
+  | CXType_IncompleteArray
+  | CXType_VariableArray
+  | CXType_DependentSizedArray
+  | CXType_MemberPointer
+  | CXType_Auto
+
+    -- | Represents a type that was referred to using an elaborated type keyword.
+    -- E.g., @struct S@, or via a qualified name, e.g., @N::M::type@, or both.
+  | CXType_Elaborated
+
+  | CXType_ObjCObject
+  | CXType_ObjCTypeParam
+  | CXType_Attributed
+
+  | CXType_ExtVector
+  | CXType_Atomic
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXChildVisitResult
+-------------------------------------------------------------------------------}
+
+-- | Describes how the traversal of the children of a particular cursor should
+-- proceed after visiting a particular child cursor.
+--
+-- A value of this enumeration type should be returned by each 'CXCursorVisitor'
+-- to indicate how 'clang_visitChildren' proceed.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html#ga99a9058656e696b622fbefaf5207d715>
+data CXChildVisitResult =
+    -- | Terminates the cursor traversal.
+    CXChildVisit_Break
+
+    -- | Continues the cursor traversal with the next sibling of the cursor just
+    -- visited, without visiting its children.
+  | CXChildVisit_Continue
+
+    -- | Recursively traverse the children of this cursor, using the same
+    -- visitor and client data.
+  | CXChildVisit_Recurse
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXTypeLayoutError
+-------------------------------------------------------------------------------}
+
+-- | List the possible error codes for 'clang_Type_getSizeOf',
+-- 'clang_Type_getAlignOf', 'clang_Type_getOffsetOf' and
+-- 'clang_Cursor_getOffsetOfField'.
+--
+-- A value of this enumeration type can be returned if the target type is not a
+-- valid argument to @sizeof@, @alignof@ or @offsetof@.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#gaaf1b95e9e7e792a08654563fef7502c1>
+data CXTypeLayoutError =
+    -- | Type is of kind 'CXType_Invalid'.
+    CXTypeLayoutError_Invalid
+
+     -- | The type is an incomplete Type.
+  | CXTypeLayoutError_Incomplete
+
+    -- | The type is a dependent Type.
+  | CXTypeLayoutError_Dependent
+
+    -- | The type is not a constant size type.
+  | CXTypeLayoutError_NotConstantSize
+
+    -- | The Field name is not valid for this record.
+  | CXTypeLayoutError_InvalidFieldName
+
+    -- | The type is undeduced.
+  | CXTypeLayoutError_Undeduced
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXTokenKind
+-------------------------------------------------------------------------------}
+
+-- | Describes a kind of token.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html#gaf63e37eee4280e2c039829af24bbc201>
+data CXTokenKind =
+    -- | A token that contains some kind of punctuation.
+    CXToken_Punctuation
+
+    -- | A language keyword.
+  | CXToken_Keyword
+
+    -- | An identifier (that is not a keyword).
+  | CXToken_Identifier
+
+    -- | A numeric, string, or character literal.
+  | CXToken_Literal
+
+    -- | A comment.
+  | CXToken_Comment
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXCursorKind
+-------------------------------------------------------------------------------}
+
+-- | Describes the kind of entity that a cursor refers to.
+--
+-- Notes:
+--
+-- * We only include constants available in @llvm-14@ and up.
+-- * We omit the various first and last markers (e.g., @CXCursor_FirstExpr@ and
+--   @CXCursor_LastExpr@); if we need them, we should define them as separate
+--   constants.
+-- * We omit aliases (such as @CXCursor_AsmStmt@, an alias for
+--   'CXCursor_GCCAsmStmt').
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gaaccc432245b4cd9f2d470913f9ef0013>
+data CXCursorKind =
+    --
+    -- Declarations
+    --
+
+    -- | A declaration whose specific kind is not exposed via this interface.
+    --
+    -- Unexposed declarations have the same operations as any other kind of
+    -- declaration; one can extract their location information, spelling, find
+    -- their definitions, etc. However, the specific kind of the declaration is
+    -- not reported.
+    CXCursor_UnexposedDecl
+
+    -- | A C or C++ struct.
+  | CXCursor_StructDecl
+
+    -- | A C or C++ union.
+  | CXCursor_UnionDecl
+
+    -- | A C++ class.
+  | CXCursor_ClassDecl
+
+    -- | An enumeration.
+  | CXCursor_EnumDecl
+
+    -- | A field (in C) or non-static data member (in C++) in a struct, union,
+    -- or C++ class.
+  | CXCursor_FieldDecl
+
+    -- | An enumerator constant.
+  | CXCursor_EnumConstantDecl
+
+    -- | A function.
+  | CXCursor_FunctionDecl
+
+    -- | A variable.
+  | CXCursor_VarDecl
+
+    -- | A function or method parameter.
+  | CXCursor_ParmDecl
+
+    -- | An Objective-C \@interface.
+  | CXCursor_ObjCInterfaceDecl
+
+    -- | An Objective-C \@interface for a category.
+  | CXCursor_ObjCCategoryDecl
+
+    -- | An Objective-C \@protocol declaration.
+  | CXCursor_ObjCProtocolDecl
+
+    -- | An Objective-C \@property declaration.
+  | CXCursor_ObjCPropertyDecl
+
+    -- | An Objective-C instance variable.
+  | CXCursor_ObjCIvarDecl
+
+    -- | An Objective-C instance method.
+  | CXCursor_ObjCInstanceMethodDecl
+
+    -- | An Objective-C class method.
+  | CXCursor_ObjCClassMethodDecl
+
+    -- | An Objective-C \@implementation.
+  | CXCursor_ObjCImplementationDecl
+
+    -- | An Objective-C \@implementation for a category.
+  | CXCursor_ObjCCategoryImplDecl
+
+    -- | A typedef.
+  | CXCursor_TypedefDecl
+
+    -- | A C++ class method.
+  | CXCursor_CXXMethod
+
+    -- | A C++ namespace.
+  | CXCursor_Namespace
+
+    -- | A linkage specification, e.g. 'extern "C"'.
+  | CXCursor_LinkageSpec
+
+    -- | A C++ constructor.
+  | CXCursor_Constructor
+
+    -- | A C++ destructor.
+  | CXCursor_Destructor
+
+    -- | A C++ conversion function.
+  | CXCursor_ConversionFunction
+
+    -- | A C++ template type parameter.
+  | CXCursor_TemplateTypeParameter
+
+    -- | A C++ non-type template parameter.
+  | CXCursor_NonTypeTemplateParameter
+
+    -- | A C++ template template parameter.
+  | CXCursor_TemplateTemplateParameter
+
+    -- | A C++ function template.
+  | CXCursor_FunctionTemplate
+
+    -- | A C++ class template.
+  | CXCursor_ClassTemplate
+
+    -- | A C++ class template partial specialization.
+  | CXCursor_ClassTemplatePartialSpecialization
+
+    -- | A C++ namespace alias declaration.
+  | CXCursor_NamespaceAlias
+
+    -- | A C++ using directive.
+  | CXCursor_UsingDirective
+
+    -- | A C++ using declaration.
+  | CXCursor_UsingDeclaration
+
+    -- | A C++ alias declaration
+  | CXCursor_TypeAliasDecl
+
+    -- | An Objective-C \@synthesize definition.
+  | CXCursor_ObjCSynthesizeDecl
+
+    -- | An Objective-C \@dynamic definition.
+  | CXCursor_ObjCDynamicDecl
+
+    -- | An access specifier.
+  | CXCursor_CXXAccessSpecifier
+
+    --
+    -- References
+    --
+
+  | CXCursor_ObjCSuperClassRef
+  | CXCursor_ObjCProtocolRef
+  | CXCursor_ObjCClassRef
+
+    -- | A reference to a type declaration.
+    --
+    -- A type reference occurs anywhere where a type is named but not declared.
+    -- For example, given:
+    --
+    -- > typedef unsigned size_type;
+    -- > size_type size;
+    --
+    -- The typedef is a declaration of @size_type@ ('CXCursor_TypedefDecl'),
+    -- while the type of the variable \"size\" is referenced. The cursor
+    -- referenced by the type of size is the typedef for @size_type@.
+  | CXCursor_TypeRef
+
+  | CXCursor_CXXBaseSpecifier
+
+    -- | A reference to a class template, function template, template template
+    -- parameter, or class template partial specialization.
+  | CXCursor_TemplateRef
+
+    -- | A reference to a namespace or namespace alias.
+  | CXCursor_NamespaceRef
+
+    -- | A reference to a member of a struct, union, or class that occurs in
+    -- some non-expression context, e.g., a designated initializer.
+  | CXCursor_MemberRef
+
+    -- | A reference to a labeled statement.
+    --
+    -- This cursor kind is used to describe the jump to \"start_over\" in the
+    -- goto statement in the following example:
+    --
+    -- > start_over:
+    -- >   ++counter;
+    -- >
+    -- >   goto start_over;
+    --
+    -- A label reference cursor refers to a label statement.
+  | CXCursor_LabelRef
+
+    -- | A reference to a set of overloaded functions or function templates that
+    -- has not yet been resolved to a specific function or function template.
+    --
+    -- An overloaded declaration reference cursor occurs in C++ templates where
+    -- a dependent name refers to a function. For example:
+    --
+    -- > template<typename T> void swap(T&, T&);
+    -- >
+    -- > struct X { ... };
+    -- > void swap(X&, X&);
+    -- >
+    -- > template<typename T>
+    -- > void reverse(T* first, T* last) {
+    -- >   while (first < last - 1) {
+    -- >     swap(*first, *--last);
+    -- >     ++first;
+    -- >   }
+    -- > }
+    -- >
+    -- > struct Y { };
+    -- > void swap(Y&, Y&);
+    --
+    -- Here, the identifier \"swap\" is associated with an overloaded
+    -- declaration reference. In the template definition, \"swap\" refers to
+    -- either of the two "\swap\" functions declared above, so both results will
+    -- be available. At instantiation time, \"swap\" may also refer to other
+    -- functions found via argument-dependent lookup (e.g., the \"swap\"
+    -- function at the end of the example).
+    --
+    -- The functions @clang_getNumOverloadedDecls@ and @clang_getOverloadedDecl@
+    -- can be used to retrieve the definitions referenced by this cursor. (Not
+    -- currently exposed by this library.)
+  | CXCursor_OverloadedDeclRef
+
+    -- | A reference to a variable that occurs in some non-expression context,
+    -- e.g., a C++ lambda capture list.
+  | CXCursor_VariableRef
+
+    --
+    -- Error conditions
+    --
+
+  | CXCursor_InvalidFile
+  | CXCursor_NoDeclFound
+  | CXCursor_NotImplemented
+  | CXCursor_InvalidCode
+
+    --
+    -- Expressions
+    --
+
+    -- | An expression whose specific kind is not exposed via this interface.
+    --
+    -- Unexposed expressions have the same operations as any other kind of
+    -- expression; one can extract their location information, spelling,
+    -- children, etc. However, the specific kind of the expression is not
+    -- reported.
+  | CXCursor_UnexposedExpr
+
+    -- | An expression that refers to some value declaration, such as a
+    -- function, variable, or enumerator.
+  | CXCursor_DeclRefExpr
+
+    -- | An expression that refers to a member of a struct, union, class,
+    -- Objective-C class, etc.
+  | CXCursor_MemberRefExpr
+
+   -- | An expression that calls a function.
+  | CXCursor_CallExpr
+
+   -- | An expression that sends a message to an Objective-C object or class.
+  | CXCursor_ObjCMessageExpr
+
+   -- | An expression that represents a block literal.
+  | CXCursor_BlockExpr
+
+   -- | An integer literal.
+  | CXCursor_IntegerLiteral
+
+   -- | A floating point number literal.
+  | CXCursor_FloatingLiteral
+
+   -- | An imaginary number literal.
+  | CXCursor_ImaginaryLiteral
+
+   -- | A string literal.
+  | CXCursor_StringLiteral
+
+   -- | A character literal.
+  | CXCursor_CharacterLiteral
+
+   -- | A parenthesized expression, e.g. @"(1)"@.
+   --
+   -- This AST node is only formed if full location information is requested.
+  | CXCursor_ParenExpr
+
+   -- | This represents the unary-expression's (except sizeof and alignof).
+  | CXCursor_UnaryOperator
+
+   -- | [C99 6.5.2.1] Array Subscripting.
+  | CXCursor_ArraySubscriptExpr
+
+   -- | A builtin binary operation expression such as @"x + y"@ or @"x <= y"@.
+  | CXCursor_BinaryOperator
+
+   -- | Compound assignment such as @"+="@.
+  | CXCursor_CompoundAssignOperator
+
+   -- | The @?:@ ternary operator.
+  | CXCursor_ConditionalOperator
+
+   -- | An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++
+   -- [expr.cast]), which uses the syntax (Type)expr.
+   --
+   -- For example: @(int)f@.
+  | CXCursor_CStyleCastExpr
+
+   -- | [C99 6.5.2.5]
+  | CXCursor_CompoundLiteralExpr
+
+   -- | Describes an C or C++ initializer list.
+  | CXCursor_InitListExpr
+
+   -- | The GNU address of label extension, representing &&label.
+  | CXCursor_AddrLabelExpr
+
+   -- | This is the GNU Statement Expression extension: ({int X=4; X;})
+  | CXCursor_StmtExpr
+
+   -- | Represents a C11 generic selection.
+  | CXCursor_GenericSelectionExpr
+
+   -- | Implements the GNU @__null@ extension, which is a name for a null
+   -- pointer constant that has integral type (e.g., int or long) and is the
+   -- same size and alignment as a pointer.
+   --
+   -- The @__null@ extension is typically only used by system headers, which
+   -- define NULL as @__null@ in C++ rather than using 0 (which is an integer
+   -- that may not match the size of a pointer).
+  | CXCursor_GNUNullExpr
+
+   -- | C++'s static_cast<> expression.
+  | CXCursor_CXXStaticCastExpr
+
+   -- | C++'s dynamic_cast<> expression.
+  | CXCursor_CXXDynamicCastExpr
+
+   -- | C++'s reinterpret_cast<> expression.
+  | CXCursor_CXXReinterpretCastExpr
+
+   -- | C++'s const_cast<> expression.
+  | CXCursor_CXXConstCastExpr
+
+    -- | Represents an explicit C++ type conversion that uses "functional"
+    -- notion (C++ [expr.type.conv]).
+    --
+    -- Example:
+    --
+    -- > x = int(0.5);
+  | CXCursor_CXXFunctionalCastExpr
+
+   -- | A C++ typeid expression (C++ [expr.typeid]).
+  | CXCursor_CXXTypeidExpr
+
+   -- | [C++ 2.13.5] C++ Boolean Literal.
+  | CXCursor_CXXBoolLiteralExpr
+
+   -- | [C++0x 2.14.7] C++ Pointer Literal.
+  | CXCursor_CXXNullPtrLiteralExpr
+
+   -- | Represents the "this" expression in C++
+  | CXCursor_CXXThisExpr
+
+    -- | [C++ 15] C++ Throw Expression.
+    --
+    -- This handles @throw@ and @throw@ assignment-expression. When
+    -- assignment-expression isn't present, Op will be null.
+  | CXCursor_CXXThrowExpr
+
+    -- | A new expression for memory allocation and constructor calls, e.g:
+    -- @"new CXXNewExpr(foo)"@.
+  | CXCursor_CXXNewExpr
+
+   -- | A delete expression for memory deallocation and destructor calls, e.g.
+   -- @"delete[] pArray"@.
+  | CXCursor_CXXDeleteExpr
+
+   -- | A unary expression. (noexcept, sizeof, or other traits)
+  | CXCursor_UnaryExpr
+
+   -- | An Objective-C string literal i.e. @"foo".
+  | CXCursor_ObjCStringLiteral
+
+   -- | An Objective-C \@encode expression.
+  | CXCursor_ObjCEncodeExpr
+
+   -- | An Objective-C \@selector expression.
+  | CXCursor_ObjCSelectorExpr
+
+   -- | An Objective-C \@protocol expression.
+  | CXCursor_ObjCProtocolExpr
+
+    -- | An Objective-C "bridged" cast expression, which casts between
+    -- Objective-C pointers and C pointers, transferring ownership in the
+    -- process.
+    --
+    -- > NSString *str = (__bridge_transfer NSString *)CFCreateString();
+  | CXCursor_ObjCBridgedCastExpr
+
+    -- | Represents a C++0x pack expansion that produces a sequence of
+    -- expressions.
+    --
+    -- A pack expansion expression contains a pattern (which itself is an
+    -- expression) followed by an ellipsis. For example:
+    --
+    -- > template<typename F, typename ...Types>
+    -- > void forward(F f, Types &&...args) {
+    -- >  f(static_cast<Types&&>(args)...);
+    -- > }
+  | CXCursor_PackExpansionExpr
+
+    -- | Represents an expression that computes the length of a parameter pack.
+    --
+    -- > template<typename ...Types>
+    -- > struct count {
+    -- >   static const unsigned value = sizeof...(Types);
+    -- > };
+  | CXCursor_SizeOfPackExpr
+
+    -- | Represents a C++ lambda expression that produces a local function
+    -- object.
+    --
+    -- > void abssort(float *x, unsigned N) {
+    -- >   std::sort(x, x + N,
+    -- >             [](float a, float b) {
+    -- >               return std::abs(a) < std::abs(b);
+    -- >             });
+    -- > }
+  | CXCursor_LambdaExpr
+
+   -- | Objective-c Boolean Literal.
+  | CXCursor_ObjCBoolLiteralExpr
+
+   -- | Represents the "self" expression in an Objective-C method.
+  | CXCursor_ObjCSelfExpr
+
+    -- | Represents an @available(...) check.
+  | CXCursor_ObjCAvailabilityCheckExpr
+
+    -- | Fixed point literal
+  | CXCursor_FixedPointLiteral
+
+    -- | OpenMP 5.0 [2.1.4, Array Shaping].
+  | CXCursor_OMPArrayShapingExpr
+
+    -- | OpenMP 5.0 [2.1.6 Iterators]
+  | CXCursor_OMPIteratorExpr
+
+    -- | OpenCL's addrspace_cast<> expression.
+  | CXCursor_CXXAddrspaceCastExpr
+
+    --
+    -- Statements
+    --
+
+    -- | A statement whose specific kind is not exposed via this interface.
+    --
+    -- Unexposed statements have the same operations as any other kind of
+    -- statement; one can extract their location information, spelling,
+    -- children, etc. However, the specific kind of the statement is not
+    -- reported.
+  | CXCursor_UnexposedStmt
+
+    -- | A labelled statement in a function.
+    --
+    -- This cursor kind is used to describe the "start_over:" label statement in
+    -- the following example:
+    --
+    -- > start_over:
+    -- >   ++counter;
+  | CXCursor_LabelStmt
+
+    -- | A group of statements like @{ stmt stmt }@.
+    --
+    -- This cursor kind is used to describe compound statements, e.g. function
+    -- bodies.
+  | CXCursor_CompoundStmt
+
+    -- | A case statement.
+  | CXCursor_CaseStmt
+
+    -- | A default statement.
+  | CXCursor_DefaultStmt
+
+    -- | An if statement
+  | CXCursor_IfStmt
+
+    -- | A switch statement.
+  | CXCursor_SwitchStmt
+
+    -- | A while statement.
+  | CXCursor_WhileStmt
+
+    -- | A do statement.
+  | CXCursor_DoStmt
+
+    -- | A for statement.
+  | CXCursor_ForStmt
+
+    -- | A goto statement.
+  | CXCursor_GotoStmt
+
+    -- | An indirect goto statement.
+  | CXCursor_IndirectGotoStmt
+
+    -- | A continue statement.
+  | CXCursor_ContinueStmt
+
+    -- | A break statement.
+  | CXCursor_BreakStmt
+
+    -- | A return statement.
+  | CXCursor_ReturnStmt
+
+    -- | A GCC inline assembly statement extension.
+  | CXCursor_GCCAsmStmt
+
+    -- | Objective-C's overall \@try-\@catch-\@finally statement.
+  | CXCursor_ObjCAtTryStmt
+
+    -- | Objective-C's \@catch statement.
+  | CXCursor_ObjCAtCatchStmt
+
+    -- | Objective-C's \@finally statement.
+  | CXCursor_ObjCAtFinallyStmt
+
+    -- | Objective-C's \@throw statement.
+  | CXCursor_ObjCAtThrowStmt
+
+    -- | Objective-C's \@synchronized statement.
+  | CXCursor_ObjCAtSynchronizedStmt
+
+    -- | Objective-C's autorelease pool statement.
+  | CXCursor_ObjCAutoreleasePoolStmt
+
+    -- | Objective-C's collection statement.
+  | CXCursor_ObjCForCollectionStmt
+
+    -- | C++'s catch statement.
+  | CXCursor_CXXCatchStmt
+
+    -- | C++'s try statement.
+  | CXCursor_CXXTryStmt
+
+    -- | C++'s for (* : *) statement.
+  | CXCursor_CXXForRangeStmt
+
+    -- | Windows Structured Exception Handling's try statement.
+  | CXCursor_SEHTryStmt
+
+    -- | Windows Structured Exception Handling's except statement.
+  | CXCursor_SEHExceptStmt
+
+    -- | Windows Structured Exception Handling's finally statement.
+  | CXCursor_SEHFinallyStmt
+
+    -- | A MS inline assembly statement extension.
+  | CXCursor_MSAsmStmt
+
+    -- | The null statement ";": C99 6.8.3p3.
+    --
+    -- This cursor kind is used to describe the null statement.
+  | CXCursor_NullStmt
+
+   -- | Adaptor class for mixing declarations with statements and expressions.
+  | CXCursor_DeclStmt
+
+   -- | OpenMP parallel directive.
+  | CXCursor_OMPParallelDirective
+
+   -- | OpenMP SIMD directive.
+  | CXCursor_OMPSimdDirective
+
+   -- | OpenMP for directive.
+  | CXCursor_OMPForDirective
+
+   -- | OpenMP sections directive.
+  | CXCursor_OMPSectionsDirective
+
+   -- | OpenMP section directive.
+  | CXCursor_OMPSectionDirective
+
+   -- | OpenMP single directive.
+  | CXCursor_OMPSingleDirective
+
+   -- | OpenMP parallel for directive.
+  | CXCursor_OMPParallelForDirective
+
+   -- | OpenMP parallel sections directive.
+  | CXCursor_OMPParallelSectionsDirective
+
+   -- | OpenMP task directive.
+  | CXCursor_OMPTaskDirective
+
+   -- | OpenMP master directive.
+  | CXCursor_OMPMasterDirective
+
+   -- | OpenMP critical directive.
+  | CXCursor_OMPCriticalDirective
+
+   -- | OpenMP taskyield directive.
+  | CXCursor_OMPTaskyieldDirective
+
+   -- | OpenMP barrier directive.
+  | CXCursor_OMPBarrierDirective
+
+   -- | OpenMP taskwait directive.
+  | CXCursor_OMPTaskwaitDirective
+
+   -- | OpenMP flush directive.
+  | CXCursor_OMPFlushDirective
+
+   -- | Windows Structured Exception Handling's leave statement.
+  | CXCursor_SEHLeaveStmt
+
+   -- | OpenMP ordered directive.
+  | CXCursor_OMPOrderedDirective
+
+   -- | OpenMP atomic directive.
+  | CXCursor_OMPAtomicDirective
+
+   -- | OpenMP for SIMD directive.
+  | CXCursor_OMPForSimdDirective
+
+   -- | OpenMP parallel for SIMD directive.
+  | CXCursor_OMPParallelForSimdDirective
+
+   -- | OpenMP target directive.
+  | CXCursor_OMPTargetDirective
+
+   -- | OpenMP teams directive.
+  | CXCursor_OMPTeamsDirective
+
+   -- | OpenMP taskgroup directive.
+  | CXCursor_OMPTaskgroupDirective
+
+   -- | OpenMP cancellation point directive.
+  | CXCursor_OMPCancellationPointDirective
+
+   -- | OpenMP cancel directive.
+  | CXCursor_OMPCancelDirective
+
+   -- | OpenMP target data directive.
+  | CXCursor_OMPTargetDataDirective
+
+   -- | OpenMP taskloop directive.
+  | CXCursor_OMPTaskLoopDirective
+
+   -- | OpenMP taskloop simd directive.
+  | CXCursor_OMPTaskLoopSimdDirective
+
+   -- | OpenMP distribute directive.
+  | CXCursor_OMPDistributeDirective
+
+   -- | OpenMP target enter data directive.
+  | CXCursor_OMPTargetEnterDataDirective
+
+   -- | OpenMP target exit data directive.
+  | CXCursor_OMPTargetExitDataDirective
+
+   -- | OpenMP target parallel directive.
+  | CXCursor_OMPTargetParallelDirective
+
+   -- | OpenMP target parallel for directive.
+  | CXCursor_OMPTargetParallelForDirective
+
+   -- | OpenMP target update directive.
+  | CXCursor_OMPTargetUpdateDirective
+
+   -- | OpenMP distribute parallel for directive.
+  | CXCursor_OMPDistributeParallelForDirective
+
+   -- | OpenMP distribute parallel for simd directive.
+  | CXCursor_OMPDistributeParallelForSimdDirective
+
+   -- | OpenMP distribute simd directive.
+  | CXCursor_OMPDistributeSimdDirective
+
+   -- | OpenMP target parallel for simd directive.
+  | CXCursor_OMPTargetParallelForSimdDirective
+
+   -- | OpenMP target simd directive.
+  | CXCursor_OMPTargetSimdDirective
+
+   -- | OpenMP teams distribute directive.
+  | CXCursor_OMPTeamsDistributeDirective
+
+   -- | OpenMP teams distribute simd directive.
+  | CXCursor_OMPTeamsDistributeSimdDirective
+
+   -- | OpenMP teams distribute parallel for simd directive.
+  | CXCursor_OMPTeamsDistributeParallelForSimdDirective
+
+   -- | OpenMP teams distribute parallel for directive.
+  | CXCursor_OMPTeamsDistributeParallelForDirective
+
+   -- | OpenMP target teams directive.
+  | CXCursor_OMPTargetTeamsDirective
+
+   -- | OpenMP target teams distribute directive.
+  | CXCursor_OMPTargetTeamsDistributeDirective
+
+   -- | OpenMP target teams distribute parallel for directive.
+  | CXCursor_OMPTargetTeamsDistributeParallelForDirective
+
+   -- | OpenMP target teams distribute parallel for simd directive.
+  | CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective
+
+   -- | OpenMP target teams distribute simd directive.
+  | CXCursor_OMPTargetTeamsDistributeSimdDirective
+
+   -- | C++2a std::bit_cast expression.
+  | CXCursor_BuiltinBitCastExpr
+
+   -- | OpenMP master taskloop directive.
+  | CXCursor_OMPMasterTaskLoopDirective
+
+   -- | OpenMP parallel master taskloop directive.
+  | CXCursor_OMPParallelMasterTaskLoopDirective
+
+   -- | OpenMP master taskloop simd directive.
+  | CXCursor_OMPMasterTaskLoopSimdDirective
+
+   -- | OpenMP parallel master taskloop simd directive.
+  | CXCursor_OMPParallelMasterTaskLoopSimdDirective
+
+   -- | OpenMP parallel master directive.
+  | CXCursor_OMPParallelMasterDirective
+
+   -- | OpenMP depobj directive.
+  | CXCursor_OMPDepobjDirective
+
+   -- | OpenMP scan directive.
+  | CXCursor_OMPScanDirective
+
+   -- | OpenMP tile directive.
+  | CXCursor_OMPTileDirective
+
+   -- | OpenMP canonical loop.
+  | CXCursor_OMPCanonicalLoop
+
+   -- | OpenMP interop directive.
+  | CXCursor_OMPInteropDirective
+
+   -- | OpenMP dispatch directive.
+  | CXCursor_OMPDispatchDirective
+
+   -- | OpenMP masked directive.
+  | CXCursor_OMPMaskedDirective
+
+   -- | OpenMP unroll directive.
+  | CXCursor_OMPUnrollDirective
+
+   -- | OpenMP metadirective directive.
+  | CXCursor_OMPMetaDirective
+
+   -- | OpenMP loop directive.
+  | CXCursor_OMPGenericLoopDirective
+
+    -- | Cursor that represents the translation unit itself.
+    --
+    -- The translation unit cursor exists primarily to act as the root cursor
+    -- for traversing the contents of a translation unit.
+  | CXCursor_TranslationUnit
+
+    --
+    -- Attributes
+    --
+
+    -- | An attribute whose specific kind is not exposed via this interface.
+  | CXCursor_UnexposedAttr
+
+  | CXCursor_IBActionAttr
+  | CXCursor_IBOutletAttr
+  | CXCursor_IBOutletCollectionAttr
+  | CXCursor_CXXFinalAttr
+  | CXCursor_CXXOverrideAttr
+  | CXCursor_AnnotateAttr
+  | CXCursor_AsmLabelAttr
+  | CXCursor_PackedAttr
+  | CXCursor_PureAttr
+  | CXCursor_ConstAttr
+  | CXCursor_NoDuplicateAttr
+  | CXCursor_CUDAConstantAttr
+  | CXCursor_CUDADeviceAttr
+  | CXCursor_CUDAGlobalAttr
+  | CXCursor_CUDAHostAttr
+  | CXCursor_CUDASharedAttr
+  | CXCursor_VisibilityAttr
+  | CXCursor_DLLExport
+  | CXCursor_DLLImport
+  | CXCursor_NSReturnsRetained
+  | CXCursor_NSReturnsNotRetained
+  | CXCursor_NSReturnsAutoreleased
+  | CXCursor_NSConsumesSelf
+  | CXCursor_NSConsumed
+  | CXCursor_ObjCException
+  | CXCursor_ObjCNSObject
+  | CXCursor_ObjCIndependentClass
+  | CXCursor_ObjCPreciseLifetime
+  | CXCursor_ObjCReturnsInnerPointer
+  | CXCursor_ObjCRequiresSuper
+  | CXCursor_ObjCRootClass
+  | CXCursor_ObjCSubclassingRestricted
+  | CXCursor_ObjCExplicitProtocolImpl
+  | CXCursor_ObjCDesignatedInitializer
+  | CXCursor_ObjCRuntimeVisible
+  | CXCursor_ObjCBoxable
+  | CXCursor_FlagEnum
+  | CXCursor_ConvergentAttr
+  | CXCursor_WarnUnusedAttr
+  | CXCursor_WarnUnusedResultAttr
+  | CXCursor_AlignedAttr
+
+    --
+    -- Preprocessing
+    --
+
+  | CXCursor_PreprocessingDirective
+  | CXCursor_MacroDefinition
+  | CXCursor_MacroExpansion
+  | CXCursor_InclusionDirective
+
+    --
+    -- Extra Declarations
+    --
+
+    -- | A module import declaration.
+  | CXCursor_ModuleImportDecl
+
+  | CXCursor_TypeAliasTemplateDecl
+
+   -- | A static_assert or _Static_assert node
+  | CXCursor_StaticAssert
+
+   -- | a friend declaration.
+  | CXCursor_FriendDecl
+
+    -- | A code completion overload candidate.
+  | CXCursor_OverloadCandidate
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXDiagnosticDisplayOptions
+-------------------------------------------------------------------------------}
+
+-- | Options to control the display of diagnostics.
+--
+-- The values in this enum are meant to be combined to customize the behavior of
+-- 'clang_formatDiagnostic'.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga0545c7c3ef36a397c44d142b0385b8d1>
+data CXDiagnosticDisplayOptions =
+    -- | Display the source-location information where the diagnostic was
+    -- located.
+    --
+    -- When set, diagnostics will be prefixed by the file, line, and
+    -- (optionally) column to which the diagnostic refers. For example,
+    --
+    -- > test.c:28: warning: extra tokens at end of #endif directive
+    --
+    -- This option corresponds to the clang flag @-fshow-source-location@.
+    CXDiagnostic_DisplaySourceLocation
+
+    -- | If displaying the source-location information of the diagnostic, also
+    -- include the column number.
+    --
+    -- | This option corresponds to the clang flag @-fshow-column@.
+  | CXDiagnostic_DisplayColumn
+
+    -- | If displaying the source-location information of the diagnostic, also
+    -- include information about source ranges in a machine-parsable format.
+    --
+    -- This option corresponds to the clang flag
+    -- @-fdiagnostics-print-source-range-info@.
+  | CXDiagnostic_DisplaySourceRanges
+
+    -- | Display the option name associated with this diagnostic, if any.
+    --
+    -- The option name displayed (e.g., @-Wconversion@) will be placed in
+    -- brackets after the diagnostic text. This option corresponds to the clang
+    -- flag @-fdiagnostics-show-option@.
+  | CXDiagnostic_DisplayOption
+
+    -- | Display the category number associated with this diagnostic, if any.
+    --
+    -- The category number is displayed within brackets after the diagnostic
+    -- text. This option corresponds to the clang flag
+    -- @-fdiagnostics-show-category=id@.
+  | CXDiagnostic_DisplayCategoryId
+
+    -- | Display the category name associated with this diagnostic, if any.
+    --
+    -- The category name is displayed within brackets after the diagnostic text.
+    -- This option corresponds to the clang flag
+    -- @-fdiagnostics-show-category=name@.
+  | CXDiagnostic_DisplayCategoryName
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXDiagnosticSeverity
+-------------------------------------------------------------------------------}
+
+-- | Describes the severity of a particular diagnostic.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#gabff210a02d448bf64e8aee79b2241370>
+data CXDiagnosticSeverity =
+    -- | A diagnostic that has been suppressed, e.g., by a command-line option.
+    CXDiagnostic_Ignored
+
+    -- | This diagnostic is a note that should be attached to the previous
+    -- (non-note) diagnostic.
+  | CXDiagnostic_Note
+
+    -- | This diagnostic indicates suspicious code that may not be wrong.
+  | CXDiagnostic_Warning
+
+    -- | This diagnostic indicates that the code is ill-formed.
+  | CXDiagnostic_Error
+
+    -- | This diagnostic indicates that the code is ill-formed such that future
+    -- parser recovery is unlikely to produce useful results.
+  | CXDiagnostic_Fatal
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CX_StorageClass
+-------------------------------------------------------------------------------}
+
+-- | Represents the storage classes as declared in the source.
+--
+-- NOTE: We omit @CX_SC_Invalid@ (zero) for the case that the passed cursor in
+-- not a declaration (and throw an error instead).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html#ga03a15eaa53465d7f3ce7d88743241d7e>
+data CX_StorageClass =
+    CX_SC_None
+  | CX_SC_Extern
+  | CX_SC_Static
+  | CX_SC_PrivateExtern
+  | CX_SC_OpenCLWorkGroupLocal
+  | CX_SC_Auto
+  | CX_SC_Register
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXLinkageKind
+-------------------------------------------------------------------------------}
+
+-- | Describe the linkage of the entity referred to by a cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gace57c68a7a11b0967b184a7ef9fbeb9e>
+data CXLinkageKind =
+    -- | This value indicates that no linkage information is available for a
+    -- provided CXCursor.
+    CXLinkage_Invalid
+    -- | This is the linkage for variables, parameters, and so on that have
+    -- automatic storage.
+    --
+    -- This covers normal (non-extern) local variables.
+  | CXLinkage_NoLinkage
+    -- | This is the linkage for static variables and static functions.
+  | CXLinkage_Internal
+    -- | This is the linkage for entities with external linkage that live in C++
+    -- anonymous namespaces.
+  | CXLinkage_UniqueExternal
+    -- | This is the linkage for entities with true, external linkage.
+  | CXLinkage_External
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXTLSKind
+-------------------------------------------------------------------------------}
+
+-- | Describe the \"thread-local storage (TLS) kind\" of the declaration
+-- referred to by a cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#ga4e9aabb46d683642ef49f542be4f1257>
+data CXTLSKind =
+    CXTLS_None
+  | CXTLS_Dynamic
+  | CXTLS_Static
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXVisibilityKind
+-------------------------------------------------------------------------------}
+
+-- | Describe the visibility of the entity referred to by a cursor.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#gaf92fafb489ab66529aceab51818994cb>
+data CXVisibilityKind =
+    -- | This value indicates that no visibility information is available for a
+    -- provided CXCursor.
+    CXVisibility_Invalid
+    -- | Symbol not seen by the linker.
+  | CXVisibility_Hidden
+    -- | Symbol seen by the linker but resolves to a symbol inside this object.
+  | CXVisibility_Protected
+    -- | Symbol seen by the linker and acts like a normal symbol.
+  | CXVisibility_Default
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXAvailabilityKind
+-------------------------------------------------------------------------------}
+
+-- | Describes the availability of a particular entity, which indicates whether
+-- the use of this entity will result in a warning or error due to it being
+-- deprecated or unavailable.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gada331ea0195e952c8f181ecf15e83d71>
+data CXAvailabilityKind =
+     -- | The entity is available.
+    CXAvailability_Available
+     -- | The entity is available, but has been deprecated (and its use is not
+     -- recommended).
+  | CXAvailability_Deprecated
+     -- | The entity is not available; any use of it will be an error.
+  | CXAvailability_NotAvailable
+     -- | The entity is available, but not accessible; any use of it will be an
+     -- error.
+  | CXAvailability_NotAccessible
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+{-------------------------------------------------------------------------------
+  CXEvalResultKind
+-------------------------------------------------------------------------------}
+
+-- | Evaluation result kind
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#ga71ffcbb614704d05b059e7edce9465fe>
+data CXEvalResultKind =
+    CXEval_Int
+  | CXEval_Float
+  | CXEval_ObjCStrLiteral
+  | CXEval_StrLiteral
+  | CXEval_CFStr
+  | CXEval_Other
+  | CXEval_UnExposed
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
diff --git a/src/Clang/LowLevel/Core/Instances.hsc b/src/Clang/LowLevel/Core/Instances.hsc
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Core/Instances.hsc
@@ -0,0 +1,937 @@
+{-# OPTIONS_GHC -Wno-orphans #-}
+
+-- | Enum instances (requires the help of the @hsc2hs@ preprocessor)
+--
+-- Since we get no HLS support in modules that are preprocessed, we use a
+-- separate module for these instances. Technically speaking this results in
+-- orphans, but the benefit of defining the Haskell definitions separately is
+-- that when working on the high-level Clang API, we can "jump to definition"
+-- for the enums and land in a regular Haskell source file rather than the
+-- result of the @hsc2hs@ preprocessor.
+--
+-- This module should only be imported by "Clang.LowLevel".
+module Clang.LowLevel.Core.Instances () where
+
+import Clang.Enum.Bitfield
+import Clang.Enum.Simple
+import Clang.Internal.ByValue
+import Clang.LowLevel.Core.Enums
+import Clang.LowLevel.Core.Structs
+
+#include <clang-c/Index.h>
+#include "clang_wrappers.h"
+
+{-------------------------------------------------------------------------------
+  HasKnownSize instances
+-------------------------------------------------------------------------------}
+
+instance HasKnownSize CXCursor_         where knownSize = #size CXCursor
+instance HasKnownSize CXSourceLocation_ where knownSize = #size CXSourceLocation
+instance HasKnownSize CXSourceRange_    where knownSize = #size CXSourceRange
+instance HasKnownSize CXString_         where knownSize = #size CXString
+instance HasKnownSize CXToken_          where knownSize = #size CXToken
+instance HasKnownSize CXType_           where knownSize = #size CXType
+
+{-------------------------------------------------------------------------------
+  CXErrorCode
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXErrorCode where
+  simpleToC CXError_Failure          = #const CXError_Failure
+  simpleToC CXError_Crashed          = #const CXError_Crashed
+  simpleToC CXError_InvalidArguments = #const CXError_InvalidArguments
+  simpleToC CXError_ASTReadError     = #const CXError_ASTReadError
+
+  simpleFromC (#const CXError_Failure)          = Just CXError_Failure
+  simpleFromC (#const CXError_Crashed)          = Just CXError_Crashed
+  simpleFromC (#const CXError_InvalidArguments) = Just CXError_InvalidArguments
+  simpleFromC (#const CXError_ASTReadError)     = Just CXError_ASTReadError
+
+  simpleFromC _ = Nothing
+
+instance IsSimpleEnum (Maybe CXErrorCode) where
+  simpleToC Nothing   = #const CXError_Success
+  simpleToC (Just hs) = simpleToC hs
+
+  simpleFromC (#const CXError_Success) = Just Nothing
+  simpleFromC c                        = Just <$> simpleFromC c
+
+{-------------------------------------------------------------------------------
+  CXTranslationUnit_Flag
+-------------------------------------------------------------------------------}
+
+instance IsSingleFlag CXTranslationUnit_Flags where
+  flagToC CXTranslationUnit_None                                 = #const CXTranslationUnit_None
+  flagToC CXTranslationUnit_DetailedPreprocessingRecord          = #const CXTranslationUnit_DetailedPreprocessingRecord
+  flagToC CXTranslationUnit_Incomplete                           = #const CXTranslationUnit_Incomplete
+  flagToC CXTranslationUnit_PrecompiledPreamble                  = #const CXTranslationUnit_PrecompiledPreamble
+  flagToC CXTranslationUnit_CacheCompletionResults               = #const CXTranslationUnit_CacheCompletionResults
+  flagToC CXTranslationUnit_ForSerialization                     = #const CXTranslationUnit_ForSerialization
+  flagToC CXTranslationUnit_SkipFunctionBodies                   = #const CXTranslationUnit_SkipFunctionBodies
+  flagToC CXTranslationUnit_IncludeBriefCommentsInCodeCompletion = #const CXTranslationUnit_IncludeBriefCommentsInCodeCompletion
+  flagToC CXTranslationUnit_CreatePreambleOnFirstParse           = #const CXTranslationUnit_CreatePreambleOnFirstParse
+  flagToC CXTranslationUnit_KeepGoing                            = #const CXTranslationUnit_KeepGoing
+  flagToC CXTranslationUnit_SingleFileParse                      = #const CXTranslationUnit_SingleFileParse
+  flagToC CXTranslationUnit_LimitSkipFunctionBodiesToPreamble    = #const CXTranslationUnit_LimitSkipFunctionBodiesToPreamble
+  flagToC CXTranslationUnit_IncludeAttributedTypes               = #const CXTranslationUnit_IncludeAttributedTypes
+  flagToC CXTranslationUnit_VisitImplicitAttributes              = #const CXTranslationUnit_VisitImplicitAttributes
+  flagToC CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles     = #const CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles
+  flagToC CXTranslationUnit_RetainExcludedConditionalBlocks      = #const CXTranslationUnit_RetainExcludedConditionalBlocks
+
+{-------------------------------------------------------------------------------
+  CXTypeKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXTypeKind where
+  simpleToC CXType_Invalid             = #const CXType_Invalid
+  simpleToC CXType_Unexposed           = #const CXType_Unexposed
+  simpleToC CXType_Void                = #const CXType_Void
+  simpleToC CXType_Bool                = #const CXType_Bool
+  simpleToC CXType_Char_U              = #const CXType_Char_U
+  simpleToC CXType_UChar               = #const CXType_UChar
+  simpleToC CXType_Char16              = #const CXType_Char16
+  simpleToC CXType_Char32              = #const CXType_Char32
+  simpleToC CXType_UShort              = #const CXType_UShort
+  simpleToC CXType_UInt                = #const CXType_UInt
+  simpleToC CXType_ULong               = #const CXType_ULong
+  simpleToC CXType_ULongLong           = #const CXType_ULongLong
+  simpleToC CXType_UInt128             = #const CXType_UInt128
+  simpleToC CXType_Char_S              = #const CXType_Char_S
+  simpleToC CXType_SChar               = #const CXType_SChar
+  simpleToC CXType_WChar               = #const CXType_WChar
+  simpleToC CXType_Short               = #const CXType_Short
+  simpleToC CXType_Int                 = #const CXType_Int
+  simpleToC CXType_Long                = #const CXType_Long
+  simpleToC CXType_LongLong            = #const CXType_LongLong
+  simpleToC CXType_Int128              = #const CXType_Int128
+  simpleToC CXType_Float               = #const CXType_Float
+  simpleToC CXType_Double              = #const CXType_Double
+  simpleToC CXType_LongDouble          = #const CXType_LongDouble
+  simpleToC CXType_NullPtr             = #const CXType_NullPtr
+  simpleToC CXType_Overload            = #const CXType_Overload
+  simpleToC CXType_Dependent           = #const CXType_Dependent
+  simpleToC CXType_ObjCId              = #const CXType_ObjCId
+  simpleToC CXType_ObjCClass           = #const CXType_ObjCClass
+  simpleToC CXType_ObjCSel             = #const CXType_ObjCSel
+  simpleToC CXType_Float128            = #const CXType_Float128
+  simpleToC CXType_Half                = #const CXType_Half
+  simpleToC CXType_Float16             = #const CXType_Float16
+  simpleToC CXType_ShortAccum          = #const CXType_ShortAccum
+  simpleToC CXType_Accum               = #const CXType_Accum
+  simpleToC CXType_LongAccum           = #const CXType_LongAccum
+  simpleToC CXType_UShortAccum         = #const CXType_UShortAccum
+  simpleToC CXType_UAccum              = #const CXType_UAccum
+  simpleToC CXType_ULongAccum          = #const CXType_ULongAccum
+  simpleToC CXType_BFloat16            = #const CXType_BFloat16
+  simpleToC CXType_Ibm128              = #const CXType_Ibm128
+  simpleToC CXType_Complex             = #const CXType_Complex
+  simpleToC CXType_Pointer             = #const CXType_Pointer
+  simpleToC CXType_BlockPointer        = #const CXType_BlockPointer
+  simpleToC CXType_LValueReference     = #const CXType_LValueReference
+  simpleToC CXType_RValueReference     = #const CXType_RValueReference
+  simpleToC CXType_Record              = #const CXType_Record
+  simpleToC CXType_Enum                = #const CXType_Enum
+  simpleToC CXType_Typedef             = #const CXType_Typedef
+  simpleToC CXType_ObjCInterface       = #const CXType_ObjCInterface
+  simpleToC CXType_ObjCObjectPointer   = #const CXType_ObjCObjectPointer
+  simpleToC CXType_FunctionNoProto     = #const CXType_FunctionNoProto
+  simpleToC CXType_FunctionProto       = #const CXType_FunctionProto
+  simpleToC CXType_ConstantArray       = #const CXType_ConstantArray
+  simpleToC CXType_Vector              = #const CXType_Vector
+  simpleToC CXType_IncompleteArray     = #const CXType_IncompleteArray
+  simpleToC CXType_VariableArray       = #const CXType_VariableArray
+  simpleToC CXType_DependentSizedArray = #const CXType_DependentSizedArray
+  simpleToC CXType_MemberPointer       = #const CXType_MemberPointer
+  simpleToC CXType_Auto                = #const CXType_Auto
+  simpleToC CXType_Elaborated          = #const CXType_Elaborated
+  simpleToC CXType_ObjCObject          = #const CXType_ObjCObject
+  simpleToC CXType_ObjCTypeParam       = #const CXType_ObjCTypeParam
+  simpleToC CXType_Attributed          = #const CXType_Attributed
+  simpleToC CXType_ExtVector           = #const CXType_ExtVector
+  simpleToC CXType_Atomic              = #const CXType_Atomic
+
+  simpleFromC (#const CXType_Invalid)             = Just CXType_Invalid
+  simpleFromC (#const CXType_Unexposed)           = Just CXType_Unexposed
+  simpleFromC (#const CXType_Void)                = Just CXType_Void
+  simpleFromC (#const CXType_Bool)                = Just CXType_Bool
+  simpleFromC (#const CXType_Char_U)              = Just CXType_Char_U
+  simpleFromC (#const CXType_UChar)               = Just CXType_UChar
+  simpleFromC (#const CXType_Char16)              = Just CXType_Char16
+  simpleFromC (#const CXType_Char32)              = Just CXType_Char32
+  simpleFromC (#const CXType_UShort)              = Just CXType_UShort
+  simpleFromC (#const CXType_UInt)                = Just CXType_UInt
+  simpleFromC (#const CXType_ULong)               = Just CXType_ULong
+  simpleFromC (#const CXType_ULongLong)           = Just CXType_ULongLong
+  simpleFromC (#const CXType_UInt128)             = Just CXType_UInt128
+  simpleFromC (#const CXType_Char_S)              = Just CXType_Char_S
+  simpleFromC (#const CXType_SChar)               = Just CXType_SChar
+  simpleFromC (#const CXType_WChar)               = Just CXType_WChar
+  simpleFromC (#const CXType_Short)               = Just CXType_Short
+  simpleFromC (#const CXType_Int)                 = Just CXType_Int
+  simpleFromC (#const CXType_Long)                = Just CXType_Long
+  simpleFromC (#const CXType_LongLong)            = Just CXType_LongLong
+  simpleFromC (#const CXType_Int128)              = Just CXType_Int128
+  simpleFromC (#const CXType_Float)               = Just CXType_Float
+  simpleFromC (#const CXType_Double)              = Just CXType_Double
+  simpleFromC (#const CXType_LongDouble)          = Just CXType_LongDouble
+  simpleFromC (#const CXType_NullPtr)             = Just CXType_NullPtr
+  simpleFromC (#const CXType_Overload)            = Just CXType_Overload
+  simpleFromC (#const CXType_Dependent)           = Just CXType_Dependent
+  simpleFromC (#const CXType_ObjCId)              = Just CXType_ObjCId
+  simpleFromC (#const CXType_ObjCClass)           = Just CXType_ObjCClass
+  simpleFromC (#const CXType_ObjCSel)             = Just CXType_ObjCSel
+  simpleFromC (#const CXType_Float128)            = Just CXType_Float128
+  simpleFromC (#const CXType_Half)                = Just CXType_Half
+  simpleFromC (#const CXType_Float16)             = Just CXType_Float16
+  simpleFromC (#const CXType_ShortAccum)          = Just CXType_ShortAccum
+  simpleFromC (#const CXType_Accum)               = Just CXType_Accum
+  simpleFromC (#const CXType_LongAccum)           = Just CXType_LongAccum
+  simpleFromC (#const CXType_UShortAccum)         = Just CXType_UShortAccum
+  simpleFromC (#const CXType_UAccum)              = Just CXType_UAccum
+  simpleFromC (#const CXType_ULongAccum)          = Just CXType_ULongAccum
+  simpleFromC (#const CXType_BFloat16)            = Just CXType_BFloat16
+  simpleFromC (#const CXType_Ibm128)              = Just CXType_Ibm128
+  simpleFromC (#const CXType_Complex)             = Just CXType_Complex
+  simpleFromC (#const CXType_Pointer)             = Just CXType_Pointer
+  simpleFromC (#const CXType_BlockPointer)        = Just CXType_BlockPointer
+  simpleFromC (#const CXType_LValueReference)     = Just CXType_LValueReference
+  simpleFromC (#const CXType_RValueReference)     = Just CXType_RValueReference
+  simpleFromC (#const CXType_Record)              = Just CXType_Record
+  simpleFromC (#const CXType_Enum)                = Just CXType_Enum
+  simpleFromC (#const CXType_Typedef)             = Just CXType_Typedef
+  simpleFromC (#const CXType_ObjCInterface)       = Just CXType_ObjCInterface
+  simpleFromC (#const CXType_ObjCObjectPointer)   = Just CXType_ObjCObjectPointer
+  simpleFromC (#const CXType_FunctionNoProto)     = Just CXType_FunctionNoProto
+  simpleFromC (#const CXType_FunctionProto)       = Just CXType_FunctionProto
+  simpleFromC (#const CXType_ConstantArray)       = Just CXType_ConstantArray
+  simpleFromC (#const CXType_Vector)              = Just CXType_Vector
+  simpleFromC (#const CXType_IncompleteArray)     = Just CXType_IncompleteArray
+  simpleFromC (#const CXType_VariableArray)       = Just CXType_VariableArray
+  simpleFromC (#const CXType_DependentSizedArray) = Just CXType_DependentSizedArray
+  simpleFromC (#const CXType_MemberPointer)       = Just CXType_MemberPointer
+  simpleFromC (#const CXType_Auto)                = Just CXType_Auto
+  simpleFromC (#const CXType_Elaborated)          = Just CXType_Elaborated
+  simpleFromC (#const CXType_ObjCObject)          = Just CXType_ObjCObject
+  simpleFromC (#const CXType_ObjCTypeParam)       = Just CXType_ObjCTypeParam
+  simpleFromC (#const CXType_Attributed)          = Just CXType_Attributed
+  simpleFromC (#const CXType_ExtVector)           = Just CXType_ExtVector
+  simpleFromC (#const CXType_Atomic)              = Just CXType_Atomic
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXChildVisitResult
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXChildVisitResult where
+  simpleToC CXChildVisit_Break    = #const CXChildVisit_Break
+  simpleToC CXChildVisit_Continue = #const CXChildVisit_Continue
+  simpleToC CXChildVisit_Recurse  = #const CXChildVisit_Recurse
+
+  simpleFromC (#const CXChildVisit_Break)    = Just CXChildVisit_Break
+  simpleFromC (#const CXChildVisit_Continue) = Just CXChildVisit_Continue
+  simpleFromC (#const CXChildVisit_Recurse)  = Just CXChildVisit_Recurse
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXTypeLayoutError
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXTypeLayoutError where
+  simpleToC CXTypeLayoutError_Invalid          = #const CXTypeLayoutError_Invalid
+  simpleToC CXTypeLayoutError_Incomplete       = #const CXTypeLayoutError_Incomplete
+  simpleToC CXTypeLayoutError_Dependent        = #const CXTypeLayoutError_Dependent
+  simpleToC CXTypeLayoutError_NotConstantSize  = #const CXTypeLayoutError_NotConstantSize
+  simpleToC CXTypeLayoutError_InvalidFieldName = #const CXTypeLayoutError_InvalidFieldName
+  simpleToC CXTypeLayoutError_Undeduced        = #const CXTypeLayoutError_Undeduced
+
+  simpleFromC (#const CXTypeLayoutError_Invalid)          = Just CXTypeLayoutError_Invalid
+  simpleFromC (#const CXTypeLayoutError_Incomplete)       = Just CXTypeLayoutError_Incomplete
+  simpleFromC (#const CXTypeLayoutError_Dependent)        = Just CXTypeLayoutError_Dependent
+  simpleFromC (#const CXTypeLayoutError_NotConstantSize)  = Just CXTypeLayoutError_NotConstantSize
+  simpleFromC (#const CXTypeLayoutError_InvalidFieldName) = Just CXTypeLayoutError_InvalidFieldName
+  simpleFromC (#const CXTypeLayoutError_Undeduced)        = Just CXTypeLayoutError_Undeduced
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXTokenKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXTokenKind where
+  simpleToC CXToken_Punctuation = #const CXToken_Punctuation
+  simpleToC CXToken_Keyword     = #const CXToken_Keyword
+  simpleToC CXToken_Identifier  = #const CXToken_Identifier
+  simpleToC CXToken_Literal     = #const CXToken_Literal
+  simpleToC CXToken_Comment     = #const CXToken_Comment
+
+  simpleFromC (#const CXToken_Punctuation) = Just CXToken_Punctuation
+  simpleFromC (#const CXToken_Keyword)     = Just CXToken_Keyword
+  simpleFromC (#const CXToken_Identifier)  = Just CXToken_Identifier
+  simpleFromC (#const CXToken_Literal)     = Just CXToken_Literal
+  simpleFromC (#const CXToken_Comment)     = Just CXToken_Comment
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXCursorKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXCursorKind where
+  simpleToC CXCursor_UnexposedDecl                                    = #const CXCursor_UnexposedDecl
+  simpleToC CXCursor_StructDecl                                       = #const CXCursor_StructDecl
+  simpleToC CXCursor_UnionDecl                                        = #const CXCursor_UnionDecl
+  simpleToC CXCursor_ClassDecl                                        = #const CXCursor_ClassDecl
+  simpleToC CXCursor_EnumDecl                                         = #const CXCursor_EnumDecl
+  simpleToC CXCursor_FieldDecl                                        = #const CXCursor_FieldDecl
+  simpleToC CXCursor_EnumConstantDecl                                 = #const CXCursor_EnumConstantDecl
+  simpleToC CXCursor_FunctionDecl                                     = #const CXCursor_FunctionDecl
+  simpleToC CXCursor_VarDecl                                          = #const CXCursor_VarDecl
+  simpleToC CXCursor_ParmDecl                                         = #const CXCursor_ParmDecl
+  simpleToC CXCursor_ObjCInterfaceDecl                                = #const CXCursor_ObjCInterfaceDecl
+  simpleToC CXCursor_ObjCCategoryDecl                                 = #const CXCursor_ObjCCategoryDecl
+  simpleToC CXCursor_ObjCProtocolDecl                                 = #const CXCursor_ObjCProtocolDecl
+  simpleToC CXCursor_ObjCPropertyDecl                                 = #const CXCursor_ObjCPropertyDecl
+  simpleToC CXCursor_ObjCIvarDecl                                     = #const CXCursor_ObjCIvarDecl
+  simpleToC CXCursor_ObjCInstanceMethodDecl                           = #const CXCursor_ObjCInstanceMethodDecl
+  simpleToC CXCursor_ObjCClassMethodDecl                              = #const CXCursor_ObjCClassMethodDecl
+  simpleToC CXCursor_ObjCImplementationDecl                           = #const CXCursor_ObjCImplementationDecl
+  simpleToC CXCursor_ObjCCategoryImplDecl                             = #const CXCursor_ObjCCategoryImplDecl
+  simpleToC CXCursor_TypedefDecl                                      = #const CXCursor_TypedefDecl
+  simpleToC CXCursor_CXXMethod                                        = #const CXCursor_CXXMethod
+  simpleToC CXCursor_Namespace                                        = #const CXCursor_Namespace
+  simpleToC CXCursor_LinkageSpec                                      = #const CXCursor_LinkageSpec
+  simpleToC CXCursor_Constructor                                      = #const CXCursor_Constructor
+  simpleToC CXCursor_Destructor                                       = #const CXCursor_Destructor
+  simpleToC CXCursor_ConversionFunction                               = #const CXCursor_ConversionFunction
+  simpleToC CXCursor_TemplateTypeParameter                            = #const CXCursor_TemplateTypeParameter
+  simpleToC CXCursor_NonTypeTemplateParameter                         = #const CXCursor_NonTypeTemplateParameter
+  simpleToC CXCursor_TemplateTemplateParameter                        = #const CXCursor_TemplateTemplateParameter
+  simpleToC CXCursor_FunctionTemplate                                 = #const CXCursor_FunctionTemplate
+  simpleToC CXCursor_ClassTemplate                                    = #const CXCursor_ClassTemplate
+  simpleToC CXCursor_ClassTemplatePartialSpecialization               = #const CXCursor_ClassTemplatePartialSpecialization
+  simpleToC CXCursor_NamespaceAlias                                   = #const CXCursor_NamespaceAlias
+  simpleToC CXCursor_UsingDirective                                   = #const CXCursor_UsingDirective
+  simpleToC CXCursor_UsingDeclaration                                 = #const CXCursor_UsingDeclaration
+  simpleToC CXCursor_TypeAliasDecl                                    = #const CXCursor_TypeAliasDecl
+  simpleToC CXCursor_ObjCSynthesizeDecl                               = #const CXCursor_ObjCSynthesizeDecl
+  simpleToC CXCursor_ObjCDynamicDecl                                  = #const CXCursor_ObjCDynamicDecl
+  simpleToC CXCursor_CXXAccessSpecifier                               = #const CXCursor_CXXAccessSpecifier
+  simpleToC CXCursor_ObjCSuperClassRef                                = #const CXCursor_ObjCSuperClassRef
+  simpleToC CXCursor_ObjCProtocolRef                                  = #const CXCursor_ObjCProtocolRef
+  simpleToC CXCursor_ObjCClassRef                                     = #const CXCursor_ObjCClassRef
+  simpleToC CXCursor_TypeRef                                          = #const CXCursor_TypeRef
+  simpleToC CXCursor_CXXBaseSpecifier                                 = #const CXCursor_CXXBaseSpecifier
+  simpleToC CXCursor_TemplateRef                                      = #const CXCursor_TemplateRef
+  simpleToC CXCursor_NamespaceRef                                     = #const CXCursor_NamespaceRef
+  simpleToC CXCursor_MemberRef                                        = #const CXCursor_MemberRef
+  simpleToC CXCursor_LabelRef                                         = #const CXCursor_LabelRef
+  simpleToC CXCursor_OverloadedDeclRef                                = #const CXCursor_OverloadedDeclRef
+  simpleToC CXCursor_VariableRef                                      = #const CXCursor_VariableRef
+  simpleToC CXCursor_InvalidFile                                      = #const CXCursor_InvalidFile
+  simpleToC CXCursor_NoDeclFound                                      = #const CXCursor_NoDeclFound
+  simpleToC CXCursor_NotImplemented                                   = #const CXCursor_NotImplemented
+  simpleToC CXCursor_InvalidCode                                      = #const CXCursor_InvalidCode
+  simpleToC CXCursor_UnexposedExpr                                    = #const CXCursor_UnexposedExpr
+  simpleToC CXCursor_DeclRefExpr                                      = #const CXCursor_DeclRefExpr
+  simpleToC CXCursor_MemberRefExpr                                    = #const CXCursor_MemberRefExpr
+  simpleToC CXCursor_CallExpr                                         = #const CXCursor_CallExpr
+  simpleToC CXCursor_ObjCMessageExpr                                  = #const CXCursor_ObjCMessageExpr
+  simpleToC CXCursor_BlockExpr                                        = #const CXCursor_BlockExpr
+  simpleToC CXCursor_IntegerLiteral                                   = #const CXCursor_IntegerLiteral
+  simpleToC CXCursor_FloatingLiteral                                  = #const CXCursor_FloatingLiteral
+  simpleToC CXCursor_ImaginaryLiteral                                 = #const CXCursor_ImaginaryLiteral
+  simpleToC CXCursor_StringLiteral                                    = #const CXCursor_StringLiteral
+  simpleToC CXCursor_CharacterLiteral                                 = #const CXCursor_CharacterLiteral
+  simpleToC CXCursor_ParenExpr                                        = #const CXCursor_ParenExpr
+  simpleToC CXCursor_UnaryOperator                                    = #const CXCursor_UnaryOperator
+  simpleToC CXCursor_ArraySubscriptExpr                               = #const CXCursor_ArraySubscriptExpr
+  simpleToC CXCursor_BinaryOperator                                   = #const CXCursor_BinaryOperator
+  simpleToC CXCursor_CompoundAssignOperator                           = #const CXCursor_CompoundAssignOperator
+  simpleToC CXCursor_ConditionalOperator                              = #const CXCursor_ConditionalOperator
+  simpleToC CXCursor_CStyleCastExpr                                   = #const CXCursor_CStyleCastExpr
+  simpleToC CXCursor_CompoundLiteralExpr                              = #const CXCursor_CompoundLiteralExpr
+  simpleToC CXCursor_InitListExpr                                     = #const CXCursor_InitListExpr
+  simpleToC CXCursor_AddrLabelExpr                                    = #const CXCursor_AddrLabelExpr
+  simpleToC CXCursor_StmtExpr                                         = #const CXCursor_StmtExpr
+  simpleToC CXCursor_GenericSelectionExpr                             = #const CXCursor_GenericSelectionExpr
+  simpleToC CXCursor_GNUNullExpr                                      = #const CXCursor_GNUNullExpr
+  simpleToC CXCursor_CXXStaticCastExpr                                = #const CXCursor_CXXStaticCastExpr
+  simpleToC CXCursor_CXXDynamicCastExpr                               = #const CXCursor_CXXDynamicCastExpr
+  simpleToC CXCursor_CXXReinterpretCastExpr                           = #const CXCursor_CXXReinterpretCastExpr
+  simpleToC CXCursor_CXXConstCastExpr                                 = #const CXCursor_CXXConstCastExpr
+  simpleToC CXCursor_CXXFunctionalCastExpr                            = #const CXCursor_CXXFunctionalCastExpr
+  simpleToC CXCursor_CXXTypeidExpr                                    = #const CXCursor_CXXTypeidExpr
+  simpleToC CXCursor_CXXBoolLiteralExpr                               = #const CXCursor_CXXBoolLiteralExpr
+  simpleToC CXCursor_CXXNullPtrLiteralExpr                            = #const CXCursor_CXXNullPtrLiteralExpr
+  simpleToC CXCursor_CXXThisExpr                                      = #const CXCursor_CXXThisExpr
+  simpleToC CXCursor_CXXThrowExpr                                     = #const CXCursor_CXXThrowExpr
+  simpleToC CXCursor_CXXNewExpr                                       = #const CXCursor_CXXNewExpr
+  simpleToC CXCursor_CXXDeleteExpr                                    = #const CXCursor_CXXDeleteExpr
+  simpleToC CXCursor_UnaryExpr                                        = #const CXCursor_UnaryExpr
+  simpleToC CXCursor_ObjCStringLiteral                                = #const CXCursor_ObjCStringLiteral
+  simpleToC CXCursor_ObjCEncodeExpr                                   = #const CXCursor_ObjCEncodeExpr
+  simpleToC CXCursor_ObjCSelectorExpr                                 = #const CXCursor_ObjCSelectorExpr
+  simpleToC CXCursor_ObjCProtocolExpr                                 = #const CXCursor_ObjCProtocolExpr
+  simpleToC CXCursor_ObjCBridgedCastExpr                              = #const CXCursor_ObjCBridgedCastExpr
+  simpleToC CXCursor_PackExpansionExpr                                = #const CXCursor_PackExpansionExpr
+  simpleToC CXCursor_SizeOfPackExpr                                   = #const CXCursor_SizeOfPackExpr
+  simpleToC CXCursor_LambdaExpr                                       = #const CXCursor_LambdaExpr
+  simpleToC CXCursor_ObjCBoolLiteralExpr                              = #const CXCursor_ObjCBoolLiteralExpr
+  simpleToC CXCursor_ObjCSelfExpr                                     = #const CXCursor_ObjCSelfExpr
+  simpleToC CXCursor_ObjCAvailabilityCheckExpr                        = #const CXCursor_ObjCAvailabilityCheckExpr
+  simpleToC CXCursor_FixedPointLiteral                                = #const CXCursor_FixedPointLiteral
+  simpleToC CXCursor_OMPArrayShapingExpr                              = #const CXCursor_OMPArrayShapingExpr
+  simpleToC CXCursor_OMPIteratorExpr                                  = #const CXCursor_OMPIteratorExpr
+  simpleToC CXCursor_CXXAddrspaceCastExpr                             = #const CXCursor_CXXAddrspaceCastExpr
+  simpleToC CXCursor_UnexposedStmt                                    = #const CXCursor_UnexposedStmt
+  simpleToC CXCursor_LabelStmt                                        = #const CXCursor_LabelStmt
+  simpleToC CXCursor_CompoundStmt                                     = #const CXCursor_CompoundStmt
+  simpleToC CXCursor_CaseStmt                                         = #const CXCursor_CaseStmt
+  simpleToC CXCursor_DefaultStmt                                      = #const CXCursor_DefaultStmt
+  simpleToC CXCursor_IfStmt                                           = #const CXCursor_IfStmt
+  simpleToC CXCursor_SwitchStmt                                       = #const CXCursor_SwitchStmt
+  simpleToC CXCursor_WhileStmt                                        = #const CXCursor_WhileStmt
+  simpleToC CXCursor_DoStmt                                           = #const CXCursor_DoStmt
+  simpleToC CXCursor_ForStmt                                          = #const CXCursor_ForStmt
+  simpleToC CXCursor_GotoStmt                                         = #const CXCursor_GotoStmt
+  simpleToC CXCursor_IndirectGotoStmt                                 = #const CXCursor_IndirectGotoStmt
+  simpleToC CXCursor_ContinueStmt                                     = #const CXCursor_ContinueStmt
+  simpleToC CXCursor_BreakStmt                                        = #const CXCursor_BreakStmt
+  simpleToC CXCursor_ReturnStmt                                       = #const CXCursor_ReturnStmt
+  simpleToC CXCursor_GCCAsmStmt                                       = #const CXCursor_GCCAsmStmt
+  simpleToC CXCursor_ObjCAtTryStmt                                    = #const CXCursor_ObjCAtTryStmt
+  simpleToC CXCursor_ObjCAtCatchStmt                                  = #const CXCursor_ObjCAtCatchStmt
+  simpleToC CXCursor_ObjCAtFinallyStmt                                = #const CXCursor_ObjCAtFinallyStmt
+  simpleToC CXCursor_ObjCAtThrowStmt                                  = #const CXCursor_ObjCAtThrowStmt
+  simpleToC CXCursor_ObjCAtSynchronizedStmt                           = #const CXCursor_ObjCAtSynchronizedStmt
+  simpleToC CXCursor_ObjCAutoreleasePoolStmt                          = #const CXCursor_ObjCAutoreleasePoolStmt
+  simpleToC CXCursor_ObjCForCollectionStmt                            = #const CXCursor_ObjCForCollectionStmt
+  simpleToC CXCursor_CXXCatchStmt                                     = #const CXCursor_CXXCatchStmt
+  simpleToC CXCursor_CXXTryStmt                                       = #const CXCursor_CXXTryStmt
+  simpleToC CXCursor_CXXForRangeStmt                                  = #const CXCursor_CXXForRangeStmt
+  simpleToC CXCursor_SEHTryStmt                                       = #const CXCursor_SEHTryStmt
+  simpleToC CXCursor_SEHExceptStmt                                    = #const CXCursor_SEHExceptStmt
+  simpleToC CXCursor_SEHFinallyStmt                                   = #const CXCursor_SEHFinallyStmt
+  simpleToC CXCursor_MSAsmStmt                                        = #const CXCursor_MSAsmStmt
+  simpleToC CXCursor_NullStmt                                         = #const CXCursor_NullStmt
+  simpleToC CXCursor_DeclStmt                                         = #const CXCursor_DeclStmt
+  simpleToC CXCursor_OMPParallelDirective                             = #const CXCursor_OMPParallelDirective
+  simpleToC CXCursor_OMPSimdDirective                                 = #const CXCursor_OMPSimdDirective
+  simpleToC CXCursor_OMPForDirective                                  = #const CXCursor_OMPForDirective
+  simpleToC CXCursor_OMPSectionsDirective                             = #const CXCursor_OMPSectionsDirective
+  simpleToC CXCursor_OMPSectionDirective                              = #const CXCursor_OMPSectionDirective
+  simpleToC CXCursor_OMPSingleDirective                               = #const CXCursor_OMPSingleDirective
+  simpleToC CXCursor_OMPParallelForDirective                          = #const CXCursor_OMPParallelForDirective
+  simpleToC CXCursor_OMPParallelSectionsDirective                     = #const CXCursor_OMPParallelSectionsDirective
+  simpleToC CXCursor_OMPTaskDirective                                 = #const CXCursor_OMPTaskDirective
+  simpleToC CXCursor_OMPMasterDirective                               = #const CXCursor_OMPMasterDirective
+  simpleToC CXCursor_OMPCriticalDirective                             = #const CXCursor_OMPCriticalDirective
+  simpleToC CXCursor_OMPTaskyieldDirective                            = #const CXCursor_OMPTaskyieldDirective
+  simpleToC CXCursor_OMPBarrierDirective                              = #const CXCursor_OMPBarrierDirective
+  simpleToC CXCursor_OMPTaskwaitDirective                             = #const CXCursor_OMPTaskwaitDirective
+  simpleToC CXCursor_OMPFlushDirective                                = #const CXCursor_OMPFlushDirective
+  simpleToC CXCursor_SEHLeaveStmt                                     = #const CXCursor_SEHLeaveStmt
+  simpleToC CXCursor_OMPOrderedDirective                              = #const CXCursor_OMPOrderedDirective
+  simpleToC CXCursor_OMPAtomicDirective                               = #const CXCursor_OMPAtomicDirective
+  simpleToC CXCursor_OMPForSimdDirective                              = #const CXCursor_OMPForSimdDirective
+  simpleToC CXCursor_OMPParallelForSimdDirective                      = #const CXCursor_OMPParallelForSimdDirective
+  simpleToC CXCursor_OMPTargetDirective                               = #const CXCursor_OMPTargetDirective
+  simpleToC CXCursor_OMPTeamsDirective                                = #const CXCursor_OMPTeamsDirective
+  simpleToC CXCursor_OMPTaskgroupDirective                            = #const CXCursor_OMPTaskgroupDirective
+  simpleToC CXCursor_OMPCancellationPointDirective                    = #const CXCursor_OMPCancellationPointDirective
+  simpleToC CXCursor_OMPCancelDirective                               = #const CXCursor_OMPCancelDirective
+  simpleToC CXCursor_OMPTargetDataDirective                           = #const CXCursor_OMPTargetDataDirective
+  simpleToC CXCursor_OMPTaskLoopDirective                             = #const CXCursor_OMPTaskLoopDirective
+  simpleToC CXCursor_OMPTaskLoopSimdDirective                         = #const CXCursor_OMPTaskLoopSimdDirective
+  simpleToC CXCursor_OMPDistributeDirective                           = #const CXCursor_OMPDistributeDirective
+  simpleToC CXCursor_OMPTargetEnterDataDirective                      = #const CXCursor_OMPTargetEnterDataDirective
+  simpleToC CXCursor_OMPTargetExitDataDirective                       = #const CXCursor_OMPTargetExitDataDirective
+  simpleToC CXCursor_OMPTargetParallelDirective                       = #const CXCursor_OMPTargetParallelDirective
+  simpleToC CXCursor_OMPTargetParallelForDirective                    = #const CXCursor_OMPTargetParallelForDirective
+  simpleToC CXCursor_OMPTargetUpdateDirective                         = #const CXCursor_OMPTargetUpdateDirective
+  simpleToC CXCursor_OMPDistributeParallelForDirective                = #const CXCursor_OMPDistributeParallelForDirective
+  simpleToC CXCursor_OMPDistributeParallelForSimdDirective            = #const CXCursor_OMPDistributeParallelForSimdDirective
+  simpleToC CXCursor_OMPDistributeSimdDirective                       = #const CXCursor_OMPDistributeSimdDirective
+  simpleToC CXCursor_OMPTargetParallelForSimdDirective                = #const CXCursor_OMPTargetParallelForSimdDirective
+  simpleToC CXCursor_OMPTargetSimdDirective                           = #const CXCursor_OMPTargetSimdDirective
+  simpleToC CXCursor_OMPTeamsDistributeDirective                      = #const CXCursor_OMPTeamsDistributeDirective
+  simpleToC CXCursor_OMPTeamsDistributeSimdDirective                  = #const CXCursor_OMPTeamsDistributeSimdDirective
+  simpleToC CXCursor_OMPTeamsDistributeParallelForSimdDirective       = #const CXCursor_OMPTeamsDistributeParallelForSimdDirective
+  simpleToC CXCursor_OMPTeamsDistributeParallelForDirective           = #const CXCursor_OMPTeamsDistributeParallelForDirective
+  simpleToC CXCursor_OMPTargetTeamsDirective                          = #const CXCursor_OMPTargetTeamsDirective
+  simpleToC CXCursor_OMPTargetTeamsDistributeDirective                = #const CXCursor_OMPTargetTeamsDistributeDirective
+  simpleToC CXCursor_OMPTargetTeamsDistributeParallelForDirective     = #const CXCursor_OMPTargetTeamsDistributeParallelForDirective
+  simpleToC CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = #const CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective
+  simpleToC CXCursor_OMPTargetTeamsDistributeSimdDirective            = #const CXCursor_OMPTargetTeamsDistributeSimdDirective
+  simpleToC CXCursor_BuiltinBitCastExpr                               = #const CXCursor_BuiltinBitCastExpr
+  simpleToC CXCursor_OMPMasterTaskLoopDirective                       = #const CXCursor_OMPMasterTaskLoopDirective
+  simpleToC CXCursor_OMPParallelMasterTaskLoopDirective               = #const CXCursor_OMPParallelMasterTaskLoopDirective
+  simpleToC CXCursor_OMPMasterTaskLoopSimdDirective                   = #const CXCursor_OMPMasterTaskLoopSimdDirective
+  simpleToC CXCursor_OMPParallelMasterTaskLoopSimdDirective           = #const CXCursor_OMPParallelMasterTaskLoopSimdDirective
+  simpleToC CXCursor_OMPParallelMasterDirective                       = #const CXCursor_OMPParallelMasterDirective
+  simpleToC CXCursor_OMPDepobjDirective                               = #const CXCursor_OMPDepobjDirective
+  simpleToC CXCursor_OMPScanDirective                                 = #const CXCursor_OMPScanDirective
+  simpleToC CXCursor_OMPTileDirective                                 = #const CXCursor_OMPTileDirective
+  simpleToC CXCursor_OMPCanonicalLoop                                 = #const CXCursor_OMPCanonicalLoop
+  simpleToC CXCursor_OMPInteropDirective                              = #const CXCursor_OMPInteropDirective
+  simpleToC CXCursor_OMPDispatchDirective                             = #const CXCursor_OMPDispatchDirective
+  simpleToC CXCursor_OMPMaskedDirective                               = #const CXCursor_OMPMaskedDirective
+  simpleToC CXCursor_OMPUnrollDirective                               = #const CXCursor_OMPUnrollDirective
+  simpleToC CXCursor_OMPMetaDirective                                 = #const CXCursor_OMPMetaDirective
+  simpleToC CXCursor_OMPGenericLoopDirective                          = #const CXCursor_OMPGenericLoopDirective
+  simpleToC CXCursor_TranslationUnit                                  = #const CXCursor_TranslationUnit
+  simpleToC CXCursor_UnexposedAttr                                    = #const CXCursor_UnexposedAttr
+  simpleToC CXCursor_IBActionAttr                                     = #const CXCursor_IBActionAttr
+  simpleToC CXCursor_IBOutletAttr                                     = #const CXCursor_IBOutletAttr
+  simpleToC CXCursor_IBOutletCollectionAttr                           = #const CXCursor_IBOutletCollectionAttr
+  simpleToC CXCursor_CXXFinalAttr                                     = #const CXCursor_CXXFinalAttr
+  simpleToC CXCursor_CXXOverrideAttr                                  = #const CXCursor_CXXOverrideAttr
+  simpleToC CXCursor_AnnotateAttr                                     = #const CXCursor_AnnotateAttr
+  simpleToC CXCursor_AsmLabelAttr                                     = #const CXCursor_AsmLabelAttr
+  simpleToC CXCursor_PackedAttr                                       = #const CXCursor_PackedAttr
+  simpleToC CXCursor_PureAttr                                         = #const CXCursor_PureAttr
+  simpleToC CXCursor_ConstAttr                                        = #const CXCursor_ConstAttr
+  simpleToC CXCursor_NoDuplicateAttr                                  = #const CXCursor_NoDuplicateAttr
+  simpleToC CXCursor_CUDAConstantAttr                                 = #const CXCursor_CUDAConstantAttr
+  simpleToC CXCursor_CUDADeviceAttr                                   = #const CXCursor_CUDADeviceAttr
+  simpleToC CXCursor_CUDAGlobalAttr                                   = #const CXCursor_CUDAGlobalAttr
+  simpleToC CXCursor_CUDAHostAttr                                     = #const CXCursor_CUDAHostAttr
+  simpleToC CXCursor_CUDASharedAttr                                   = #const CXCursor_CUDASharedAttr
+  simpleToC CXCursor_VisibilityAttr                                   = #const CXCursor_VisibilityAttr
+  simpleToC CXCursor_DLLExport                                        = #const CXCursor_DLLExport
+  simpleToC CXCursor_DLLImport                                        = #const CXCursor_DLLImport
+  simpleToC CXCursor_NSReturnsRetained                                = #const CXCursor_NSReturnsRetained
+  simpleToC CXCursor_NSReturnsNotRetained                             = #const CXCursor_NSReturnsNotRetained
+  simpleToC CXCursor_NSReturnsAutoreleased                            = #const CXCursor_NSReturnsAutoreleased
+  simpleToC CXCursor_NSConsumesSelf                                   = #const CXCursor_NSConsumesSelf
+  simpleToC CXCursor_NSConsumed                                       = #const CXCursor_NSConsumed
+  simpleToC CXCursor_ObjCException                                    = #const CXCursor_ObjCException
+  simpleToC CXCursor_ObjCNSObject                                     = #const CXCursor_ObjCNSObject
+  simpleToC CXCursor_ObjCIndependentClass                             = #const CXCursor_ObjCIndependentClass
+  simpleToC CXCursor_ObjCPreciseLifetime                              = #const CXCursor_ObjCPreciseLifetime
+  simpleToC CXCursor_ObjCReturnsInnerPointer                          = #const CXCursor_ObjCReturnsInnerPointer
+  simpleToC CXCursor_ObjCRequiresSuper                                = #const CXCursor_ObjCRequiresSuper
+  simpleToC CXCursor_ObjCRootClass                                    = #const CXCursor_ObjCRootClass
+  simpleToC CXCursor_ObjCSubclassingRestricted                        = #const CXCursor_ObjCSubclassingRestricted
+  simpleToC CXCursor_ObjCExplicitProtocolImpl                         = #const CXCursor_ObjCExplicitProtocolImpl
+  simpleToC CXCursor_ObjCDesignatedInitializer                        = #const CXCursor_ObjCDesignatedInitializer
+  simpleToC CXCursor_ObjCRuntimeVisible                               = #const CXCursor_ObjCRuntimeVisible
+  simpleToC CXCursor_ObjCBoxable                                      = #const CXCursor_ObjCBoxable
+  simpleToC CXCursor_FlagEnum                                         = #const CXCursor_FlagEnum
+  simpleToC CXCursor_ConvergentAttr                                   = #const CXCursor_ConvergentAttr
+  simpleToC CXCursor_WarnUnusedAttr                                   = #const CXCursor_WarnUnusedAttr
+  simpleToC CXCursor_WarnUnusedResultAttr                             = #const CXCursor_WarnUnusedResultAttr
+  simpleToC CXCursor_AlignedAttr                                      = #const CXCursor_AlignedAttr
+  simpleToC CXCursor_PreprocessingDirective                           = #const CXCursor_PreprocessingDirective
+  simpleToC CXCursor_MacroDefinition                                  = #const CXCursor_MacroDefinition
+  simpleToC CXCursor_MacroExpansion                                   = #const CXCursor_MacroExpansion
+  simpleToC CXCursor_InclusionDirective                               = #const CXCursor_InclusionDirective
+  simpleToC CXCursor_ModuleImportDecl                                 = #const CXCursor_ModuleImportDecl
+  simpleToC CXCursor_TypeAliasTemplateDecl                            = #const CXCursor_TypeAliasTemplateDecl
+  simpleToC CXCursor_StaticAssert                                     = #const CXCursor_StaticAssert
+  simpleToC CXCursor_FriendDecl                                       = #const CXCursor_FriendDecl
+  simpleToC CXCursor_OverloadCandidate                                = #const CXCursor_OverloadCandidate
+
+  simpleFromC (#const CXCursor_UnexposedDecl)                                    = Just CXCursor_UnexposedDecl
+  simpleFromC (#const CXCursor_StructDecl)                                       = Just CXCursor_StructDecl
+  simpleFromC (#const CXCursor_UnionDecl)                                        = Just CXCursor_UnionDecl
+  simpleFromC (#const CXCursor_ClassDecl)                                        = Just CXCursor_ClassDecl
+  simpleFromC (#const CXCursor_EnumDecl)                                         = Just CXCursor_EnumDecl
+  simpleFromC (#const CXCursor_FieldDecl)                                        = Just CXCursor_FieldDecl
+  simpleFromC (#const CXCursor_EnumConstantDecl)                                 = Just CXCursor_EnumConstantDecl
+  simpleFromC (#const CXCursor_FunctionDecl)                                     = Just CXCursor_FunctionDecl
+  simpleFromC (#const CXCursor_VarDecl)                                          = Just CXCursor_VarDecl
+  simpleFromC (#const CXCursor_ParmDecl)                                         = Just CXCursor_ParmDecl
+  simpleFromC (#const CXCursor_ObjCInterfaceDecl)                                = Just CXCursor_ObjCInterfaceDecl
+  simpleFromC (#const CXCursor_ObjCCategoryDecl)                                 = Just CXCursor_ObjCCategoryDecl
+  simpleFromC (#const CXCursor_ObjCProtocolDecl)                                 = Just CXCursor_ObjCProtocolDecl
+  simpleFromC (#const CXCursor_ObjCPropertyDecl)                                 = Just CXCursor_ObjCPropertyDecl
+  simpleFromC (#const CXCursor_ObjCIvarDecl)                                     = Just CXCursor_ObjCIvarDecl
+  simpleFromC (#const CXCursor_ObjCInstanceMethodDecl)                           = Just CXCursor_ObjCInstanceMethodDecl
+  simpleFromC (#const CXCursor_ObjCClassMethodDecl)                              = Just CXCursor_ObjCClassMethodDecl
+  simpleFromC (#const CXCursor_ObjCImplementationDecl)                           = Just CXCursor_ObjCImplementationDecl
+  simpleFromC (#const CXCursor_ObjCCategoryImplDecl)                             = Just CXCursor_ObjCCategoryImplDecl
+  simpleFromC (#const CXCursor_TypedefDecl)                                      = Just CXCursor_TypedefDecl
+  simpleFromC (#const CXCursor_CXXMethod)                                        = Just CXCursor_CXXMethod
+  simpleFromC (#const CXCursor_Namespace)                                        = Just CXCursor_Namespace
+  simpleFromC (#const CXCursor_LinkageSpec)                                      = Just CXCursor_LinkageSpec
+  simpleFromC (#const CXCursor_Constructor)                                      = Just CXCursor_Constructor
+  simpleFromC (#const CXCursor_Destructor)                                       = Just CXCursor_Destructor
+  simpleFromC (#const CXCursor_ConversionFunction)                               = Just CXCursor_ConversionFunction
+  simpleFromC (#const CXCursor_TemplateTypeParameter)                            = Just CXCursor_TemplateTypeParameter
+  simpleFromC (#const CXCursor_NonTypeTemplateParameter)                         = Just CXCursor_NonTypeTemplateParameter
+  simpleFromC (#const CXCursor_TemplateTemplateParameter)                        = Just CXCursor_TemplateTemplateParameter
+  simpleFromC (#const CXCursor_FunctionTemplate)                                 = Just CXCursor_FunctionTemplate
+  simpleFromC (#const CXCursor_ClassTemplate)                                    = Just CXCursor_ClassTemplate
+  simpleFromC (#const CXCursor_ClassTemplatePartialSpecialization)               = Just CXCursor_ClassTemplatePartialSpecialization
+  simpleFromC (#const CXCursor_NamespaceAlias)                                   = Just CXCursor_NamespaceAlias
+  simpleFromC (#const CXCursor_UsingDirective)                                   = Just CXCursor_UsingDirective
+  simpleFromC (#const CXCursor_UsingDeclaration)                                 = Just CXCursor_UsingDeclaration
+  simpleFromC (#const CXCursor_TypeAliasDecl)                                    = Just CXCursor_TypeAliasDecl
+  simpleFromC (#const CXCursor_ObjCSynthesizeDecl)                               = Just CXCursor_ObjCSynthesizeDecl
+  simpleFromC (#const CXCursor_ObjCDynamicDecl)                                  = Just CXCursor_ObjCDynamicDecl
+  simpleFromC (#const CXCursor_CXXAccessSpecifier)                               = Just CXCursor_CXXAccessSpecifier
+  simpleFromC (#const CXCursor_ObjCSuperClassRef)                                = Just CXCursor_ObjCSuperClassRef
+  simpleFromC (#const CXCursor_ObjCProtocolRef)                                  = Just CXCursor_ObjCProtocolRef
+  simpleFromC (#const CXCursor_ObjCClassRef)                                     = Just CXCursor_ObjCClassRef
+  simpleFromC (#const CXCursor_TypeRef)                                          = Just CXCursor_TypeRef
+  simpleFromC (#const CXCursor_CXXBaseSpecifier)                                 = Just CXCursor_CXXBaseSpecifier
+  simpleFromC (#const CXCursor_TemplateRef)                                      = Just CXCursor_TemplateRef
+  simpleFromC (#const CXCursor_NamespaceRef)                                     = Just CXCursor_NamespaceRef
+  simpleFromC (#const CXCursor_MemberRef)                                        = Just CXCursor_MemberRef
+  simpleFromC (#const CXCursor_LabelRef)                                         = Just CXCursor_LabelRef
+  simpleFromC (#const CXCursor_OverloadedDeclRef)                                = Just CXCursor_OverloadedDeclRef
+  simpleFromC (#const CXCursor_VariableRef)                                      = Just CXCursor_VariableRef
+  simpleFromC (#const CXCursor_InvalidFile)                                      = Just CXCursor_InvalidFile
+  simpleFromC (#const CXCursor_NoDeclFound)                                      = Just CXCursor_NoDeclFound
+  simpleFromC (#const CXCursor_NotImplemented)                                   = Just CXCursor_NotImplemented
+  simpleFromC (#const CXCursor_InvalidCode)                                      = Just CXCursor_InvalidCode
+  simpleFromC (#const CXCursor_UnexposedExpr)                                    = Just CXCursor_UnexposedExpr
+  simpleFromC (#const CXCursor_DeclRefExpr)                                      = Just CXCursor_DeclRefExpr
+  simpleFromC (#const CXCursor_MemberRefExpr)                                    = Just CXCursor_MemberRefExpr
+  simpleFromC (#const CXCursor_CallExpr)                                         = Just CXCursor_CallExpr
+  simpleFromC (#const CXCursor_ObjCMessageExpr)                                  = Just CXCursor_ObjCMessageExpr
+  simpleFromC (#const CXCursor_BlockExpr)                                        = Just CXCursor_BlockExpr
+  simpleFromC (#const CXCursor_IntegerLiteral)                                   = Just CXCursor_IntegerLiteral
+  simpleFromC (#const CXCursor_FloatingLiteral)                                  = Just CXCursor_FloatingLiteral
+  simpleFromC (#const CXCursor_ImaginaryLiteral)                                 = Just CXCursor_ImaginaryLiteral
+  simpleFromC (#const CXCursor_StringLiteral)                                    = Just CXCursor_StringLiteral
+  simpleFromC (#const CXCursor_CharacterLiteral)                                 = Just CXCursor_CharacterLiteral
+  simpleFromC (#const CXCursor_ParenExpr)                                        = Just CXCursor_ParenExpr
+  simpleFromC (#const CXCursor_UnaryOperator)                                    = Just CXCursor_UnaryOperator
+  simpleFromC (#const CXCursor_ArraySubscriptExpr)                               = Just CXCursor_ArraySubscriptExpr
+  simpleFromC (#const CXCursor_BinaryOperator)                                   = Just CXCursor_BinaryOperator
+  simpleFromC (#const CXCursor_CompoundAssignOperator)                           = Just CXCursor_CompoundAssignOperator
+  simpleFromC (#const CXCursor_ConditionalOperator)                              = Just CXCursor_ConditionalOperator
+  simpleFromC (#const CXCursor_CStyleCastExpr)                                   = Just CXCursor_CStyleCastExpr
+  simpleFromC (#const CXCursor_CompoundLiteralExpr)                              = Just CXCursor_CompoundLiteralExpr
+  simpleFromC (#const CXCursor_InitListExpr)                                     = Just CXCursor_InitListExpr
+  simpleFromC (#const CXCursor_AddrLabelExpr)                                    = Just CXCursor_AddrLabelExpr
+  simpleFromC (#const CXCursor_StmtExpr)                                         = Just CXCursor_StmtExpr
+  simpleFromC (#const CXCursor_GenericSelectionExpr)                             = Just CXCursor_GenericSelectionExpr
+  simpleFromC (#const CXCursor_GNUNullExpr)                                      = Just CXCursor_GNUNullExpr
+  simpleFromC (#const CXCursor_CXXStaticCastExpr)                                = Just CXCursor_CXXStaticCastExpr
+  simpleFromC (#const CXCursor_CXXDynamicCastExpr)                               = Just CXCursor_CXXDynamicCastExpr
+  simpleFromC (#const CXCursor_CXXReinterpretCastExpr)                           = Just CXCursor_CXXReinterpretCastExpr
+  simpleFromC (#const CXCursor_CXXConstCastExpr)                                 = Just CXCursor_CXXConstCastExpr
+  simpleFromC (#const CXCursor_CXXFunctionalCastExpr)                            = Just CXCursor_CXXFunctionalCastExpr
+  simpleFromC (#const CXCursor_CXXTypeidExpr)                                    = Just CXCursor_CXXTypeidExpr
+  simpleFromC (#const CXCursor_CXXBoolLiteralExpr)                               = Just CXCursor_CXXBoolLiteralExpr
+  simpleFromC (#const CXCursor_CXXNullPtrLiteralExpr)                            = Just CXCursor_CXXNullPtrLiteralExpr
+  simpleFromC (#const CXCursor_CXXThisExpr)                                      = Just CXCursor_CXXThisExpr
+  simpleFromC (#const CXCursor_CXXThrowExpr)                                     = Just CXCursor_CXXThrowExpr
+  simpleFromC (#const CXCursor_CXXNewExpr)                                       = Just CXCursor_CXXNewExpr
+  simpleFromC (#const CXCursor_CXXDeleteExpr)                                    = Just CXCursor_CXXDeleteExpr
+  simpleFromC (#const CXCursor_UnaryExpr)                                        = Just CXCursor_UnaryExpr
+  simpleFromC (#const CXCursor_ObjCStringLiteral)                                = Just CXCursor_ObjCStringLiteral
+  simpleFromC (#const CXCursor_ObjCEncodeExpr)                                   = Just CXCursor_ObjCEncodeExpr
+  simpleFromC (#const CXCursor_ObjCSelectorExpr)                                 = Just CXCursor_ObjCSelectorExpr
+  simpleFromC (#const CXCursor_ObjCProtocolExpr)                                 = Just CXCursor_ObjCProtocolExpr
+  simpleFromC (#const CXCursor_ObjCBridgedCastExpr)                              = Just CXCursor_ObjCBridgedCastExpr
+  simpleFromC (#const CXCursor_PackExpansionExpr)                                = Just CXCursor_PackExpansionExpr
+  simpleFromC (#const CXCursor_SizeOfPackExpr)                                   = Just CXCursor_SizeOfPackExpr
+  simpleFromC (#const CXCursor_LambdaExpr)                                       = Just CXCursor_LambdaExpr
+  simpleFromC (#const CXCursor_ObjCBoolLiteralExpr)                              = Just CXCursor_ObjCBoolLiteralExpr
+  simpleFromC (#const CXCursor_ObjCSelfExpr)                                     = Just CXCursor_ObjCSelfExpr
+  simpleFromC (#const CXCursor_ObjCAvailabilityCheckExpr)                        = Just CXCursor_ObjCAvailabilityCheckExpr
+  simpleFromC (#const CXCursor_FixedPointLiteral)                                = Just CXCursor_FixedPointLiteral
+  simpleFromC (#const CXCursor_OMPArrayShapingExpr)                              = Just CXCursor_OMPArrayShapingExpr
+  simpleFromC (#const CXCursor_OMPIteratorExpr)                                  = Just CXCursor_OMPIteratorExpr
+  simpleFromC (#const CXCursor_CXXAddrspaceCastExpr)                             = Just CXCursor_CXXAddrspaceCastExpr
+  simpleFromC (#const CXCursor_UnexposedStmt)                                    = Just CXCursor_UnexposedStmt
+  simpleFromC (#const CXCursor_LabelStmt)                                        = Just CXCursor_LabelStmt
+  simpleFromC (#const CXCursor_CompoundStmt)                                     = Just CXCursor_CompoundStmt
+  simpleFromC (#const CXCursor_CaseStmt)                                         = Just CXCursor_CaseStmt
+  simpleFromC (#const CXCursor_DefaultStmt)                                      = Just CXCursor_DefaultStmt
+  simpleFromC (#const CXCursor_IfStmt)                                           = Just CXCursor_IfStmt
+  simpleFromC (#const CXCursor_SwitchStmt)                                       = Just CXCursor_SwitchStmt
+  simpleFromC (#const CXCursor_WhileStmt)                                        = Just CXCursor_WhileStmt
+  simpleFromC (#const CXCursor_DoStmt)                                           = Just CXCursor_DoStmt
+  simpleFromC (#const CXCursor_ForStmt)                                          = Just CXCursor_ForStmt
+  simpleFromC (#const CXCursor_GotoStmt)                                         = Just CXCursor_GotoStmt
+  simpleFromC (#const CXCursor_IndirectGotoStmt)                                 = Just CXCursor_IndirectGotoStmt
+  simpleFromC (#const CXCursor_ContinueStmt)                                     = Just CXCursor_ContinueStmt
+  simpleFromC (#const CXCursor_BreakStmt)                                        = Just CXCursor_BreakStmt
+  simpleFromC (#const CXCursor_ReturnStmt)                                       = Just CXCursor_ReturnStmt
+  simpleFromC (#const CXCursor_GCCAsmStmt)                                       = Just CXCursor_GCCAsmStmt
+  simpleFromC (#const CXCursor_ObjCAtTryStmt)                                    = Just CXCursor_ObjCAtTryStmt
+  simpleFromC (#const CXCursor_ObjCAtCatchStmt)                                  = Just CXCursor_ObjCAtCatchStmt
+  simpleFromC (#const CXCursor_ObjCAtFinallyStmt)                                = Just CXCursor_ObjCAtFinallyStmt
+  simpleFromC (#const CXCursor_ObjCAtThrowStmt)                                  = Just CXCursor_ObjCAtThrowStmt
+  simpleFromC (#const CXCursor_ObjCAtSynchronizedStmt)                           = Just CXCursor_ObjCAtSynchronizedStmt
+  simpleFromC (#const CXCursor_ObjCAutoreleasePoolStmt)                          = Just CXCursor_ObjCAutoreleasePoolStmt
+  simpleFromC (#const CXCursor_ObjCForCollectionStmt)                            = Just CXCursor_ObjCForCollectionStmt
+  simpleFromC (#const CXCursor_CXXCatchStmt)                                     = Just CXCursor_CXXCatchStmt
+  simpleFromC (#const CXCursor_CXXTryStmt)                                       = Just CXCursor_CXXTryStmt
+  simpleFromC (#const CXCursor_CXXForRangeStmt)                                  = Just CXCursor_CXXForRangeStmt
+  simpleFromC (#const CXCursor_SEHTryStmt)                                       = Just CXCursor_SEHTryStmt
+  simpleFromC (#const CXCursor_SEHExceptStmt)                                    = Just CXCursor_SEHExceptStmt
+  simpleFromC (#const CXCursor_SEHFinallyStmt)                                   = Just CXCursor_SEHFinallyStmt
+  simpleFromC (#const CXCursor_MSAsmStmt)                                        = Just CXCursor_MSAsmStmt
+  simpleFromC (#const CXCursor_NullStmt)                                         = Just CXCursor_NullStmt
+  simpleFromC (#const CXCursor_DeclStmt)                                         = Just CXCursor_DeclStmt
+  simpleFromC (#const CXCursor_OMPParallelDirective)                             = Just CXCursor_OMPParallelDirective
+  simpleFromC (#const CXCursor_OMPSimdDirective)                                 = Just CXCursor_OMPSimdDirective
+  simpleFromC (#const CXCursor_OMPForDirective)                                  = Just CXCursor_OMPForDirective
+  simpleFromC (#const CXCursor_OMPSectionsDirective)                             = Just CXCursor_OMPSectionsDirective
+  simpleFromC (#const CXCursor_OMPSectionDirective)                              = Just CXCursor_OMPSectionDirective
+  simpleFromC (#const CXCursor_OMPSingleDirective)                               = Just CXCursor_OMPSingleDirective
+  simpleFromC (#const CXCursor_OMPParallelForDirective)                          = Just CXCursor_OMPParallelForDirective
+  simpleFromC (#const CXCursor_OMPParallelSectionsDirective)                     = Just CXCursor_OMPParallelSectionsDirective
+  simpleFromC (#const CXCursor_OMPTaskDirective)                                 = Just CXCursor_OMPTaskDirective
+  simpleFromC (#const CXCursor_OMPMasterDirective)                               = Just CXCursor_OMPMasterDirective
+  simpleFromC (#const CXCursor_OMPCriticalDirective)                             = Just CXCursor_OMPCriticalDirective
+  simpleFromC (#const CXCursor_OMPTaskyieldDirective)                            = Just CXCursor_OMPTaskyieldDirective
+  simpleFromC (#const CXCursor_OMPBarrierDirective)                              = Just CXCursor_OMPBarrierDirective
+  simpleFromC (#const CXCursor_OMPTaskwaitDirective)                             = Just CXCursor_OMPTaskwaitDirective
+  simpleFromC (#const CXCursor_OMPFlushDirective)                                = Just CXCursor_OMPFlushDirective
+  simpleFromC (#const CXCursor_SEHLeaveStmt)                                     = Just CXCursor_SEHLeaveStmt
+  simpleFromC (#const CXCursor_OMPOrderedDirective)                              = Just CXCursor_OMPOrderedDirective
+  simpleFromC (#const CXCursor_OMPAtomicDirective)                               = Just CXCursor_OMPAtomicDirective
+  simpleFromC (#const CXCursor_OMPForSimdDirective)                              = Just CXCursor_OMPForSimdDirective
+  simpleFromC (#const CXCursor_OMPParallelForSimdDirective)                      = Just CXCursor_OMPParallelForSimdDirective
+  simpleFromC (#const CXCursor_OMPTargetDirective)                               = Just CXCursor_OMPTargetDirective
+  simpleFromC (#const CXCursor_OMPTeamsDirective)                                = Just CXCursor_OMPTeamsDirective
+  simpleFromC (#const CXCursor_OMPTaskgroupDirective)                            = Just CXCursor_OMPTaskgroupDirective
+  simpleFromC (#const CXCursor_OMPCancellationPointDirective)                    = Just CXCursor_OMPCancellationPointDirective
+  simpleFromC (#const CXCursor_OMPCancelDirective)                               = Just CXCursor_OMPCancelDirective
+  simpleFromC (#const CXCursor_OMPTargetDataDirective)                           = Just CXCursor_OMPTargetDataDirective
+  simpleFromC (#const CXCursor_OMPTaskLoopDirective)                             = Just CXCursor_OMPTaskLoopDirective
+  simpleFromC (#const CXCursor_OMPTaskLoopSimdDirective)                         = Just CXCursor_OMPTaskLoopSimdDirective
+  simpleFromC (#const CXCursor_OMPDistributeDirective)                           = Just CXCursor_OMPDistributeDirective
+  simpleFromC (#const CXCursor_OMPTargetEnterDataDirective)                      = Just CXCursor_OMPTargetEnterDataDirective
+  simpleFromC (#const CXCursor_OMPTargetExitDataDirective)                       = Just CXCursor_OMPTargetExitDataDirective
+  simpleFromC (#const CXCursor_OMPTargetParallelDirective)                       = Just CXCursor_OMPTargetParallelDirective
+  simpleFromC (#const CXCursor_OMPTargetParallelForDirective)                    = Just CXCursor_OMPTargetParallelForDirective
+  simpleFromC (#const CXCursor_OMPTargetUpdateDirective)                         = Just CXCursor_OMPTargetUpdateDirective
+  simpleFromC (#const CXCursor_OMPDistributeParallelForDirective)                = Just CXCursor_OMPDistributeParallelForDirective
+  simpleFromC (#const CXCursor_OMPDistributeParallelForSimdDirective)            = Just CXCursor_OMPDistributeParallelForSimdDirective
+  simpleFromC (#const CXCursor_OMPDistributeSimdDirective)                       = Just CXCursor_OMPDistributeSimdDirective
+  simpleFromC (#const CXCursor_OMPTargetParallelForSimdDirective)                = Just CXCursor_OMPTargetParallelForSimdDirective
+  simpleFromC (#const CXCursor_OMPTargetSimdDirective)                           = Just CXCursor_OMPTargetSimdDirective
+  simpleFromC (#const CXCursor_OMPTeamsDistributeDirective)                      = Just CXCursor_OMPTeamsDistributeDirective
+  simpleFromC (#const CXCursor_OMPTeamsDistributeSimdDirective)                  = Just CXCursor_OMPTeamsDistributeSimdDirective
+  simpleFromC (#const CXCursor_OMPTeamsDistributeParallelForSimdDirective)       = Just CXCursor_OMPTeamsDistributeParallelForSimdDirective
+  simpleFromC (#const CXCursor_OMPTeamsDistributeParallelForDirective)           = Just CXCursor_OMPTeamsDistributeParallelForDirective
+  simpleFromC (#const CXCursor_OMPTargetTeamsDirective)                          = Just CXCursor_OMPTargetTeamsDirective
+  simpleFromC (#const CXCursor_OMPTargetTeamsDistributeDirective)                = Just CXCursor_OMPTargetTeamsDistributeDirective
+  simpleFromC (#const CXCursor_OMPTargetTeamsDistributeParallelForDirective)     = Just CXCursor_OMPTargetTeamsDistributeParallelForDirective
+  simpleFromC (#const CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective) = Just CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective
+  simpleFromC (#const CXCursor_OMPTargetTeamsDistributeSimdDirective)            = Just CXCursor_OMPTargetTeamsDistributeSimdDirective
+  simpleFromC (#const CXCursor_BuiltinBitCastExpr)                               = Just CXCursor_BuiltinBitCastExpr
+  simpleFromC (#const CXCursor_OMPMasterTaskLoopDirective)                       = Just CXCursor_OMPMasterTaskLoopDirective
+  simpleFromC (#const CXCursor_OMPParallelMasterTaskLoopDirective)               = Just CXCursor_OMPParallelMasterTaskLoopDirective
+  simpleFromC (#const CXCursor_OMPMasterTaskLoopSimdDirective)                   = Just CXCursor_OMPMasterTaskLoopSimdDirective
+  simpleFromC (#const CXCursor_OMPParallelMasterTaskLoopSimdDirective)           = Just CXCursor_OMPParallelMasterTaskLoopSimdDirective
+  simpleFromC (#const CXCursor_OMPParallelMasterDirective)                       = Just CXCursor_OMPParallelMasterDirective
+  simpleFromC (#const CXCursor_OMPDepobjDirective)                               = Just CXCursor_OMPDepobjDirective
+  simpleFromC (#const CXCursor_OMPScanDirective)                                 = Just CXCursor_OMPScanDirective
+  simpleFromC (#const CXCursor_OMPTileDirective)                                 = Just CXCursor_OMPTileDirective
+  simpleFromC (#const CXCursor_OMPCanonicalLoop)                                 = Just CXCursor_OMPCanonicalLoop
+  simpleFromC (#const CXCursor_OMPInteropDirective)                              = Just CXCursor_OMPInteropDirective
+  simpleFromC (#const CXCursor_OMPDispatchDirective)                             = Just CXCursor_OMPDispatchDirective
+  simpleFromC (#const CXCursor_OMPMaskedDirective)                               = Just CXCursor_OMPMaskedDirective
+  simpleFromC (#const CXCursor_OMPUnrollDirective)                               = Just CXCursor_OMPUnrollDirective
+  simpleFromC (#const CXCursor_OMPMetaDirective)                                 = Just CXCursor_OMPMetaDirective
+  simpleFromC (#const CXCursor_OMPGenericLoopDirective)                          = Just CXCursor_OMPGenericLoopDirective
+  simpleFromC (#const CXCursor_TranslationUnit)                                  = Just CXCursor_TranslationUnit
+  simpleFromC (#const CXCursor_UnexposedAttr)                                    = Just CXCursor_UnexposedAttr
+  simpleFromC (#const CXCursor_IBActionAttr)                                     = Just CXCursor_IBActionAttr
+  simpleFromC (#const CXCursor_IBOutletAttr)                                     = Just CXCursor_IBOutletAttr
+  simpleFromC (#const CXCursor_IBOutletCollectionAttr)                           = Just CXCursor_IBOutletCollectionAttr
+  simpleFromC (#const CXCursor_CXXFinalAttr)                                     = Just CXCursor_CXXFinalAttr
+  simpleFromC (#const CXCursor_CXXOverrideAttr)                                  = Just CXCursor_CXXOverrideAttr
+  simpleFromC (#const CXCursor_AnnotateAttr)                                     = Just CXCursor_AnnotateAttr
+  simpleFromC (#const CXCursor_AsmLabelAttr)                                     = Just CXCursor_AsmLabelAttr
+  simpleFromC (#const CXCursor_PackedAttr)                                       = Just CXCursor_PackedAttr
+  simpleFromC (#const CXCursor_PureAttr)                                         = Just CXCursor_PureAttr
+  simpleFromC (#const CXCursor_ConstAttr)                                        = Just CXCursor_ConstAttr
+  simpleFromC (#const CXCursor_NoDuplicateAttr)                                  = Just CXCursor_NoDuplicateAttr
+  simpleFromC (#const CXCursor_CUDAConstantAttr)                                 = Just CXCursor_CUDAConstantAttr
+  simpleFromC (#const CXCursor_CUDADeviceAttr)                                   = Just CXCursor_CUDADeviceAttr
+  simpleFromC (#const CXCursor_CUDAGlobalAttr)                                   = Just CXCursor_CUDAGlobalAttr
+  simpleFromC (#const CXCursor_CUDAHostAttr)                                     = Just CXCursor_CUDAHostAttr
+  simpleFromC (#const CXCursor_CUDASharedAttr)                                   = Just CXCursor_CUDASharedAttr
+  simpleFromC (#const CXCursor_VisibilityAttr)                                   = Just CXCursor_VisibilityAttr
+  simpleFromC (#const CXCursor_DLLExport)                                        = Just CXCursor_DLLExport
+  simpleFromC (#const CXCursor_DLLImport)                                        = Just CXCursor_DLLImport
+  simpleFromC (#const CXCursor_NSReturnsRetained)                                = Just CXCursor_NSReturnsRetained
+  simpleFromC (#const CXCursor_NSReturnsNotRetained)                             = Just CXCursor_NSReturnsNotRetained
+  simpleFromC (#const CXCursor_NSReturnsAutoreleased)                            = Just CXCursor_NSReturnsAutoreleased
+  simpleFromC (#const CXCursor_NSConsumesSelf)                                   = Just CXCursor_NSConsumesSelf
+  simpleFromC (#const CXCursor_NSConsumed)                                       = Just CXCursor_NSConsumed
+  simpleFromC (#const CXCursor_ObjCException)                                    = Just CXCursor_ObjCException
+  simpleFromC (#const CXCursor_ObjCNSObject)                                     = Just CXCursor_ObjCNSObject
+  simpleFromC (#const CXCursor_ObjCIndependentClass)                             = Just CXCursor_ObjCIndependentClass
+  simpleFromC (#const CXCursor_ObjCPreciseLifetime)                              = Just CXCursor_ObjCPreciseLifetime
+  simpleFromC (#const CXCursor_ObjCReturnsInnerPointer)                          = Just CXCursor_ObjCReturnsInnerPointer
+  simpleFromC (#const CXCursor_ObjCRequiresSuper)                                = Just CXCursor_ObjCRequiresSuper
+  simpleFromC (#const CXCursor_ObjCRootClass)                                    = Just CXCursor_ObjCRootClass
+  simpleFromC (#const CXCursor_ObjCSubclassingRestricted)                        = Just CXCursor_ObjCSubclassingRestricted
+  simpleFromC (#const CXCursor_ObjCExplicitProtocolImpl)                         = Just CXCursor_ObjCExplicitProtocolImpl
+  simpleFromC (#const CXCursor_ObjCDesignatedInitializer)                        = Just CXCursor_ObjCDesignatedInitializer
+  simpleFromC (#const CXCursor_ObjCRuntimeVisible)                               = Just CXCursor_ObjCRuntimeVisible
+  simpleFromC (#const CXCursor_ObjCBoxable)                                      = Just CXCursor_ObjCBoxable
+  simpleFromC (#const CXCursor_FlagEnum)                                         = Just CXCursor_FlagEnum
+  simpleFromC (#const CXCursor_ConvergentAttr)                                   = Just CXCursor_ConvergentAttr
+  simpleFromC (#const CXCursor_WarnUnusedAttr)                                   = Just CXCursor_WarnUnusedAttr
+  simpleFromC (#const CXCursor_WarnUnusedResultAttr)                             = Just CXCursor_WarnUnusedResultAttr
+  simpleFromC (#const CXCursor_AlignedAttr)                                      = Just CXCursor_AlignedAttr
+  simpleFromC (#const CXCursor_PreprocessingDirective)                           = Just CXCursor_PreprocessingDirective
+  simpleFromC (#const CXCursor_MacroDefinition)                                  = Just CXCursor_MacroDefinition
+  simpleFromC (#const CXCursor_MacroExpansion)                                   = Just CXCursor_MacroExpansion
+  simpleFromC (#const CXCursor_InclusionDirective)                               = Just CXCursor_InclusionDirective
+  simpleFromC (#const CXCursor_ModuleImportDecl)                                 = Just CXCursor_ModuleImportDecl
+  simpleFromC (#const CXCursor_TypeAliasTemplateDecl)                            = Just CXCursor_TypeAliasTemplateDecl
+  simpleFromC (#const CXCursor_StaticAssert)                                     = Just CXCursor_StaticAssert
+  simpleFromC (#const CXCursor_FriendDecl)                                       = Just CXCursor_FriendDecl
+  simpleFromC (#const CXCursor_OverloadCandidate)                                = Just CXCursor_OverloadCandidate
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXDiagnosticDisplayOptions
+-------------------------------------------------------------------------------}
+
+instance IsSingleFlag CXDiagnosticDisplayOptions where
+  flagToC CXDiagnostic_DisplaySourceLocation = #const CXDiagnostic_DisplaySourceLocation
+  flagToC CXDiagnostic_DisplayColumn         = #const CXDiagnostic_DisplayColumn
+  flagToC CXDiagnostic_DisplaySourceRanges   = #const CXDiagnostic_DisplaySourceRanges
+  flagToC CXDiagnostic_DisplayOption         = #const CXDiagnostic_DisplayOption
+  flagToC CXDiagnostic_DisplayCategoryId     = #const CXDiagnostic_DisplayCategoryId
+  flagToC CXDiagnostic_DisplayCategoryName   = #const CXDiagnostic_DisplayCategoryName
+
+{-------------------------------------------------------------------------------
+  CXDiagnosticSeverity
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXDiagnosticSeverity where
+  simpleToC CXDiagnostic_Ignored  = #const CXDiagnostic_Ignored
+  simpleToC CXDiagnostic_Note     = #const CXDiagnostic_Note
+  simpleToC CXDiagnostic_Warning  = #const CXDiagnostic_Warning
+  simpleToC CXDiagnostic_Error    = #const CXDiagnostic_Error
+  simpleToC CXDiagnostic_Fatal    = #const CXDiagnostic_Fatal
+
+  simpleFromC (#const CXDiagnostic_Ignored) = Just CXDiagnostic_Ignored
+  simpleFromC (#const CXDiagnostic_Note)    = Just CXDiagnostic_Note
+  simpleFromC (#const CXDiagnostic_Warning) = Just CXDiagnostic_Warning
+  simpleFromC (#const CXDiagnostic_Error)   = Just CXDiagnostic_Error
+  simpleFromC (#const CXDiagnostic_Fatal)   = Just CXDiagnostic_Fatal
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CX_StorageClass
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CX_StorageClass where
+  simpleToC CX_SC_None                 = #const CX_SC_None
+  simpleToC CX_SC_Extern               = #const CX_SC_Extern
+  simpleToC CX_SC_Static               = #const CX_SC_Static
+  simpleToC CX_SC_PrivateExtern        = #const CX_SC_PrivateExtern
+  simpleToC CX_SC_OpenCLWorkGroupLocal = #const CX_SC_OpenCLWorkGroupLocal
+  simpleToC CX_SC_Auto                 = #const CX_SC_Auto
+  simpleToC CX_SC_Register             = #const CX_SC_Register
+
+  simpleFromC (#const CX_SC_None)                 = Just CX_SC_None
+  simpleFromC (#const CX_SC_Extern)               = Just CX_SC_Extern
+  simpleFromC (#const CX_SC_Static)               = Just CX_SC_Static
+  simpleFromC (#const CX_SC_PrivateExtern)        = Just CX_SC_PrivateExtern
+  simpleFromC (#const CX_SC_OpenCLWorkGroupLocal) = Just CX_SC_OpenCLWorkGroupLocal
+  simpleFromC (#const CX_SC_Auto)                 = Just CX_SC_Auto
+  simpleFromC (#const CX_SC_Register)             = Just CX_SC_Register
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXLinkageKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXLinkageKind where
+  simpleToC CXLinkage_Invalid        = #const CXLinkage_Invalid
+  simpleToC CXLinkage_NoLinkage      = #const CXLinkage_NoLinkage
+  simpleToC CXLinkage_Internal       = #const CXLinkage_Internal
+  simpleToC CXLinkage_UniqueExternal = #const CXLinkage_UniqueExternal
+  simpleToC CXLinkage_External       = #const CXLinkage_External
+
+  simpleFromC (#const CXLinkage_Invalid)        = Just CXLinkage_Invalid
+  simpleFromC (#const CXLinkage_NoLinkage)      = Just CXLinkage_NoLinkage
+  simpleFromC (#const CXLinkage_Internal)       = Just CXLinkage_Internal
+  simpleFromC (#const CXLinkage_UniqueExternal) = Just CXLinkage_UniqueExternal
+  simpleFromC (#const CXLinkage_External)       = Just CXLinkage_External
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXTLSKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXTLSKind where
+  simpleToC CXTLS_None    = #const CXTLS_None
+  simpleToC CXTLS_Dynamic = #const CXTLS_Dynamic
+  simpleToC CXTLS_Static  = #const CXTLS_Static
+
+  simpleFromC (#const CXTLS_None)    = Just CXTLS_None
+  simpleFromC (#const CXTLS_Dynamic) = Just CXTLS_Dynamic
+  simpleFromC (#const CXTLS_Static)  = Just CXTLS_Static
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXVisibilityKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXVisibilityKind where
+  simpleToC CXVisibility_Invalid   = #const CXVisibility_Invalid
+  simpleToC CXVisibility_Hidden    = #const CXVisibility_Hidden
+  simpleToC CXVisibility_Protected = #const CXVisibility_Protected
+  simpleToC CXVisibility_Default   = #const CXVisibility_Default
+
+  simpleFromC (#const CXVisibility_Invalid)   = Just CXVisibility_Invalid
+  simpleFromC (#const CXVisibility_Hidden)    = Just CXVisibility_Hidden
+  simpleFromC (#const CXVisibility_Protected) = Just CXVisibility_Protected
+  simpleFromC (#const CXVisibility_Default)   = Just CXVisibility_Default
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXAvailabilityKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXAvailabilityKind where
+  simpleToC CXAvailability_Available     = #const CXAvailability_Available
+  simpleToC CXAvailability_Deprecated    = #const CXAvailability_Deprecated
+  simpleToC CXAvailability_NotAvailable  = #const CXAvailability_NotAvailable
+  simpleToC CXAvailability_NotAccessible = #const CXAvailability_NotAccessible
+
+  simpleFromC (#const CXAvailability_Available)     = Just CXAvailability_Available
+  simpleFromC (#const CXAvailability_Deprecated)    = Just CXAvailability_Deprecated
+  simpleFromC (#const CXAvailability_NotAvailable)  = Just CXAvailability_NotAvailable
+  simpleFromC (#const CXAvailability_NotAccessible) = Just CXAvailability_NotAccessible
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXEvalResultKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXEvalResultKind where
+  simpleToC CXEval_Int            = #const CXEval_Int
+  simpleToC CXEval_Float          = #const CXEval_Float
+  simpleToC CXEval_ObjCStrLiteral = #const CXEval_ObjCStrLiteral
+  simpleToC CXEval_StrLiteral     = #const CXEval_StrLiteral
+  simpleToC CXEval_CFStr          = #const CXEval_CFStr
+  simpleToC CXEval_Other          = #const CXEval_Other
+  simpleToC CXEval_UnExposed      = #const CXEval_UnExposed
+
+  simpleFromC (#const CXEval_Int)            = Just CXEval_Int
+  simpleFromC (#const CXEval_Float)          = Just CXEval_Float
+  simpleFromC (#const CXEval_ObjCStrLiteral) = Just CXEval_ObjCStrLiteral
+  simpleFromC (#const CXEval_StrLiteral)     = Just CXEval_StrLiteral
+  simpleFromC (#const CXEval_CFStr)          = Just CXEval_CFStr
+  simpleFromC (#const CXEval_Other)          = Just CXEval_Other
+  simpleFromC (#const CXEval_UnExposed)      = Just CXEval_UnExposed
+
+  simpleFromC _otherwise                     = Nothing
diff --git a/src/Clang/LowLevel/Core/Pointers.hs b/src/Clang/LowLevel/Core/Pointers.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Core/Pointers.hs
@@ -0,0 +1,104 @@
+module Clang.LowLevel.Core.Pointers (
+    CXIndex(..)
+  , CXTranslationUnit(..)
+  , CXTargetInfo(..)
+  , CXFile(..)
+  , CXPrintingPolicy(..)
+  , CXEvalResult(..)
+  , CXDiagnostic(..)
+  , CXDiagnosticSet(..)
+  ) where
+
+import Foreign
+
+import Clang.Internal.Results
+
+{-------------------------------------------------------------------------------
+  CXIndex
+-------------------------------------------------------------------------------}
+
+-- | An "index" that consists of a set of translation units that would typically
+-- be linked together into an executable or library.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gae039c2574bfd75774ca7a9a3e55910cb>
+newtype {-# CType "CXIndex" #-} CXIndex = CXIndex (Ptr ())
+  deriving stock (Show)
+
+{-------------------------------------------------------------------------------
+  CXTranslationUnit
+-------------------------------------------------------------------------------}
+
+-- | A single translation unit, which resides in an index.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#gacdb7815736ca709ce9a5e1ec2b7e16ac>
+newtype {-# CType "CXTranslationUnit" #-} CXTranslationUnit = CXTranslationUnit (Ptr ())
+  deriving stock (Show)
+  deriving newtype (Storable, IsNullPtr)
+
+{-------------------------------------------------------------------------------
+  CXTargetInfo
+-------------------------------------------------------------------------------}
+
+-- | An opaque type representing target information for a given translation
+-- unit.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html#ga6b47552ab8c5d81387070a9b197cd3e2>
+newtype {-# CType "CXTargetInfo" #-} CXTargetInfo = CXTargetInfo (Ptr ())
+  deriving stock (Show)
+
+{-------------------------------------------------------------------------------
+  CXFile
+-------------------------------------------------------------------------------}
+
+-- | A particular source file that is part of a translation unit.
+--
+-- NOTE: Equality on 'CXFile' is /pointer/ equality.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html#gacfcea9c1239c916597e2e5b3e109215a>
+newtype {-# CType "CXFile" #-} CXFile = CXFile (Ptr ())
+  deriving stock (Show, Eq)
+  deriving newtype (Storable, IsNullPtr)
+
+{-------------------------------------------------------------------------------
+  CXPrintingPolicy
+-------------------------------------------------------------------------------}
+
+-- | Opaque pointer representing a policy that controls pretty printing for
+-- clang_getCursorPrettyPrinted.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html#ga7944a70cf590a5939acfb760df5ed3b6>
+newtype {-# CType "CXPrintingPolicy" #-} CXPrintingPolicy = CXPrintingPolicy (Ptr ())
+  deriving stock (Show)
+  deriving newtype (Storable)
+
+{-------------------------------------------------------------------------------
+  CXEvalResult
+-------------------------------------------------------------------------------}
+
+-- | An opaque type representing an evaluation result
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html#gaa9270afc68877e1f3b20ce5b343191bc>
+newtype {-# CType "CXEvalResult" #-} CXEvalResult = CXEvalResult (Ptr ())
+  deriving stock (Show)
+  deriving newtype (Storable)
+
+{-------------------------------------------------------------------------------
+  CXDiagnostic
+-------------------------------------------------------------------------------}
+
+-- | A single diagnostic, containing the diagnostic's severity, location, text,
+-- source ranges, and fix-it hints.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga44bb8aba7c40590ad25d1763c4fbff7f>
+newtype {-# CType "CXDiagnostic" #-} CXDiagnostic = CXDiagnostic (Ptr ())
+  deriving stock (Show)
+  deriving newtype (Storable)
+
+{-------------------------------------------------------------------------------
+  CXDiagnosticSet
+-------------------------------------------------------------------------------}
+
+-- | A group of CXDiagnostics.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html#ga38dfc0ae45b55bf7fd577eed9148e244>
+newtype {-# CType "CXDiagnosticSet" #-} CXDiagnosticSet = CXDiagnosticSet (Ptr ())
diff --git a/src/Clang/LowLevel/Core/Structs.hsc b/src/Clang/LowLevel/Core/Structs.hsc
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Core/Structs.hsc
@@ -0,0 +1,62 @@
+{-# LANGUAGE RecordWildCards #-}
+
+module Clang.LowLevel.Core.Structs (
+    CXCursor_
+  , CXSourceLocation_
+  , CXSourceRange_
+  , CXString_
+  , CXToken_
+  , CXType_
+  , CXUnsavedFile(..)
+  ) where
+
+import Foreign.C.String
+import Foreign.C.Types
+import Foreign.Storable
+
+#include <clang-c/Index.h>
+
+-- | <https://clang.llvm.org/doxygen/structCXCursor.html>
+data {-# CType "CXCursor" #-} CXCursor_
+
+-- | <https://clang.llvm.org/doxygen/structCXSourceLocation.html>
+data {-# CType "CXSourceLocation" #-} CXSourceLocation_
+
+-- | <https://clang.llvm.org/doxygen/structCXSourceRange.html>
+data {-# CType "CXSourceRange" #-} CXSourceRange_
+
+-- | <https://clang.llvm.org/doxygen/structCXString.html>
+data {-# CType "CXString" #-} CXString_
+
+-- | <https://clang.llvm.org/doxygen/structCXToken.html>
+data {-# CType "CXToken" #-} CXToken_
+
+-- | <https://clang.llvm.org/doxygen/structCXType.html>
+data {-# CType "CXType" #-} CXType_
+
+-- | Provides the contents of a file that has not yet been saved to disk.
+--
+-- Each 'CXUnsavedFile' instance provides the name of a file on the system along
+-- with the current contents of that file that have not yet been saved to disk.
+--
+-- <https://clang.llvm.org/doxygen/structCXUnsavedFile.html>
+data {-# CType "struct CXUnsavedFile" #-} CXUnsavedFile = CXUnsavedFile {
+      cxUnsavedFileFilename :: CString
+    , cxUnsavedFileContents :: CString
+    , cxUnsavedFileLength   :: CULong
+    }
+
+instance Storable CXUnsavedFile where
+  sizeOf    _ = #size      struct CXUnsavedFile
+  alignment _ = #alignment struct CXUnsavedFile
+
+  peek ptr = do
+    cxUnsavedFileFilename <- (#peek struct CXUnsavedFile, Filename) ptr
+    cxUnsavedFileContents <- (#peek struct CXUnsavedFile, Contents) ptr
+    cxUnsavedFileLength   <- (#peek struct CXUnsavedFile, Length)   ptr
+    return CXUnsavedFile{..}
+
+  poke ptr CXUnsavedFile{..} = do
+    (#poke struct CXUnsavedFile, Filename) ptr cxUnsavedFileFilename
+    (#poke struct CXUnsavedFile, Contents) ptr cxUnsavedFileContents
+    (#poke struct CXUnsavedFile, Length)   ptr cxUnsavedFileLength
diff --git a/src/Clang/LowLevel/Doxygen.hs b/src/Clang/LowLevel/Doxygen.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Doxygen.hs
@@ -0,0 +1,594 @@
+-- | Doxygen support
+--
+-- The routines in this group provide access to information in documentation
+-- comments.
+--
+-- These facilities are distinct from the core and may be subject to their own
+-- schedule of stability and deprecation.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html>
+module Clang.LowLevel.Doxygen (
+    -- * Top-level
+    CXComment
+  , CXCommentKind(..)
+  , clang_Cursor_getParsedComment
+  , clang_Comment_getKind
+  , clang_Comment_getNumChildren
+  , clang_Comment_getChild
+  , clang_Comment_isWhitespace
+  , clang_InlineContentComment_hasTrailingNewline
+    -- * Comment type 'CXComment_Text'
+  , clang_TextComment_getText
+    -- * Comment type 'CXComment_InlineCommand'
+  , CXCommentInlineCommandRenderKind(..)
+  , clang_InlineCommandComment_getCommandName
+  , clang_InlineCommandComment_getRenderKind
+  , clang_InlineCommandComment_getNumArgs
+  , clang_InlineCommandComment_getArgText
+    -- * Comment type 'CXComment_HTMLStartTag' and 'CXComment_HTMLEndTag'
+  , clang_HTMLTagComment_getTagName
+  , clang_HTMLStartTagComment_isSelfClosing
+  , clang_HTMLStartTag_getNumAttrs
+  , clang_HTMLStartTag_getAttrName
+  , clang_HTMLStartTag_getAttrValue
+  , clang_HTMLTagComment_getAsString
+    -- * Comment type 'CXComment_BlockCommand'
+  , clang_BlockCommandComment_getCommandName
+  , clang_BlockCommandComment_getNumArgs
+  , clang_BlockCommandComment_getArgText
+  , clang_BlockCommandComment_getParagraph
+    -- * Comment type 'CXComment_ParamCommand'
+  , CXCommentParamPassDirection(..)
+  , clang_ParamCommandComment_getParamName
+  , clang_ParamCommandComment_isParamIndexValid
+  , clang_ParamCommandComment_getParamIndex
+  , clang_ParamCommandComment_isDirectionExplicit
+  , clang_ParamCommandComment_getDirection
+    -- * Comment type 'CXComment_TParamCommand'
+  , clang_TParamCommandComment_getParamName
+  , clang_TParamCommandComment_isParamPositionValid
+  , clang_TParamCommandComment_getDepth
+  , clang_TParamCommandComment_getIndex
+    -- * Comment type 'CXComment_VerbatimBlockLine'
+  , clang_VerbatimBlockLineComment_getText
+    -- * Comment type 'CXComment_VerbatimLine'
+  , clang_VerbatimLineComment_getText
+    -- * Comment type 'CXComment_FullComment'
+  , clang_FullComment_getAsHTML
+  , clang_FullComment_getAsXML
+  ) where
+
+import Control.Monad.IO.Class
+import Data.Text (Text)
+import Foreign.C
+
+import Clang.Enum.Simple
+import Clang.Internal.ByValue
+import Clang.Internal.CXString ()
+import Clang.Internal.Results
+import Clang.LowLevel.Core
+import Clang.LowLevel.Core.Structs
+import Clang.LowLevel.Doxygen.Enums
+import Clang.LowLevel.Doxygen.Instances ()
+import Clang.LowLevel.Doxygen.Structs
+
+{-------------------------------------------------------------------------------
+  Top-level
+-------------------------------------------------------------------------------}
+
+-- | A parsed comment.
+newtype CXComment = CXComment (OnHaskellHeap CXComment_)
+  deriving newtype (LivesOnHaskellHeap, Preallocate)
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_Cursor_getParsedComment"
+  wrap_Cursor_getParsedComment :: R CXCursor_ -> W CXComment_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_Comment_getKind"
+  wrap_Comment_getKind :: R CXComment_ -> IO (SimpleEnum CXCommentKind)
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_Comment_getNumChildren"
+  wrap_Comment_getNumChildren :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_Comment_getChild"
+  wrap_Comment_getChild :: R CXComment_ -> CUInt -> W CXComment_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_Comment_isWhitespace"
+  wrap_Comment_isWhitespace :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_InlineContentComment_hasTrailingNewline"
+  wrap_InlineContentComment_hasTrailingNewline :: R CXComment_ -> IO CUInt
+
+-- | Given a cursor that represents a documentable entity (e.g., declaration),
+-- return the associated parsed comment as a 'CXComment_FullComment' AST node.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gab4f95ae3b2e0bd63b10cecc3727a391e>
+clang_Cursor_getParsedComment :: MonadIO m => CXCursor -> m CXComment
+clang_Cursor_getParsedComment cursor = liftIO $
+    onHaskellHeap cursor $ \cursor' ->
+      preallocate_ $ wrap_Cursor_getParsedComment cursor'
+
+-- | Get the type of an AST node of any kind
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gad7f2a27ab2f69abcb9442e05a21a130f>
+clang_Comment_getKind ::
+     MonadIO m
+  => CXComment -- ^ AST node of any kind
+  -> m (SimpleEnum CXCommentKind)
+clang_Comment_getKind comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_Comment_getKind comment'
+
+-- | Get the number of children of the AST node.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gaad4eba69493735a4db462bb4b5bed97a>
+clang_Comment_getNumChildren ::
+     MonadIO m
+  => CXComment -- ^ AST node of any kind
+  -> m CUInt
+clang_Comment_getNumChildren comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_Comment_getNumChildren comment'
+
+-- | Get the specified child of the AST node.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gad5567ecc26b083562e42b83170c105aa>
+clang_Comment_getChild ::
+     MonadIO m
+  => CXComment -- ^ AST node of any kind
+  -> CUInt     -- ^ child index (zero-based)
+  -> m CXComment
+clang_Comment_getChild comment childIdx = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_Comment_getChild comment' childIdx
+
+-- | Determine whether the comment is considered whitespace.
+--
+-- A @CXComment_Paragraph@ node is considered whitespace if it contains only
+-- @CXComment_Text@ nodes that are empty or whitespace.
+--
+-- Other AST nodes (except @CXComment_Paragraph@ and @CXComment_Text@) are
+-- never considered whitespace.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga1193c1dc798aecad92cb30cea78bf71e>
+clang_Comment_isWhitespace :: MonadIO m => CXComment -> m Bool
+clang_Comment_isWhitespace comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      cToBool <$> wrap_Comment_isWhitespace comment'
+
+-- | Determine whether the comment is inline content and has a newline
+-- immediately following it in the comment text.
+--
+-- Newlines between paragraphs do not count.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gacbc2924271ca86226c024e859e0a75c8>
+clang_InlineContentComment_hasTrailingNewline ::
+     MonadIO m
+  => CXComment -> m Bool
+clang_InlineContentComment_hasTrailingNewline comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      cToBool <$> wrap_InlineContentComment_hasTrailingNewline comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_Text'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_TextComment_getText"
+  wrap_TextComment_getText :: R CXComment_ -> W CXString_ -> IO ()
+
+-- | Get the text contained in the AST node.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gae9a27e851356181beac36bbff6e638e2>
+clang_TextComment_getText :: MonadIO m => CXComment -> m Text
+clang_TextComment_getText comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_TextComment_getText comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_InlineCommand'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_InlineCommandComment_getCommandName"
+  wrap_InlineCommandComment_getCommandName ::
+       R CXComment_
+    -> W CXString_
+    -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_InlineCommandComment_getRenderKind"
+  wrap_InlineCommandComment_getRenderKind ::
+       R CXComment_
+    -> IO (SimpleEnum CXCommentInlineCommandRenderKind)
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_InlineCommandComment_getNumArgs"
+  wrap_InlineCommandComment_getNumArgs :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_InlineCommandComment_getArgText"
+  wrap_InlineCommandComment_getArgText ::
+       R CXComment_
+    -> CUInt
+    -> W CXString_
+    -> IO ()
+
+-- | Get the name of the inline command.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga77f5b160e7d73190ac518298c1e79d05>
+clang_InlineCommandComment_getCommandName :: MonadIO m => CXComment -> m Text
+clang_InlineCommandComment_getCommandName comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_InlineCommandComment_getCommandName comment'
+
+-- | Get the most appropriate rendering mode, chosen on command semantics in
+-- Doxygen.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga3dd54ce1288d09c408cac8c887da2ebd>
+clang_InlineCommandComment_getRenderKind ::
+     MonadIO m
+  => CXComment
+  -> m (SimpleEnum CXCommentInlineCommandRenderKind)
+clang_InlineCommandComment_getRenderKind comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_InlineCommandComment_getRenderKind comment'
+
+-- | Get the number of command arguments.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga78db1049239be9649c2829cdeb83c544>
+clang_InlineCommandComment_getNumArgs :: MonadIO m => CXComment -> m CUInt
+clang_InlineCommandComment_getNumArgs comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_InlineCommandComment_getNumArgs comment'
+
+-- | Get the text of the specified argument.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga6824f3cdcb42edbd143db77a657fe888>
+clang_InlineCommandComment_getArgText ::
+     MonadIO m
+  => CXComment
+  -> CUInt -- ^ argument index (zero-based)
+  -> m Text
+clang_InlineCommandComment_getArgText comment argIdx = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_InlineCommandComment_getArgText comment' argIdx
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_HTMLStartTag' and 'CXComment_HTMLEndTag'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_HTMLTagComment_getTagName"
+  wrap_HTMLTagComment_getTagName :: R CXComment_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_HTMLStartTagComment_isSelfClosing"
+  wrap_HTMLStartTagComment_isSelfClosing :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_HTMLStartTag_getNumAttrs"
+  wrap_HTMLStartTag_getNumAttrs :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_HTMLStartTag_getAttrName"
+  wrap_HTMLStartTag_getAttrName :: R CXComment_ -> CUInt -> W CXString_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_HTMLStartTag_getAttrValue"
+  wrap_HTMLStartTag_getAttrValue ::
+       R CXComment_
+    -> CUInt
+    -> W CXString_
+    -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_HTMLTagComment_getAsString"
+  wrap_HTMLTagComment_getAsString :: R CXComment_ -> W CXString_ -> IO ()
+
+-- | Get the HTML tag name.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga55b84483c67c0629260b1534d4b3f80e>
+clang_HTMLTagComment_getTagName ::
+     MonadIO m
+  => CXComment
+  -- ^ a 'CXComment_HTMLStartTag' or 'CXComment_HTMLEndTag' AST node
+  -> m Text
+clang_HTMLTagComment_getTagName comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_HTMLTagComment_getTagName comment'
+
+-- | Determine whether the tag is self-closing.
+--
+-- Example: @<br />@ is self-closing
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga052be5f208a0ef2f76e3e9923a96ef19>
+clang_HTMLStartTagComment_isSelfClosing ::
+     MonadIO m
+  => CXComment -- ^ a 'CXComment_HTMLStartTag' AST node
+  -> m Bool
+clang_HTMLStartTagComment_isSelfClosing comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      cToBool <$> wrap_HTMLStartTagComment_isSelfClosing comment'
+
+-- | Get the number of attributes (name-value pairs) attached to the start tag.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gaffb8098debd5b99c2345840a5f0e63e0>
+clang_HTMLStartTag_getNumAttrs ::
+     MonadIO m
+  => CXComment -- ^ a 'CXComment_HTMLStartTag' AST node
+  -> m CUInt
+clang_HTMLStartTag_getNumAttrs comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_HTMLStartTag_getNumAttrs comment'
+
+-- | Get the name of the specified attribute.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga4bdf958af343477fc70eb2b4822cd006>
+clang_HTMLStartTag_getAttrName ::
+     MonadIO m
+  => CXComment -- ^ a 'CXComment_HTMLStartTag' AST node
+  -> CUInt     -- ^ attribute index (zero-based)
+  -> m Text
+clang_HTMLStartTag_getAttrName comment attrIdx = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_HTMLStartTag_getAttrName comment' attrIdx
+
+-- | Get the value of the specified attribute.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gae674a07af38d28d67941c1c54909c5e8>
+clang_HTMLStartTag_getAttrValue ::
+     MonadIO m
+  => CXComment -- ^ a 'CXComment_HTMLStartTag' AST node
+  -> CUInt     -- ^ attribute index (zero-based)
+  -> m Text
+clang_HTMLStartTag_getAttrValue comment attrIdx = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_HTMLStartTag_getAttrValue comment' attrIdx
+
+-- | Convert an HTML tag AST node to string.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga684a46f5993fe907016aba5dbe9d1d9e>
+clang_HTMLTagComment_getAsString ::
+     MonadIO m
+  => CXComment
+  -- ^ a 'CXComment_HTMLStartTag' or 'CXComment_HTMLEndTag' AST node
+  -> m Text
+clang_HTMLTagComment_getAsString comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_HTMLTagComment_getAsString comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_BlockCommand'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_BlockCommandComment_getCommandName"
+  wrap_BlockCommandComment_getCommandName ::
+       R CXComment_
+    -> W CXString_
+    -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_BlockCommandComment_getNumArgs"
+  wrap_BlockCommandComment_getNumArgs :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_BlockCommandComment_getArgText"
+  wrap_BlockCommandComment_getArgText ::
+       R CXComment_
+    -> CUInt
+    -> W CXString_
+    -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_BlockCommandComment_getParagraph"
+  wrap_BlockCommandComment_getParagraph :: R CXComment_ -> W CXComment_ -> IO ()
+
+-- | Get the name of the block command.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga8fdde998537370477362a4f84bc03420>
+clang_BlockCommandComment_getCommandName :: MonadIO m => CXComment -> m Text
+clang_BlockCommandComment_getCommandName comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_BlockCommandComment_getCommandName comment'
+
+-- | Get the number of word-like arguments.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gacb447968ce9efdfdabbfca8918540cdf>
+clang_BlockCommandComment_getNumArgs :: MonadIO m => CXComment -> m CUInt
+clang_BlockCommandComment_getNumArgs comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_BlockCommandComment_getNumArgs comment'
+
+-- | Get the text of the specified word-like argument.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga9faf08601d88c809a9a97a9826051990>
+clang_BlockCommandComment_getArgText ::
+     MonadIO m
+  => CXComment
+  -> CUInt -- ^ argument index (zero-based)
+  -> m Text
+clang_BlockCommandComment_getArgText comment argIdx = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_BlockCommandComment_getArgText comment' argIdx
+
+-- | Get the paragraph argument of the block command.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gac6f2ffc8fdbe9394bd4bb7d54327c968>
+clang_BlockCommandComment_getParagraph ::
+     MonadIO m
+  => CXComment
+  -- ^ a @CXComment_BlockCommand@ or @CXComment_VerbatimBlockCommand@ AST node
+  -> m CXComment
+clang_BlockCommandComment_getParagraph comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_BlockCommandComment_getParagraph comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_ParamCommand'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_ParamCommandComment_getParamName"
+  wrap_ParamCommandComment_getParamName :: R CXComment_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_ParamCommandComment_isParamIndexValid"
+  wrap_ParamCommandComment_isParamIndexValid :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_ParamCommandComment_getParamIndex"
+  wrap_ParamCommandComment_getParamIndex :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_ParamCommandComment_isDirectionExplicit"
+  wrap_ParamCommandComment_isDirectionExplicit :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_ParamCommandComment_getDirection"
+  wrap_ParamCommandComment_getDirection ::
+       R CXComment_
+    -> IO (SimpleEnum CXCommentParamPassDirection)
+
+-- | Get the parameter name.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gaffd7aaf697c5eb3a3d2b508b5d806763>
+clang_ParamCommandComment_getParamName :: MonadIO m => CXComment -> m Text
+clang_ParamCommandComment_getParamName comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_ParamCommandComment_getParamName comment'
+
+-- | Determine whether the parameter that this AST node represents was found in
+-- the function prototype and @clang_ParamCommandComment_getParamIndex@ function
+-- will return a meaningful value.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga92e6422da2a3e428b4452a3e8955ff76>
+clang_ParamCommandComment_isParamIndexValid :: MonadIO m => CXComment -> m Bool
+clang_ParamCommandComment_isParamIndexValid comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      cToBool <$> wrap_ParamCommandComment_isParamIndexValid comment'
+
+-- | Get the zero-based parameter index in function prototype.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gad9d1dc9ebb52dcc9cb7da8ca4c23332a>
+clang_ParamCommandComment_getParamIndex :: MonadIO m => CXComment -> m CUInt
+clang_ParamCommandComment_getParamIndex comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_ParamCommandComment_getParamIndex comment'
+
+-- | Determine whether the parameter passing direction was specified explicitly
+-- in the comment.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gaf68f19e83ca9b27aec7eb22b065620bd>
+clang_ParamCommandComment_isDirectionExplicit ::
+     MonadIO m
+  => CXComment -> m Bool
+clang_ParamCommandComment_isDirectionExplicit comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      cToBool <$> wrap_ParamCommandComment_isDirectionExplicit comment'
+
+-- | Get the parameter passing direction.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gac78b84734e9e6040a001a0036e6aa15c>
+clang_ParamCommandComment_getDirection ::
+     MonadIO m
+  => CXComment
+  -> m (SimpleEnum CXCommentParamPassDirection)
+clang_ParamCommandComment_getDirection comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_ParamCommandComment_getDirection comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_TParamCommand'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_TParamCommandComment_getParamName"
+  wrap_TParamCommandComment_getParamName :: R CXComment_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_TParamCommandComment_isParamPositionValid"
+  wrap_TParamCommandComment_isParamPositionValid :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_TParamCommandComment_getDepth"
+  wrap_TParamCommandComment_getDepth :: R CXComment_ -> IO CUInt
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_TParamCommandComment_getIndex"
+  wrap_TParamCommandComment_getIndex :: R CXComment_ -> CUInt -> IO CUInt
+
+-- | Get the template parameter name.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga01f61f1d0dabcaf806eb1b9f21e5e340>
+clang_TParamCommandComment_getParamName :: MonadIO m => CXComment -> m Text
+clang_TParamCommandComment_getParamName comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_TParamCommandComment_getParamName comment'
+
+-- | Determine whether the parameter that this AST node represents was found in
+-- the template parameter list and @clang_TParamCommandComment_getDepth@ and
+-- @clang_TParamCommandComment_getIndex@ functions will return a meaningful
+-- value.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga1f6e7538a646824f3dde65d634de753f>
+clang_TParamCommandComment_isParamPositionValid ::
+     MonadIO m
+  => CXComment -> m Bool
+clang_TParamCommandComment_isParamPositionValid comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      cToBool <$> wrap_TParamCommandComment_isParamPositionValid comment'
+
+-- | Get the zero-based nesting depth of this parameter in the template
+-- parameter list.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga88371156eeeb768d0d14eb5630b7c726>
+clang_TParamCommandComment_getDepth :: MonadIO m => CXComment -> m CUInt
+clang_TParamCommandComment_getDepth comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_TParamCommandComment_getDepth comment'
+
+-- | Get the zero-based parameter index in the template parameter list at a
+-- given nesting depth.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga0b91d26f02a476076b6dc5b5eea59a8f>
+clang_TParamCommandComment_getIndex ::
+     MonadIO m
+  => CXComment
+  -> CUInt -- ^ depth
+  -> m CUInt
+clang_TParamCommandComment_getIndex comment depth = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      wrap_TParamCommandComment_getIndex comment' depth
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_VerbatimBlockLine'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_VerbatimBlockLineComment_getText"
+  wrap_VerbatimBlockLineComment_getText :: R CXComment_ -> W CXString_ -> IO ()
+
+-- | Get the text contained in the AST node.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga599fad38a1c52917a2458ac10412969f>
+clang_VerbatimBlockLineComment_getText :: MonadIO m => CXComment -> m Text
+clang_VerbatimBlockLineComment_getText comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_VerbatimBlockLineComment_getText comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_VerbatimLine'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_VerbatimLineComment_getText"
+  wrap_VerbatimLineComment_getText :: R CXComment_ -> W CXString_ -> IO ()
+
+-- | Get the text contained in the AST node.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga4eb1de9012b525f14051409427bd8eb2>
+clang_VerbatimLineComment_getText :: MonadIO m => CXComment -> m Text
+clang_VerbatimLineComment_getText comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_VerbatimLineComment_getText comment'
+
+{-------------------------------------------------------------------------------
+  Comment type 'CXComment_FullComment'
+-------------------------------------------------------------------------------}
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_FullComment_getAsHTML"
+  wrap_FullComment_getAsHTML :: R CXComment_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "doxygen_wrappers.h wrap_FullComment_getAsXML"
+  wrap_FullComment_getAsXML :: R CXComment_ -> W CXString_ -> IO ()
+
+-- | Convert a given full parsed comment to an HTML fragment.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gafdfc03bbfdddd06c380a2644f16ccba9>
+clang_FullComment_getAsHTML :: MonadIO m => CXComment -> m Text
+clang_FullComment_getAsHTML comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_FullComment_getAsHTML comment'
+
+-- | Convert a given full parsed comment to an XML document.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gac877b07be05f591fdfea05f466ed9395>
+clang_FullComment_getAsXML :: MonadIO m => CXComment -> m Text
+clang_FullComment_getAsXML comment = liftIO $
+    onHaskellHeap comment $ \comment' ->
+      preallocate_ $ wrap_FullComment_getAsXML comment'
diff --git a/src/Clang/LowLevel/Doxygen/Enums.hs b/src/Clang/LowLevel/Doxygen/Enums.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Doxygen/Enums.hs
@@ -0,0 +1,142 @@
+module Clang.LowLevel.Doxygen.Enums (
+    CXCommentKind(..)
+  , CXCommentInlineCommandRenderKind(..)
+  , CXCommentParamPassDirection(..)
+  ) where
+
+import GHC.Generics (Generic)
+
+-- | Describes the type of the comment AST node ('CXComment').
+--
+-- A comment node can be considered block content (e. g., paragraph), inline
+-- content (plain text) or neither (the root AST node).
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga3c336d80551401fde394b84aa5651221>
+data CXCommentKind =
+    -- | Null comment.
+    --
+    -- No AST node is constructed at the requested location because there is no
+    -- text or a syntax error.
+    CXComment_Null
+
+    -- | Plain text.
+    --
+    -- Inline content.
+  | CXComment_Text
+
+    -- | A command with word-like arguments that is considered inline content.
+    --
+    -- For example: @\\c command@.
+  | CXComment_InlineCommand
+
+    -- | HTML start tag with attributes (name-value pairs).
+    --
+    -- Considered inline content.
+    --
+    -- For example:
+    --
+    -- > <br> <br /> <a href="http://example.org/">
+  | CXComment_HTMLStartTag
+
+    -- | HTML end tag.
+    --
+    -- Considered inline content.
+    --
+    -- For example:
+    --
+    -- > </a>
+  | CXComment_HTMLEndTag
+
+     -- | A paragraph, contains inline comment.
+     --
+     -- The paragraph itself is block content.
+  | CXComment_Paragraph
+
+    -- | A command that has zero or more word-like arguments (number of
+    -- word-like arguments depends on command name) and a paragraph as an
+    -- argument.
+   --
+   -- Block command is block content.
+   --
+   -- Paragraph argument is also a child of the block command.
+   --
+   -- For example: @\has 0 word-like arguments and a paragraph argument@.
+   --
+   -- AST nodes of special kinds that parser knows about (e. g., @\param@
+   -- command) have their own node kinds.
+  | CXComment_BlockCommand
+
+   -- | A @\param@ or @\arg@ command that describes the function parameter
+   -- (name, passing direction, description).
+   --
+   -- For example: @\param [in] ParamName description@.
+  | CXComment_ParamCommand
+
+   -- | A @\tparam@ command that describes a template parameter (name and
+   -- description).
+   --
+   -- For example: @\tparam T description@.
+  | CXComment_TParamCommand
+
+    -- | A verbatim block command (e. g., preformatted code).
+    --
+    -- Verbatim block has an opening and a closing command and contains multiple
+    -- lines of text ('CXComment_VerbatimBlockLine' child nodes).
+    --
+    -- For example:
+    --
+    -- > \verbatim
+    -- > aaa
+    -- > \endverbatim
+  | CXComment_VerbatimBlockCommand
+
+    -- | A line of text that is contained within a
+    -- 'CXComment_VerbatimBlockCommand' node.
+  | CXComment_VerbatimBlockLine
+
+    -- | A verbatim line command.
+    --
+    -- Verbatim line has an opening command, a single line of text (up to the
+    -- newline after the opening command) and has no closing command.
+  | CXComment_VerbatimLine
+
+    -- | A full comment attached to a declaration, contains block content.
+  | CXComment_FullComment
+  deriving stock (Show, Eq, Ord, Enum, Bounded)
+
+-- | The most appropriate rendering mode for an inline command, chosen on
+-- command semantics in Doxygen.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga23efacd9c1e4e286a9f9714e1720fdcf>
+data CXCommentInlineCommandRenderKind =
+    -- | Command argument should be rendered in a normal font.
+    CXCommentInlineCommandRenderKind_Normal
+
+    -- | Command argument should be rendered in a bold font.
+  | CXCommentInlineCommandRenderKind_Bold
+
+    -- | Command argument should be rendered in a monospaced font.
+  | CXCommentInlineCommandRenderKind_Monospaced
+
+    -- | Command argument should be rendered emphasized (typically italic
+    -- font).
+  | CXCommentInlineCommandRenderKind_Emphasized
+
+    -- | Command argument should not be rendered (since it only defines an
+    -- anchor).
+  | CXCommentInlineCommandRenderKind_Anchor
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
+
+-- | Describes parameter passing direction for @\\param@ or @\\arg@ command.
+--
+-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gafadf6e52217ea74d1a014198df656ee1>
+data CXCommentParamPassDirection =
+    -- | The parameter is an input parameter.
+    CXCommentParamPassDirection_In
+
+    -- | The parameter is an output parameter.
+  | CXCommentParamPassDirection_Out
+
+    -- | The parameter is an input and output parameter.
+  | CXCommentParamPassDirection_InOut
+  deriving stock (Show, Eq, Ord, Enum, Bounded, Generic)
diff --git a/src/Clang/LowLevel/Doxygen/Instances.hsc b/src/Clang/LowLevel/Doxygen/Instances.hsc
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Doxygen/Instances.hsc
@@ -0,0 +1,85 @@
+{-# OPTIONS_GHC -Wno-orphans #-}
+
+module Clang.LowLevel.Doxygen.Instances () where
+
+import Clang.Enum.Simple
+import Clang.Internal.ByValue
+import Clang.LowLevel.Doxygen.Enums
+import Clang.LowLevel.Doxygen.Structs
+
+#include <clang-c/Documentation.h>
+
+{-------------------------------------------------------------------------------
+  HasKnownSize instances
+-------------------------------------------------------------------------------}
+
+instance HasKnownSize CXComment_ where knownSize = #size CXComment
+
+{-------------------------------------------------------------------------------
+  CXCommentKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXCommentKind where
+  simpleToC CXComment_Null                 = #const CXComment_Null
+  simpleToC CXComment_Text                 = #const CXComment_Text
+  simpleToC CXComment_InlineCommand        = #const CXComment_InlineCommand
+  simpleToC CXComment_HTMLStartTag         = #const CXComment_HTMLStartTag
+  simpleToC CXComment_HTMLEndTag           = #const CXComment_HTMLEndTag
+  simpleToC CXComment_Paragraph            = #const CXComment_Paragraph
+  simpleToC CXComment_BlockCommand         = #const CXComment_BlockCommand
+  simpleToC CXComment_ParamCommand         = #const CXComment_ParamCommand
+  simpleToC CXComment_TParamCommand        = #const CXComment_TParamCommand
+  simpleToC CXComment_VerbatimBlockCommand = #const CXComment_VerbatimBlockCommand
+  simpleToC CXComment_VerbatimBlockLine    = #const CXComment_VerbatimBlockLine
+  simpleToC CXComment_VerbatimLine         = #const CXComment_VerbatimLine
+  simpleToC CXComment_FullComment          = #const CXComment_FullComment
+
+  simpleFromC (#const CXComment_Null)                 = Just CXComment_Null
+  simpleFromC (#const CXComment_Text)                 = Just CXComment_Text
+  simpleFromC (#const CXComment_InlineCommand)        = Just CXComment_InlineCommand
+  simpleFromC (#const CXComment_HTMLStartTag)         = Just CXComment_HTMLStartTag
+  simpleFromC (#const CXComment_HTMLEndTag)           = Just CXComment_HTMLEndTag
+  simpleFromC (#const CXComment_Paragraph)            = Just CXComment_Paragraph
+  simpleFromC (#const CXComment_BlockCommand)         = Just CXComment_BlockCommand
+  simpleFromC (#const CXComment_ParamCommand)         = Just CXComment_ParamCommand
+  simpleFromC (#const CXComment_TParamCommand)        = Just CXComment_TParamCommand
+  simpleFromC (#const CXComment_VerbatimBlockCommand) = Just CXComment_VerbatimBlockCommand
+  simpleFromC (#const CXComment_VerbatimBlockLine)    = Just CXComment_VerbatimBlockLine
+  simpleFromC (#const CXComment_VerbatimLine)         = Just CXComment_VerbatimLine
+  simpleFromC (#const CXComment_FullComment)          = Just CXComment_FullComment
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXCommentInlineCommandRenderKind
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXCommentInlineCommandRenderKind where
+  simpleToC CXCommentInlineCommandRenderKind_Normal     = #const CXCommentInlineCommandRenderKind_Normal
+  simpleToC CXCommentInlineCommandRenderKind_Bold       = #const CXCommentInlineCommandRenderKind_Bold
+  simpleToC CXCommentInlineCommandRenderKind_Monospaced = #const CXCommentInlineCommandRenderKind_Monospaced
+  simpleToC CXCommentInlineCommandRenderKind_Emphasized = #const CXCommentInlineCommandRenderKind_Emphasized
+  simpleToC CXCommentInlineCommandRenderKind_Anchor     = #const CXCommentInlineCommandRenderKind_Anchor
+
+  simpleFromC (#const CXCommentInlineCommandRenderKind_Normal)     = Just CXCommentInlineCommandRenderKind_Normal
+  simpleFromC (#const CXCommentInlineCommandRenderKind_Bold)       = Just CXCommentInlineCommandRenderKind_Bold
+  simpleFromC (#const CXCommentInlineCommandRenderKind_Monospaced) = Just CXCommentInlineCommandRenderKind_Monospaced
+  simpleFromC (#const CXCommentInlineCommandRenderKind_Emphasized) = Just CXCommentInlineCommandRenderKind_Emphasized
+  simpleFromC (#const CXCommentInlineCommandRenderKind_Anchor)     = Just CXCommentInlineCommandRenderKind_Anchor
+
+  simpleFromC _otherwise = Nothing
+
+{-------------------------------------------------------------------------------
+  CXCommentParamPassDirection
+-------------------------------------------------------------------------------}
+
+instance IsSimpleEnum CXCommentParamPassDirection where
+  simpleToC CXCommentParamPassDirection_In    = #const CXCommentParamPassDirection_In
+  simpleToC CXCommentParamPassDirection_Out   = #const CXCommentParamPassDirection_Out
+  simpleToC CXCommentParamPassDirection_InOut = #const CXCommentParamPassDirection_InOut
+
+  simpleFromC (#const CXCommentParamPassDirection_In)    = Just CXCommentParamPassDirection_In
+  simpleFromC (#const CXCommentParamPassDirection_Out)   = Just CXCommentParamPassDirection_Out
+  simpleFromC (#const CXCommentParamPassDirection_InOut) = Just CXCommentParamPassDirection_InOut
+
+  simpleFromC _otherwise = Nothing
diff --git a/src/Clang/LowLevel/Doxygen/Structs.hs b/src/Clang/LowLevel/Doxygen/Structs.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/Doxygen/Structs.hs
@@ -0,0 +1,6 @@
+module Clang.LowLevel.Doxygen.Structs (
+    CXComment_
+  ) where
+
+-- <https://clang.llvm.org/doxygen/structCXComment.html>
+data CXComment_
diff --git a/src/Clang/LowLevel/FFI.hs b/src/Clang/LowLevel/FFI.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/LowLevel/FFI.hs
@@ -0,0 +1,737 @@
+{-# LANGUAGE CPP #-}
+{-| this module is autogenerated with cabal run libclang-bootstrap -}
+module Clang.LowLevel.FFI (module Clang.LowLevel.FFI) where
+
+#include "clang_config.h"
+
+import Clang.Enum.Simple
+import Clang.Internal.ByValue
+import Clang.Internal.ConstPtr
+import Clang.LowLevel.Core.Enums
+import Clang.LowLevel.Core.Pointers
+import Clang.LowLevel.Core.Structs
+import Foreign.C.Types
+import Foreign.Ptr
+
+-- *** Top-level ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX.html>
+
+foreign import capi unsafe "clang_wrappers.h clang_createIndex"
+  nowrapper_createIndex :: CInt -> CInt -> IO CXIndex
+
+foreign import capi unsafe "clang_wrappers.h clang_disposeIndex"
+  nowrapper_disposeIndex :: CXIndex -> IO ()
+
+-- OMITTED: CXIndex             clang_createIndexWithOptions (const CXIndexOptions * options);
+
+-- OMITTED: void                clang_CXIndex_setGlobalOptions (CXIndex, unsigned options);
+
+-- OMITTED: unsigned            clang_CXIndex_getGlobalOptions (CXIndex);
+
+-- OMITTED: void                clang_CXIndex_setInvocationEmissionPathOption (CXIndex, const char * Path);
+
+-- OMITTED: unsigned            clang_isFileMultipleIncludeGuarded (CXTranslationUnit tu, CXFile file);
+
+foreign import capi unsafe "clang_wrappers.h clang_getFile"
+  nowrapper_getFile :: CXTranslationUnit -> ConstPtr CChar -> IO CXFile
+
+foreign import capi unsafe "clang_wrappers.h clang_getFileContents"
+  nowrapper_getFileContents :: CXTranslationUnit -> CXFile -> Ptr CSize -> IO (ConstPtr CChar)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getLocation :: CXTranslationUnit -> CXFile -> CUInt -> CUInt -> W CXSourceLocation_ -> IO ()
+
+-- OMITTED: CXSourceLocation    clang_getLocationForOffset (CXTranslationUnit tu, CXFile file, unsigned offset);
+
+-- OMITTED: CXSourceRangeList * clang_getSkippedRanges (CXTranslationUnit tu, CXFile file);
+
+-- OMITTED: CXSourceRangeList * clang_getAllSkippedRanges (CXTranslationUnit tu);
+
+foreign import capi unsafe "clang_wrappers.h clang_getNumDiagnostics"
+  nowrapper_getNumDiagnostics :: CXTranslationUnit -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_getDiagnostic"
+  nowrapper_getDiagnostic :: CXTranslationUnit -> CUInt -> IO CXDiagnostic
+
+-- OMITTED: CXDiagnosticSet     clang_getDiagnosticSetFromTU (CXTranslationUnit Unit);
+
+-- *** Diagnostic reporting ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DIAG.html>
+
+foreign import capi unsafe "clang_wrappers.h clang_getNumDiagnosticsInSet"
+  nowrapper_getNumDiagnosticsInSet :: CXDiagnosticSet -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_getDiagnosticInSet"
+  nowrapper_getDiagnosticInSet :: CXDiagnosticSet -> CUInt -> IO CXDiagnostic
+
+-- OMITTED: CXDiagnosticSet           clang_loadDiagnostics (const char * file, enum CXLoadDiag_Error * error, CXString * errorString);
+
+foreign import capi unsafe "clang_wrappers.h clang_disposeDiagnosticSet"
+  nowrapper_disposeDiagnosticSet :: CXDiagnosticSet -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_getChildDiagnostics"
+  nowrapper_getChildDiagnostics :: CXDiagnostic -> IO CXDiagnosticSet
+
+foreign import capi unsafe "clang_wrappers.h clang_disposeDiagnostic"
+  nowrapper_disposeDiagnostic :: CXDiagnostic -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_formatDiagnostic :: CXDiagnostic -> CUInt -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_defaultDiagnosticDisplayOptions"
+  nowrapper_defaultDiagnosticDisplayOptions :: IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_getDiagnosticSeverity"
+  nowrapper_getDiagnosticSeverity :: CXDiagnostic -> IO (SimpleEnum CXDiagnosticSeverity)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getDiagnosticLocation :: CXDiagnostic -> W CXSourceLocation_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getDiagnosticSpelling :: CXDiagnostic -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getDiagnosticOption :: CXDiagnostic -> W CXString_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_getDiagnosticCategory"
+  nowrapper_getDiagnosticCategory :: CXDiagnostic -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getDiagnosticCategoryText :: CXDiagnostic -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_getDiagnosticNumRanges"
+  nowrapper_getDiagnosticNumRanges :: CXDiagnostic -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getDiagnosticRange :: CXDiagnostic -> CUInt -> W CXSourceRange_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_getDiagnosticNumFixIts"
+  nowrapper_getDiagnosticNumFixIts :: CXDiagnostic -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getDiagnosticFixIt :: CXDiagnostic -> CUInt -> W CXSourceRange_ -> W CXString_ -> IO ()
+
+-- *** File manipulation routines ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__FILES.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getFileName :: CXFile -> W CXString_ -> IO ()
+
+-- OMITTED: time_t   clang_getFileTime (CXFile SFile);
+
+-- OMITTED: int      clang_getFileUniqueID (CXFile file, CXFileUniqueID * outID);
+
+-- OMITTED: int      clang_File_isEqual (CXFile file1, CXFile file2);
+
+-- OMITTED: CXString clang_File_tryGetRealPathName (CXFile file);
+
+-- *** Physical source locations ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LOCATIONS.html>
+
+-- OMITTED: CXSourceLocation clang_getNullLocation (void);
+
+-- OMITTED: unsigned         clang_equalLocations (CXSourceLocation loc1, CXSourceLocation loc2);
+
+#ifdef HAVE_CLANG_ISBEFOREINTRANSLATIONUNIT
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isBeforeInTranslationUnit :: R CXSourceLocation_ -> R CXSourceLocation_ -> IO CUInt
+
+#endif
+
+-- OMITTED: int              clang_Location_isInSystemHeader (CXSourceLocation location);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Location_isFromMainFile :: R CXSourceLocation_ -> IO CInt
+
+-- OMITTED: CXSourceRange    clang_getNullRange (void);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getRange :: R CXSourceLocation_ -> R CXSourceLocation_ -> W CXSourceRange_ -> IO ()
+
+-- OMITTED: unsigned         clang_equalRanges (CXSourceRange range1, CXSourceRange range2);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Range_isNull :: R CXSourceRange_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getExpansionLocation :: R CXSourceLocation_ -> Ptr CXFile -> Ptr CUInt -> Ptr CUInt -> Ptr CUInt -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getPresumedLocation :: R CXSourceLocation_ -> W CXString_ -> Ptr CUInt -> Ptr CUInt -> IO ()
+
+-- OMITTED: void             clang_getInstantiationLocation (CXSourceLocation location, CXFile * file, unsigned * line, unsigned * column, unsigned * offset);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getSpellingLocation :: R CXSourceLocation_ -> Ptr CXFile -> Ptr CUInt -> Ptr CUInt -> Ptr CUInt -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getFileLocation :: R CXSourceLocation_ -> Ptr CXFile -> Ptr CUInt -> Ptr CUInt -> Ptr CUInt -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getRangeStart :: R CXSourceRange_ -> W CXSourceLocation_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getRangeEnd :: R CXSourceRange_ -> W CXSourceLocation_ -> IO ()
+
+-- OMITTED: void             clang_disposeSourceRangeList (CXSourceRangeList * ranges);
+
+-- *** String manipulation routines ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__STRING.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCString :: R CXString_ -> IO (ConstPtr CChar)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_disposeString :: R CXString_ -> IO ()
+
+-- OMITTED: void         clang_disposeStringSet (CXStringSet * set);
+
+-- *** Translation unit manipulation ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html>
+
+-- OMITTED: CXString          clang_getTranslationUnitSpelling (CXTranslationUnit CTUnit);
+
+-- OMITTED: CXTranslationUnit clang_createTranslationUnitFromSourceFile (CXIndex CIdx, const char * source_filename, int num_clang_command_line_args, const char * const * clang_command_line_args, unsigned num_unsaved_files, struct CXUnsavedFile * unsaved_files);
+
+-- OMITTED: CXTranslationUnit clang_createTranslationUnit (CXIndex CIdx, const char * ast_filename);
+
+-- OMITTED: enum CXErrorCode  clang_createTranslationUnit2 (CXIndex CIdx, const char * ast_filename, CXTranslationUnit * out_TU);
+
+-- OMITTED: unsigned          clang_defaultEditingTranslationUnitOptions (void);
+
+foreign import capi unsafe "clang_wrappers.h clang_parseTranslationUnit"
+  nowrapper_parseTranslationUnit :: CXIndex -> ConstPtr CChar -> ConstPtr (ConstPtr CChar) -> CInt -> Ptr CXUnsavedFile -> CUInt -> CUInt -> IO CXTranslationUnit
+
+foreign import capi unsafe "clang_wrappers.h clang_parseTranslationUnit2"
+  nowrapper_parseTranslationUnit2 :: CXIndex -> ConstPtr CChar -> ConstPtr (ConstPtr CChar) -> CInt -> Ptr CXUnsavedFile -> CUInt -> CUInt -> Ptr CXTranslationUnit -> IO (SimpleEnum (Maybe CXErrorCode))
+
+-- OMITTED: enum CXErrorCode  clang_parseTranslationUnit2FullArgv (CXIndex CIdx, const char * source_filename, const char * const * command_line_args, int num_command_line_args, struct CXUnsavedFile * unsaved_files, unsigned num_unsaved_files, unsigned options, CXTranslationUnit * out_TU);
+
+-- OMITTED: unsigned          clang_defaultSaveOptions (CXTranslationUnit TU);
+
+-- OMITTED: int               clang_saveTranslationUnit (CXTranslationUnit TU, const char * FileName, unsigned options);
+
+-- OMITTED: unsigned          clang_suspendTranslationUnit (CXTranslationUnit TU);
+
+foreign import capi unsafe "clang_wrappers.h clang_disposeTranslationUnit"
+  nowrapper_disposeTranslationUnit :: CXTranslationUnit -> IO ()
+
+-- OMITTED: unsigned          clang_defaultReparseOptions (CXTranslationUnit TU);
+
+-- OMITTED: int               clang_reparseTranslationUnit (CXTranslationUnit TU, unsigned num_unsaved_files, struct CXUnsavedFile * unsaved_files, unsigned options);
+
+-- OMITTED: const char *      clang_getTUResourceUsageName (enum CXTUResourceUsageKind kind);
+
+-- OMITTED: CXTUResourceUsage clang_getCXTUResourceUsage (CXTranslationUnit TU);
+
+-- OMITTED: void              clang_disposeCXTUResourceUsage (CXTUResourceUsage usage);
+
+foreign import capi unsafe "clang_wrappers.h clang_getTranslationUnitTargetInfo"
+  nowrapper_getTranslationUnitTargetInfo :: CXTranslationUnit -> IO CXTargetInfo
+
+foreign import capi unsafe "clang_wrappers.h clang_TargetInfo_dispose"
+  nowrapper_TargetInfo_dispose :: CXTargetInfo -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_TargetInfo_getTriple :: CXTargetInfo -> W CXString_ -> IO ()
+
+-- OMITTED: int               clang_TargetInfo_getPointerWidth (CXTargetInfo Info);
+
+-- *** Cursor manipulations ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getNullCursor :: W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTranslationUnitCursor :: CXTranslationUnit -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_equalCursors :: R CXCursor_ -> R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isNull :: R CXCursor_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_hashCursor :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorKind :: R CXCursor_ -> IO (SimpleEnum CXCursorKind)
+
+foreign import capi unsafe "clang_wrappers.h clang_isDeclaration"
+  nowrapper_isDeclaration :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isInvalidDeclaration :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isReference"
+  nowrapper_isReference :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isExpression"
+  nowrapper_isExpression :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isStatement"
+  nowrapper_isStatement :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isAttribute"
+  nowrapper_isAttribute :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_hasAttrs :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isInvalid"
+  nowrapper_isInvalid :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isTranslationUnit"
+  nowrapper_isTranslationUnit :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isPreprocessing"
+  nowrapper_isPreprocessing :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_isUnexposed"
+  nowrapper_isUnexposed :: SimpleEnum CXCursorKind -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorLinkage :: R CXCursor_ -> IO (SimpleEnum CXLinkageKind)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorVisibility :: R CXCursor_ -> IO (SimpleEnum CXVisibilityKind)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorAvailability :: R CXCursor_ -> IO (SimpleEnum CXAvailabilityKind)
+
+-- OMITTED: int                     clang_getCursorPlatformAvailability (CXCursor cursor, int * always_deprecated, CXString * deprecated_message, int * always_unavailable, CXString * unavailable_message, CXPlatformAvailability * availability, int availability_size);
+
+-- OMITTED: void                    clang_disposeCXPlatformAvailability (CXPlatformAvailability * availability);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getVarDeclInitializer :: R CXCursor_ -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_hasVarDeclGlobalStorage :: R CXCursor_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_hasVarDeclExternalStorage :: R CXCursor_ -> IO CInt
+
+-- OMITTED: enum CXLanguageKind     clang_getCursorLanguage (CXCursor cursor);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorTLSKind :: R CXCursor_ -> IO (SimpleEnum CXTLSKind)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getTranslationUnit :: R CXCursor_ -> IO CXTranslationUnit
+
+-- OMITTED: CXCursorSet             clang_createCXCursorSet (void);
+
+-- OMITTED: void                    clang_disposeCXCursorSet (CXCursorSet cset);
+
+-- OMITTED: unsigned                clang_CXCursorSet_contains (CXCursorSet cset, CXCursor cursor);
+
+-- OMITTED: unsigned                clang_CXCursorSet_insert (CXCursorSet cset, CXCursor cursor);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorSemanticParent :: R CXCursor_ -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorLexicalParent :: R CXCursor_ -> W CXCursor_ -> IO ()
+
+-- OMITTED: void                    clang_getOverriddenCursors (CXCursor cursor, CXCursor * * overridden, unsigned * num_overridden);
+
+-- OMITTED: void                    clang_disposeOverriddenCursors (CXCursor * overridden);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getIncludedFile :: R CXCursor_ -> IO CXFile
+
+-- *** Mapping between cursors and source code  ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__SOURCE.html>
+
+-- OMITTED: CXCursor         clang_getCursor (CXTranslationUnit TU, CXSourceLocation Source);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorLocation :: R CXCursor_ -> W CXSourceLocation_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorExtent :: R CXCursor_ -> W CXSourceRange_ -> IO ()
+
+-- *** Type information for CXCursors ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__TYPES.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorType :: R CXCursor_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTypeSpelling :: R CXType_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTypedefDeclUnderlyingType :: R CXCursor_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getEnumDeclIntegerType :: R CXCursor_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getEnumConstantDeclValue :: R CXCursor_ -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getEnumConstantDeclUnsignedValue :: R CXCursor_ -> IO CULLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isBitField :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getFieldDeclBitWidth :: R CXCursor_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getNumArguments :: R CXCursor_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getArgument :: R CXCursor_ -> CUInt -> W CXCursor_ -> IO ()
+
+-- OMITTED: int                         clang_Cursor_getNumTemplateArguments (CXCursor C);
+
+-- OMITTED: enum CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind (CXCursor C, unsigned I);
+
+-- OMITTED: CXType                      clang_Cursor_getTemplateArgumentType (CXCursor C, unsigned I);
+
+-- OMITTED: long long                   clang_Cursor_getTemplateArgumentValue (CXCursor C, unsigned I);
+
+-- OMITTED: unsigned long long          clang_Cursor_getTemplateArgumentUnsignedValue (CXCursor C, unsigned I);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_equalTypes :: R CXType_ -> R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCanonicalType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isConstQualifiedType :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isMacroFunctionLike :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isMacroBuiltin :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isFunctionInlined :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isVolatileQualifiedType :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isRestrictQualifiedType :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getAddressSpace :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTypedefName :: R CXType_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getPointeeType :: R CXType_ -> W CXType_ -> IO ()
+
+-- OMITTED: CXType                      clang_getUnqualifiedType (CXType CT); // NOTE: does not exist before clang-16, so we define a custom wrapper in clang_wrappers.h
+
+-- OMITTED: CXType                      clang_getNonReferenceType (CXType CT);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTypeDeclaration :: R CXType_ -> W CXCursor_ -> IO ()
+
+-- OMITTED: CXString                    clang_getDeclObjCTypeEncoding (CXCursor C);
+
+-- OMITTED: CXString                    clang_Type_getObjCEncoding (CXType type);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTypeKindSpelling :: SimpleEnum CXTypeKind -> W CXString_ -> IO ()
+
+-- OMITTED: enum CXCallingConv          clang_getFunctionTypeCallingConv (CXType T);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getResultType :: R CXType_ -> W CXType_ -> IO ()
+
+-- OMITTED: int                         clang_getExceptionSpecificationType (CXType T);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getNumArgTypes :: R CXType_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getArgType :: R CXType_ -> CUInt -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getObjCObjectBaseType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getNumObjCProtocolRefs :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getObjCProtocolDecl :: R CXType_ -> CUInt -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getNumObjCTypeArgs :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getObjCTypeArg :: R CXType_ -> CUInt -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isFunctionTypeVariadic :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorResultType :: R CXCursor_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorExceptionSpecificationType :: R CXCursor_ -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isPODType :: R CXType_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getElementType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getNumElements :: R CXType_ -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getArrayElementType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getArraySize :: R CXType_ -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getNamedType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_isTransparentTagTypedef :: R CXType_ -> IO CUInt
+
+-- OMITTED: enum CXTypeNullabilityKind  clang_Type_getNullability (CXType T);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getAlignOf :: R CXType_ -> IO CLLong
+
+-- OMITTED: CXType                      clang_Type_getClassType (CXType T);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getSizeOf :: R CXType_ -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getOffsetOf :: R CXType_ -> ConstPtr CChar -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getModifiedType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Type_getValueType :: R CXType_ -> W CXType_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getOffsetOfField :: R CXCursor_ -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isAnonymous :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_isAnonymousRecordDecl :: R CXCursor_ -> IO CUInt
+
+-- OMITTED: unsigned                    clang_Cursor_isInlineNamespace (CXCursor C);
+
+-- OMITTED: int                         clang_Type_getNumTemplateArguments (CXType T);
+
+-- OMITTED: CXType                      clang_Type_getTemplateArgumentAsType (CXType T, unsigned i);
+
+-- OMITTED: enum CXRefQualifierKind     clang_Type_getCXXRefQualifier (CXType T);
+
+-- OMITTED: unsigned                    clang_isVirtualBase (CXCursor C);
+
+-- OMITTED: long long                   clang_getOffsetOfBase (CXCursor Parent, CXCursor Base);
+
+-- OMITTED: enum CX_CXXAccessSpecifier  clang_getCXXAccessSpecifier (CXCursor C);
+
+-- OMITTED: enum CX_BinaryOperatorKind  clang_Cursor_getBinaryOpcode (CXCursor C);
+
+-- OMITTED: CXString                    clang_Cursor_getBinaryOpcodeStr (enum CX_BinaryOperatorKind Op);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getStorageClass :: R CXCursor_ -> IO (SimpleEnum CX_StorageClass)
+
+-- OMITTED: unsigned                    clang_getNumOverloadedDecls (CXCursor cursor);
+
+-- OMITTED: CXCursor                    clang_getOverloadedDecl (CXCursor cursor, unsigned index);
+
+-- *** Traversing the AST with cursors ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html>
+
+-- OMITTED: unsigned clang_visitChildren (CXCursor parent, CXCursorVisitor visitor, CXClientData client_data);
+
+-- OMITTED: unsigned clang_visitChildrenWithBlock (CXCursor parent, CXCursorVisitorBlock block);
+
+-- *** Cross-referencing in the AST  ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__CURSOR__XREF.html>
+
+-- OMITTED: CXString         clang_getCursorUSR (CXCursor);
+
+-- OMITTED: CXString         clang_constructUSR_ObjCClass (const char * class_name);
+
+-- OMITTED: CXString         clang_constructUSR_ObjCCategory (const char * class_name, const char * category_name);
+
+-- OMITTED: CXString         clang_constructUSR_ObjCProtocol (const char * protocol_name);
+
+-- OMITTED: CXString         clang_constructUSR_ObjCIvar (const char * name, CXString classUSR);
+
+-- OMITTED: CXString         clang_constructUSR_ObjCMethod (const char * name, unsigned isInstanceMethod, CXString classUSR);
+
+-- OMITTED: CXString         clang_constructUSR_ObjCProperty (const char * property, CXString classUSR);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorSpelling :: R CXCursor_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getSpellingNameRange :: R CXCursor_ -> CUInt -> CUInt -> W CXSourceRange_ -> IO ()
+
+-- OMITTED: unsigned         clang_PrintingPolicy_getProperty (CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property);
+
+-- OMITTED: void             clang_PrintingPolicy_setProperty (CXPrintingPolicy Policy, enum CXPrintingPolicyProperty Property, unsigned Value);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorPrintingPolicy :: R CXCursor_ -> IO CXPrintingPolicy
+
+foreign import capi unsafe "clang_wrappers.h clang_PrintingPolicy_dispose"
+  nowrapper_PrintingPolicy_dispose :: CXPrintingPolicy -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorPrettyPrinted :: R CXCursor_ -> CXPrintingPolicy -> W CXString_ -> IO ()
+
+-- OMITTED: CXString         clang_getTypePrettyPrinted (CXType CT, CXPrintingPolicy cxPolicy);
+
+-- OMITTED: CXString         clang_getFullyQualifiedName (CXType CT, CXPrintingPolicy Policy, unsigned WithGlobalNsPrefix);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorDisplayName :: R CXCursor_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorReferenced :: R CXCursor_ -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorDefinition :: R CXCursor_ -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_isCursorDefinition :: R CXCursor_ -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCanonicalCursor :: R CXCursor_ -> W CXCursor_ -> IO ()
+
+-- OMITTED: int              clang_Cursor_getObjCSelectorIndex (CXCursor);
+
+-- OMITTED: int              clang_Cursor_isDynamicCall (CXCursor C);
+
+-- OMITTED: CXType           clang_Cursor_getReceiverType (CXCursor C);
+
+-- OMITTED: unsigned         clang_Cursor_getObjCPropertyAttributes (CXCursor C, unsigned reserved);
+
+-- OMITTED: CXString         clang_Cursor_getObjCPropertyGetterName (CXCursor C);
+
+-- OMITTED: CXString         clang_Cursor_getObjCPropertySetterName (CXCursor C);
+
+-- OMITTED: unsigned         clang_Cursor_getObjCDeclQualifiers (CXCursor C);
+
+-- OMITTED: unsigned         clang_Cursor_isObjCOptional (CXCursor C);
+
+-- OMITTED: unsigned         clang_Cursor_isVariadic (CXCursor C);
+
+-- OMITTED: unsigned         clang_Cursor_isExternalSymbol (CXCursor C, CXString * language, CXString * definedIn, unsigned * isGenerated);
+
+-- OMITTED: CXSourceRange    clang_Cursor_getCommentRange (CXCursor C);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getRawCommentText :: R CXCursor_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_getBriefCommentText :: R CXCursor_ -> W CXString_ -> IO ()
+
+-- *** Token extraction and manipulation ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__LEX.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getToken :: CXTranslationUnit -> R CXSourceLocation_ -> IO (Ptr CXToken_)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTokenKind :: Ptr CXToken_ -> IO (SimpleEnum CXTokenKind)
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTokenSpelling :: CXTranslationUnit -> Ptr CXToken_ -> W CXString_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTokenLocation :: CXTranslationUnit -> Ptr CXToken_ -> W CXSourceLocation_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getTokenExtent :: CXTranslationUnit -> Ptr CXToken_ -> W CXSourceRange_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_tokenize :: CXTranslationUnit -> R CXSourceRange_ -> Ptr (Ptr CXToken_) -> Ptr CUInt -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_annotateTokens"
+  nowrapper_annotateTokens :: CXTranslationUnit -> Ptr CXToken_ -> CUInt -> W CXCursor_ -> IO ()
+
+foreign import capi unsafe "clang_wrappers.h clang_disposeTokens"
+  nowrapper_disposeTokens :: CXTranslationUnit -> Ptr CXToken_ -> CUInt -> IO ()
+
+-- *** Debugging facilities ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__DEBUG.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getCursorKindSpelling :: SimpleEnum CXCursorKind -> W CXString_ -> IO ()
+
+-- OMITTED: void     clang_getDefinitionSpellingAndExtent (CXCursor, const char * * startBuf, const char * * endBuf, unsigned * startLine, unsigned * startColumn, unsigned * endLine, unsigned * endColumn);
+
+-- OMITTED: void     clang_enableStackTraces (void);
+
+-- OMITTED: void     clang_executeOnThread (void(*fn)(void *), void * user_data, unsigned stack_size); // NOTE: function pointer syntax not supported by the libclang-bootstrap parser
+
+-- *** Miscellaneous utility functions ***
+
+-- <https://clang.llvm.org/doxygen/group__CINDEX__MISC.html>
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_getClangVersion :: W CXString_ -> IO ()
+
+-- OMITTED: void               clang_toggleCrashRecovery (unsigned isEnabled);
+
+-- OMITTED: void               clang_getInclusions (CXTranslationUnit tu, CXInclusionVisitor visitor, CXClientData client_data);
+
+foreign import capi unsafe "clang_wrappers.h"
+  wrap_Cursor_Evaluate :: R CXCursor_ -> IO CXEvalResult
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_getKind"
+  nowrapper_EvalResult_getKind :: CXEvalResult -> IO (SimpleEnum CXEvalResultKind)
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_getAsInt"
+  nowrapper_EvalResult_getAsInt :: CXEvalResult -> IO CInt
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_getAsLongLong"
+  nowrapper_EvalResult_getAsLongLong :: CXEvalResult -> IO CLLong
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_isUnsignedInt"
+  nowrapper_EvalResult_isUnsignedInt :: CXEvalResult -> IO CUInt
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_getAsUnsigned"
+  nowrapper_EvalResult_getAsUnsigned :: CXEvalResult -> IO CULLong
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_getAsDouble"
+  nowrapper_EvalResult_getAsDouble :: CXEvalResult -> IO CDouble
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_getAsStr"
+  nowrapper_EvalResult_getAsStr :: CXEvalResult -> IO (ConstPtr CChar)
+
+foreign import capi unsafe "clang_wrappers.h clang_EvalResult_dispose"
+  nowrapper_EvalResult_dispose :: CXEvalResult -> IO ()
+
diff --git a/src/Clang/Paths.hs b/src/Clang/Paths.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Paths.hs
@@ -0,0 +1,64 @@
+module Clang.Paths (
+    -- * Source paths
+    SourcePath(..)
+  , getSourcePath
+  , nullSourcePath
+
+    -- * C include directories
+  , CIncludeDir(..)
+  ) where
+
+import Data.String
+import Data.Text (Text)
+import Data.Text qualified as Text
+
+{-------------------------------------------------------------------------------
+  Source paths
+-------------------------------------------------------------------------------}
+
+-- | Filesystem path of a source file, typically a C header
+--
+-- The 'Text' type is used because Clang uses UTF-8 internally for everything,
+-- including paths.
+--
+-- The format of the path is platform-dependent.  For example, different
+-- directory separators are used on different platforms.
+newtype SourcePath = SourcePath Text
+  -- 'Show' instance valid due to 'IsString' instance
+  deriving newtype (Eq, IsString, Ord, Show)
+
+-- | Get the 'FilePath' representation of a 'SourcePath'
+getSourcePath :: SourcePath -> FilePath
+getSourcePath (SourcePath path) = Text.unpack path
+
+-- | Determine if a 'SourcePath' is empty
+nullSourcePath :: SourcePath -> Bool
+nullSourcePath (SourcePath path) = Text.null path
+
+{-------------------------------------------------------------------------------
+  C include directories
+-------------------------------------------------------------------------------}
+
+-- | C include directory
+--
+-- A /C include directory/ is a directory that contains C header files, and a
+-- /C include search path/ is a list of C include directories that is used to
+-- resolve headers.
+--
+-- The wrapped 'FilePath' may be absolute or relative to the current working
+-- directory.  When an include directive is resolved using a relative
+-- 'CIncludeDir', the resulting 'SourcePath' is also relative.
+--
+-- Examples:
+--
+-- * When using a C include search path that contains 'CIncludeDir'
+--   @/usr/include@, @#include <stdint.h>@ may resolve to 'SourcePath'
+--   @/usr/include/stdint.h@.
+--
+-- * When using a C include search path that contains 'CIncludeDir' @include@ (a
+--   directory in the current working directory), @#include <foo.h>@ may resolve
+--   to 'SourcePath' @include/foo.h@ (also relative to the current working
+--   directory).
+newtype CIncludeDir = CIncludeDir { getCIncludeDir :: FilePath }
+  -- 'Show' instance valid due to 'IsString' instance
+  deriving newtype (Eq, IsString, Ord, Show)
diff --git a/src/Clang/Version.hs b/src/Clang/Version.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Version.hs
@@ -0,0 +1,89 @@
+-- | @libclang@ version API
+module Clang.Version (
+    -- * Definition
+    ClangVersion(..)
+  , parseClangVersion
+    -- * Versions in use
+  , compileTimeClangVersionString
+  , compileTimeClangVersion
+  , runtimeClangVersionString
+  , runtimeClangVersion
+    -- * Version requirements
+  , isCompatibleClangVersion
+  , Requires
+  , requireClangVersion
+  ) where
+
+import Control.Applicative qualified as Applicative
+import Control.Monad.IO.Class
+import Data.Maybe (fromMaybe)
+import Data.Text (Text)
+import GHC.Stack
+import System.IO.Unsafe (unsafePerformIO)
+
+import Clang.Internal.ByValue
+import Clang.Internal.CXString ()
+import Clang.Internal.Results
+import Clang.LowLevel.FFI
+import Clang.Version.Internal (ClangVersion (..), parseClangVersion)
+
+import Version_libclang_bindings qualified
+
+{-------------------------------------------------------------------------------
+  Versions in use
+-------------------------------------------------------------------------------}
+
+-- | Version of @libclang@ linked at compile-time (string)
+compileTimeClangVersionString :: Text
+compileTimeClangVersionString =
+    Version_libclang_bindings.clangVersionCompileTime
+
+-- | Version of @libclang@ linked at compile-time
+compileTimeClangVersion :: ClangVersion
+compileTimeClangVersion = parseClangVersion compileTimeClangVersionString
+
+-- | Version of @libclang@ loaded at runtime (string)
+runtimeClangVersionString :: Text
+runtimeClangVersionString = unsafePerformIO $ preallocate_ wrap_getClangVersion
+{-# NOINLINE runtimeClangVersionString #-}
+
+-- | Version of @libclang@ loaded at runtime
+runtimeClangVersion :: ClangVersion
+runtimeClangVersion = parseClangVersion runtimeClangVersionString
+
+{-------------------------------------------------------------------------------
+  Version requirements
+-------------------------------------------------------------------------------}
+
+-- | Check for compatibility of two Clang versions
+--
+-- Two Clang versions are compatible if they have the same major and minor
+-- versions.
+isCompatibleClangVersion :: ClangVersion -> ClangVersion -> Bool
+isCompatibleClangVersion l r =
+    fromMaybe False $ Applicative.liftA2 (==) (proj l) (proj r)
+  where
+    proj :: ClangVersion -> Maybe (Int, Int)
+    proj = \case
+      ClangVersion (major, minor, _patch) -> Just (major, minor)
+      ClangVersionUnknown{}               -> Nothing
+
+-- | Version requirement
+--
+-- @Requires a@ means that version @a@ or later is required.  For example,
+-- @Requires (17, 0, 0)@ means that LLVM/Clang 17 or later is required.
+newtype Requires a = Requires a
+  deriving stock (Show)
+
+-- | Check that the version of @libclang@ loaded at runtime is greather than or
+-- equal to the specified version
+--
+-- 'CallFailed' is thrown if the current @libclang@ version is not greater than
+-- or equal to the specified version, or if it is unknown.
+requireClangVersion :: (MonadIO m, HasCallStack) => (Int, Int, Int) -> m ()
+requireClangVersion v =
+    case runtimeClangVersion of
+      ClangVersion version | version >= v ->
+        return ()
+      _otherwise ->
+        callFailedShow (Requires v)
diff --git a/src/Clang/Version/Internal.hs b/src/Clang/Version/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Version/Internal.hs
@@ -0,0 +1,210 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module Clang.Version.Internal (
+    -- * Definition
+    ClangVersion(..)
+  , parseClangVersion
+    -- * CLANG_VERSION macro
+  , checkUserClangVersion
+  ) where
+
+import Control.Monad (unless)
+import Data.Char qualified as Char
+import Data.Maybe
+import Data.Text (Text)
+import Data.Text qualified as Text
+import Foreign.C.String qualified as C
+import Language.Haskell.TH.Syntax qualified as TH
+import Text.Read (readMaybe)
+
+import Version_libclang_bindings (clangVersionCompileTime)
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Clang version
+--
+-- We're intentionally /not/ deriving 'Ord', to ensure that version comparisons
+-- take 'ClangVersionUnknown' into account.
+data ClangVersion =
+    -- | Parsed version number (major, minor, patch)
+    ClangVersion (Int, Int, Int)
+
+    -- | Unknown version
+    --
+    -- We get the version by parsing the result of @clang_getClangVersion@,
+    -- which explicitly says
+    --
+    -- > Return a version string, suitable for showing to a user, but not
+    -- > intended to be parsed (the format is not guaranteed to be stable).
+    --
+    -- Unfortunately, @libclang@ does not provide any other means of getting
+    -- the version number. We therefore parse the string anyway, and use
+    -- 'ClangVersionUnknown' when that fails.
+    --
+    -- NOTE: While @Index.h@ does provide @CINDEX_VERSION_MAJOR@ (which is
+    -- always zero) and @CINDEX_VERSION_MINOR@, unfortunately they do not map
+    -- cleanly to @clang@ versions, and do not provide sufficient resolution.
+    -- For example, a @CINDEX_VERSION_MINOR@ value of 64 could be any version
+    -- between @17.0.0@ and @20.1.7@ (and possibly more still).
+  | ClangVersionUnknown Text
+  deriving stock (Show, Eq) -- No 'Ord'
+
+-- | Parse clang version string
+--
+-- @clang_getClangVersion@ may return something like
+--
+-- > "Ubuntu clang version 14.0.0-1ubuntu1.1"
+-- > "Ubuntu clang version 18.1.3 (1ubuntu1)"
+-- > "Ubuntu clang version 19.1.1 (1ubuntu1~24.04.2)"
+-- > "clang version 14.0.6"
+-- > "clang version 14.0.6 (git@github.com:llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)"
+-- > "clang version 18.1.8 (https://github.com/llvm/llvm-project.git ad36915a8c42d51218eee4b53f2c0aae80eb17e9)"
+-- > "clang version 20.1.4 (https://github.com/llvm/llvm-project ec28b8f9cc7f2ac187d8a617a6d08d5e56f9120e)"
+--
+-- We try to find the proper version (14.0.0, 18.1.3, ..) in this string.
+parseClangVersion :: Text -> ClangVersion
+parseClangVersion versionString =
+      maybe (ClangVersionUnknown versionString) ClangVersion
+    . (>>= readParts)
+    . listToMaybe
+    . mapMaybe exactlyThree
+    . map (splitOn '.' . takeWhile isPartOfVersionProper)
+    . words
+    $ Text.unpack versionString
+  where
+    isPartOfVersionProper :: Char -> Bool
+    isPartOfVersionProper c = (c >= '0' && c <= '9') || (c == '.')
+
+    exactlyThree :: [a] -> Maybe (a, a, a)
+    exactlyThree [x, y, z]  = Just (x, y, z)
+    exactlyThree _otherwise = Nothing
+
+    readParts :: (String, String, String) -> Maybe (Int, Int, Int)
+    readParts (x, y, z) = (,,) <$> readMaybe x <*> readMaybe y <*> readMaybe z
+
+{-------------------------------------------------------------------------------
+  Auxiliary
+-------------------------------------------------------------------------------}
+
+-- | Split on every occurrence of the separator
+--
+-- > splitOn '.' "18.1.3" == ["18","1","3"]
+splitOn :: forall a. Eq a => a -> [a] -> [[a]]
+splitOn sep = go
+  where
+    go :: [a] -> [[a]]
+    go [] = []
+    go xs = case break (== sep) xs of
+              (pref, [])        -> [pref]
+              (pref, _sep:rest) -> pref : go rest
+
+{-------------------------------------------------------------------------------
+  CLANG_VERSION macro
+-------------------------------------------------------------------------------}
+
+-- There is no way to portably stringify a preprocessor macro in GHC.  (See
+-- <https://gitlab.haskell.org/ghc/ghc/-/issues/12516>.)  To work around this,
+-- we stringify the macro in C and define a C function that returns the string.
+$([] <$ TH.addForeignSource TH.LangC (unlines
+  [ "#define LCB_STR_HELPER(s) #s"
+  , "#define LCB_STR(s) LCB_STR_HELPER(s)"
+  , "const char *user_clang_version ="
+  , "#ifdef CLANG_VERSION"
+  , "  LCB_STR(CLANG_VERSION);"
+  , "#else"
+  , "  \"CLANG_VERSION_NOT_SET\";"
+  , "#endif"
+  , "const char *get_user_clang_version(void) {"
+  , "  return user_clang_version;"
+  , "}"
+  ]))
+
+foreign import ccall unsafe "get_user_clang_version"
+  get_user_clang_version :: IO C.CString
+
+-- | Clang version specified in the @CLANG_VERSION@ macro
+data UserClangVersion =
+    -- | Parsed version
+    --
+    -- This includes the original string (for error messages) as well as the
+    -- major, minor (optional), and patch (optional) numbers.
+    UserClangVersion (String, Int, Maybe Int, Maybe Int)
+
+    -- | Unknown version
+  | UserClangVersionUnknown String
+
+-- | Get the Clang version specified in the @CLANG_VERSION@ macro
+--
+-- This function returns 'Nothing' when the macro is not set.
+getUserClangVersion :: IO (Maybe UserClangVersion)
+getUserClangVersion =
+    get_user_clang_version >>= C.peekCString >>= return . \case
+      "CLANG_VERSION_NOT_SET" -> Nothing
+      s -> Just $
+        case sequence (parse s) of
+          Just [major, minor, patch] ->
+            UserClangVersion (s, major, Just minor, Just patch)
+          Just [major, minor] ->
+            UserClangVersion (s, major, Just minor, Nothing)
+          Just [major] ->
+            UserClangVersion (s, major, Nothing, Nothing)
+          _otherwise ->
+            UserClangVersionUnknown s
+  where
+    parse :: String -> [Maybe Int]
+    parse s = case span Char.isDigit s of
+      (l@(_:_), "")    -> [readMaybe l]
+      (l@(_:_), '.':r) -> readMaybe l : parse r
+      _otherwise       -> [Nothing]
+
+-- | Check the compile-time Clang version against the Clang version specified in
+-- the @CLANG_VERSION@ macro
+--
+-- Users may /optionally/ specify a Clang version in the @CLANG_VERSION@ macro.
+-- When set, this function is used to check that the compile-time Clang version
+-- matches, failing if not.  When not set, no check is performed.
+--
+-- Only the version number is checked.  The following checks are supported:
+--
+-- * @MAJOR@ to just check the major version (example: @21@)
+-- * @MAJOR.MINOR@ to check the major and minor versions (example: @21.1@)
+-- * @MAJOR.MINOR.PATCH@ to check the major, minor, and patch versions
+--   (example: @21.1.8@)
+--
+-- The primary motivation for this is to distinguish the Clang version in cached
+-- builds in the Cabal store.  Cabal does not consider system dependencies to
+-- determine when a package needs to be rebuilt.  This is particularly
+-- problematic for @libclang-bindings@ because the LLVM/Clang project has
+-- frequent releases, and it is easy to run into a situation where a library
+-- cached in the Cabal store no longer works.  This can be solved by clearing
+-- the Cabal store, but doing so may result in time-consuming recompilation of
+-- many other packages.  The @CLANG_VERSION@ macro provides a workaround:
+-- changing GHC options forces Cabal to rebuild the library.
+--
+-- The @CLANG_VERSION@ macro is generally set in a @cabal.project.local@ file,
+-- by configuring @-optc@ in @ghc-options@.  Note that @cc-options@ is /not/
+-- sufficient to force Cabal to rebuild the library.  Example:
+--
+-- @
+-- package libclang-bindings
+--   ghc-options: -optc=-DCLANG_VERSION=21.1
+-- @
+checkUserClangVersion :: TH.Q [TH.Dec]
+checkUserClangVersion = TH.runIO getUserClangVersion >>= ([] <$) . \case
+    Nothing -> return ()
+    Just (UserClangVersionUnknown s) ->
+      fail $ "Unable to parse CLANG_VERSION: " ++ s
+    Just (UserClangVersion (uVersion, uMajor, mUMinor, mUPatch)) ->
+      case parseClangVersion clangVersionCompileTime of
+        ClangVersionUnknown t ->
+          fail $ "Unable to parse linked libclang version: " ++ Text.unpack t
+        ClangVersion (major, minor, patch) -> do
+          let compatible =
+                uMajor == major
+                  && maybe True (== minor) mUMinor
+                  && maybe True (== patch) mUPatch
+          unless compatible . fail $
+            "CLANG_VERSION " ++ uVersion ++ " does not match "
+              ++ Text.unpack clangVersionCompileTime
diff --git a/src/Clang/Version/Internal/Check.hs b/src/Clang/Version/Internal/Check.hs
new file mode 100644
--- /dev/null
+++ b/src/Clang/Version/Internal/Check.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+-- | Use 'checkUserClangVersion' to process the @CLANG_VERSION@ macro
+module Clang.Version.Internal.Check () where
+
+import Clang.Version.Internal (checkUserClangVersion)
+
+$(checkUserClangVersion)
diff --git a/test/Test/Discover.hs b/test/Test/Discover.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Discover.hs
@@ -0,0 +1,72 @@
+module Test.Discover (tests) where
+
+import Control.Monad (forM_)
+import Data.IORef
+import GHC.Stack (CallStack)
+import System.Directory (doesDirectoryExist, doesFileExist)
+import Test.Tasty
+import Test.Tasty.HUnit
+
+import Clang.Discover
+
+{-------------------------------------------------------------------------------
+  List of tests
+
+  'getPaths' inspects (and the tests below temporarily set) process-global
+  environment variables, so the tests are run sequentially to avoid races with
+  each other.
+
+  We cannot assume that @clang@ is installed (and so cannot assume that any
+  particular path /is/ discovered), but the assertions below hold regardless of
+  the platform or whether @clang@ is available.
+-------------------------------------------------------------------------------}
+
+tests :: TestTree
+tests = sequentialTestGroup "Test.Discover" AllFinish [
+      testCaseInfo "discovered paths exist"      testDiscoveredPathsExist
+    , testCase     "disabled config"             testDisabledConfig
+    ]
+
+-- | Smoke test against the real environment
+--
+-- Discovery must not crash, and any path that /is/ reported must actually exist
+-- on disk.
+testDiscoveredPathsExist :: IO String
+testDiscoveredPathsExist = do
+    msgsRef <- newIORef []
+    let trace _cs msg = modifyIORef' msgsRef (msg :)
+
+    paths <- getPaths trace BuiltinIncDirClang
+    forM_ (pClangExe paths) $ \exe -> do
+      exists <- doesFileExist exe
+      assertBool ("discovered clang executable does not exist: " ++ exe) exists
+    forM_ (pBuiltinIncDir paths) $ \dir -> do
+      exists <- doesDirectoryExist dir
+      assertBool ("discovered builtin include dir does not exist: " ++ dir) exists
+
+    -- Report what was discovered (and the collected trace) on success.
+    msgs <- reverse <$> readIORef msgsRef
+    return $ unlines $ [
+          "clang executable:    " ++ show (pClangExe      paths)
+        , "builtin include dir: " ++ show (pBuiltinIncDir paths)
+        , "trace:"
+        ] ++ map (("  " ++) . show) msgs
+
+-- | With discovery disabled, no builtin include dir is reported, whether or not
+-- @clang@ is installed
+--
+-- We clear the environment variable so that an ambient setting cannot override
+-- the config.
+testDisabledConfig :: Assertion
+testDisabledConfig = do
+    paths <- getPaths ignoreTrace BuiltinIncDirDisable
+    assertEqual "disabled config yields no builtin include dir"
+      Nothing (pBuiltinIncDir paths)
+
+{-------------------------------------------------------------------------------
+  Auxiliary functions
+-------------------------------------------------------------------------------}
+
+-- | A trace function that discards all messages
+ignoreTrace :: CallStack -> DiscoverMsg -> IO ()
+ignoreTrace _cs _msg = return ()
diff --git a/test/Test/Meta/IsConcrete.hs b/test/Test/Meta/IsConcrete.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Meta/IsConcrete.hs
@@ -0,0 +1,57 @@
+-- | Test the invariant of 'IsConcrete'
+module Test.Meta.IsConcrete (tests) where
+
+import Data.Proxy
+import Test.QuickCheck.Monadic
+import Test.Tasty
+import Test.Tasty.HUnit
+import Test.Tasty.QuickCheck
+import Test.Util.AST qualified as AST
+import Test.Util.Input (TestInput)
+import Test.Util.Input.Examples
+import Test.Util.Input.StructForest (StructForest)
+
+{-------------------------------------------------------------------------------
+  Top-level
+-------------------------------------------------------------------------------}
+
+tests :: TestTree
+tests = testGroup "Test.Meta.IsConcrete" [
+      testGroup "sanity" [
+          testCase "SingleFunction" $ test SingleFunction
+        , testCase "SingleStruct"   $ test SingleStruct
+        , testCase "TwoStructs"     $ test ThreeStructs
+        ]
+    , testGroup "random" [
+          testProperty "StructForest" $ prop (Proxy @(StructForest ()))
+        ]
+    ]
+
+{-------------------------------------------------------------------------------
+  Properties
+-------------------------------------------------------------------------------}
+
+test :: AST.IsConcrete a => a -> Assertion
+test x = do
+    actualAST <- AST.parse (AST.toTestInput x)
+    assertEqual "" (AST.toAbstractAST x) $ actualAST
+
+prop ::
+     AST.IsConcrete a
+  => Proxy a -- ^ For which type should we generate a random value/
+  -> a -> Property
+prop _ x =
+    counterexample ("test input: " ++ show testInput) $
+      monadicIO go
+  where
+    testInput :: TestInput
+    testInput = AST.toTestInput x
+
+    expectedAST :: AST.AST AST.Descr
+    expectedAST = AST.toAbstractAST x
+
+    go :: PropertyM IO Property
+    go = do
+        actualAST <- run $ AST.parse testInput
+        return $ expectedAST === actualAST
+
diff --git a/test/Test/Test/Exceptions.hs b/test/Test/Test/Exceptions.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Test/Exceptions.hs
@@ -0,0 +1,253 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+-- | Test exception handling in folds
+--
+-- Exception handling during folding is tricky, since each child in the AST is
+-- processed by a separate callback from C to Haskell. We provide infrastructure
+-- for handling this (making this transparent to the user), which we test here.
+module Test.Test.Exceptions (tests) where
+
+import Control.Exception
+import Data.Maybe (fromMaybe)
+import Data.Text (Text)
+import Data.Text qualified as Text
+import Test.QuickCheck.Monadic
+import Test.Tasty
+import Test.Tasty.HUnit
+import Test.Tasty.QuickCheck
+import Test.Util.AST (AST (..))
+import Test.Util.AST qualified as AST
+import Test.Util.Clang qualified as Clang
+import Test.Util.FoldException (FoldException (..))
+import Test.Util.FoldException qualified as FoldException
+import Test.Util.Input (TestInput)
+import Test.Util.Input.Examples
+import Test.Util.Input.StructForest (StructForest (..))
+import Test.Util.Input.StructForest qualified as StructForest
+
+import Clang.Enum.Simple
+import Clang.HighLevel.Types hiding (FoldException)
+import Clang.LowLevel.Core
+
+{-------------------------------------------------------------------------------
+  List of tests
+-------------------------------------------------------------------------------}
+
+tests :: TestTree
+tests = testGroup "Test.Test.Exceptions" [
+      testGroup "Demo" [
+          testCase "demo1" demo1
+        , testCase "demo2" demo2
+        , testCase "demo3" demo3
+        ]
+    , testGroup "Sanity" [
+          testCase "withinLevel"  exceptions_withinLevel
+        , testCase "acrossLevels" exceptions_acrossLevels
+        , testCase "outsideFold"  exceptions_outsideFold
+        ]
+    , testProperty "property" prop_exceptions
+    ]
+
+{-------------------------------------------------------------------------------
+  Demonstrate the need for specialized exception
+
+  These examples are used in the documentation of 'foldWithHandler'.
+-------------------------------------------------------------------------------}
+
+demo1 :: Assertion
+demo1 = do
+    result <- Clang.parseUsing foldStruct $ AST.toTestInput ThreeStructs
+    assertEqual "" result $ [["a", "b"], ["c", "d"], ["e", "f"]]
+  where
+    foldStruct :: Fold IO [Text]
+    foldStruct = simpleFold $ \curr -> do
+        kind <- fromSimpleEnum <$> clang_getCursorKind curr
+        case kind of
+          Right CXCursor_StructDecl ->
+            foldRecursePure foldField concat
+          _otherwise ->
+            error $ "unexpected: " ++ show kind
+
+    foldField :: Fold IO [Text]
+    foldField = simpleFold $ \curr -> do
+        kind <- fromSimpleEnum <$> clang_getCursorKind curr
+        case kind of
+          Right CXCursor_FieldDecl -> do
+            name <- clang_getCursorSpelling curr
+            foldContinueWith [name]
+          _otherwise ->
+            error $ "unexpected: " ++ show kind
+
+demo2 :: Assertion
+demo2 = do
+    mResult <- try $ Clang.parseUsing foldStruct $ AST.toTestInput ThreeStructs
+    case mResult of
+      Left UnexpectedField -> return ()
+      Right result -> assertFailure $ "Unexpected " ++ show result
+  where
+    foldStruct :: Fold IO [Text]
+    foldStruct = simpleFold $ \curr ->
+        handle (foldContinueWith . hasUnexpectedField) $ do
+          kind <- fromSimpleEnum <$> clang_getCursorKind curr
+          case kind of
+            Right CXCursor_StructDecl ->
+              foldRecursePure foldField concat
+            _otherwise ->
+              error $ "unexpected: " ++ show kind
+
+    foldField :: Fold IO [Text]
+    foldField = simpleFold $ \curr -> do
+        kind <- fromSimpleEnum <$> clang_getCursorKind curr
+        case kind of
+          Right CXCursor_FieldDecl -> do
+            name <- clang_getCursorSpelling curr
+            if name == "c"
+              then throwIO UnexpectedField
+              else foldContinueWith [name]
+          _otherwise ->
+            error $ "unexpected: " ++ show kind
+
+demo3 :: Assertion
+demo3 = do
+    result <- Clang.parseUsing foldStruct $ AST.toTestInput ThreeStructs
+    assertEqual "" result $ [["a", "b"], [], ["e", "f"]]
+  where
+    foldStruct :: Fold IO [Text]
+    foldStruct =
+        foldWithHandler (\_curr -> return . HandlerResult . Just . hasUnexpectedField) $ \curr -> do
+          kind <- fromSimpleEnum <$> clang_getCursorKind curr
+          case kind of
+            Right CXCursor_StructDecl ->
+              foldRecursePure foldField concat
+            _otherwise ->
+              error $ "unexpected: " ++ show kind
+
+    foldField :: Fold IO [Text]
+    foldField = simpleFold $ \curr -> do
+        kind <- fromSimpleEnum <$> clang_getCursorKind curr
+        case kind of
+          Right CXCursor_FieldDecl -> do
+            name <- clang_getCursorSpelling curr
+            if name == "c"
+              then throwIO UnexpectedField
+              else foldContinueWith [name]
+          _otherwise ->
+            error $ "unexpected: " ++ show kind
+
+data UnexpectedField = UnexpectedField
+  deriving stock (Show)
+  deriving anyclass (Exception)
+
+hasUnexpectedField :: UnexpectedField -> [Text]
+hasUnexpectedField UnexpectedField = []
+
+{-------------------------------------------------------------------------------
+  Sanity checks
+-------------------------------------------------------------------------------}
+
+-- | Sanity check: catch an exception within one level of the fold
+exceptions_withinLevel :: Assertion
+exceptions_withinLevel = do
+    result <- AST.parseUsing fold $ AST.toTestInput SingleFunction
+    assertEqual "" expected $ result
+  where
+    fold :: Fold IO (AST.Node AST.Descr)
+    fold = foldWithHandler FoldException.handleAt $ \_curr ->
+        throwIO $ FoldException 1
+
+    expected :: AST AST.Descr
+    expected = AST $ AST.Siblings [
+          AST.Node descrAtException $ AST.Siblings []
+        ]
+
+    descrAtException :: AST.Descr
+    descrAtException =
+        FoldException.descrAt
+          (AST.defaultDescr "f" CXCursor_FunctionDecl)
+          (FoldException 1)
+
+-- | At a higher level of the AST catch exception thrown at a lower level
+exceptions_acrossLevels :: Assertion
+exceptions_acrossLevels = do
+    result<- AST.parseUsing higherLevel $ AST.toTestInput SingleStruct
+    assertEqual "" expected $ result
+  where
+    higherLevel :: Fold IO (AST.Node AST.Descr)
+    higherLevel = foldWithHandler FoldException.handleAt $ \curr -> do
+        descr <- AST.descrAt curr
+        foldRecursePure lowerLevel (AST.Node descr . AST.Siblings)
+
+    lowerLevel :: Fold IO (AST.Node AST.Descr)
+    lowerLevel = simpleFold $ \curr -> do
+        descr <- AST.descrAt curr
+        kind  <- clang_getCursorKind curr
+        case fromSimpleEnum kind of
+          Right CXCursor_FieldDecl ->
+            throw $ FoldException 1
+          _otherwise ->
+            foldRecursePure lowerLevel (AST.Node descr . AST.Siblings)
+
+    -- We only have an exception handler at the very top, so the exception is
+    -- reported at @foo@, even though it was thrown at @x@.
+    expected :: AST AST.Descr
+    expected = AST $ AST.Siblings [
+          AST.Node descrAtException $ AST.Siblings []
+        ]
+
+    descrAtException :: AST.Descr
+    descrAtException =
+        FoldException.descrAt
+          (AST.defaultDescr "foo" CXCursor_StructDecl)
+          (FoldException 1)
+
+-- | Outside the scope of the fold catch exception thrown inside the scope
+exceptions_outsideFold :: Assertion
+exceptions_outsideFold = do
+    result <- handle FoldException.handleTopLevel $
+                AST.parseUsing fold $ AST.toTestInput SingleFunction
+    assertEqual "" expected $ result
+  where
+    fold :: Fold IO (AST.Node AST.Descr)
+    fold = simpleFold $ \_curr -> throwIO $ FoldException 1
+
+    expected :: AST AST.Descr
+    expected = AST $ AST.Siblings [
+          AST.Node descrAtException $ AST.Siblings []
+        ]
+
+    descrAtException :: AST.Descr
+    descrAtException = FoldException.descrTopLevel $ FoldException 1
+
+{-------------------------------------------------------------------------------
+  Exceptions: properties
+-------------------------------------------------------------------------------}
+
+prop_exceptions :: StructForest FoldException.Info -> Property
+prop_exceptions structForest =
+    counterexample ("test input: " ++ show testInput) $
+      monadicIO go
+  where
+    testInput :: TestInput
+    testInput = StructForest.toTestInput structForest
+
+    expectedAST :: AST AST.Descr
+    expectedAST =
+        FoldException.model $
+          StructForest.toAbstractAST FoldException.defaultInfo structForest
+
+    go :: PropertyM IO Property
+    go = do
+        actualAST <- run $ FoldException.parse infoForCursor testInput
+        return $ expectedAST === actualAST
+
+    infoForCursor :: CXCursor -> IO FoldException.Info
+    infoForCursor curr = do
+        mKind <- fromSimpleEnum <$> clang_getCursorKind curr
+        name  <- Text.unpack <$> clang_getCursorSpelling curr
+        return $
+          case mKind of
+            Right CXCursor_StructDecl ->
+              fromMaybe FoldException.defaultInfo $
+                StructForest.lookup name structForest
+            _otherwise ->
+              FoldException.defaultInfo
diff --git a/test/Test/Util/AST.hs b/test/Test/Util/AST.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/AST.hs
@@ -0,0 +1,145 @@
+-- | Abstract syntax tree
+--
+-- Intended for qualified import.
+--
+-- > import Test.Util.AST (AST(..))
+-- > import Test.Util.AST qualified as AST
+module Test.Util.AST (
+    -- * Definition
+    AST(..)
+  , Siblings(..)
+  , Node(..)
+  , Descr(..)
+  , defaultDescr
+    -- * Concrete ASTs
+  , IsConcrete(..)
+  , ShowComment(..)
+    -- * Clang interop
+  , descrAt
+  , fold
+  , parse
+  , parseUsing
+  ) where
+
+import Data.Text qualified as Text
+import Data.Tree (Forest, Tree)
+import Data.Tree qualified as Tree
+import Test.Util.Clang qualified as Clang
+import Test.Util.Input (TestInput)
+
+import Clang.Enum.Simple
+import Clang.HighLevel.Types
+import Clang.LowLevel.Core
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Top-level AST
+--
+-- The most common instantiation of @a@ is 'Descr'.
+data AST a = AST (Siblings a)
+  deriving stock (Eq, Functor)
+
+-- | Siblings (children of the same node)
+data Siblings a = Siblings [Node a]
+  deriving stock (Eq, Functor)
+
+-- | Single node in the AST
+data Node a = Node a (Siblings a)
+  deriving stock (Eq, Functor)
+
+-- | Description of a node in the tree
+newtype Descr = Descr String
+  deriving newtype (Eq, Show)
+
+-- | Default description of a name and a kind
+defaultDescr :: String -> CXCursorKind -> Descr
+defaultDescr name kind = Descr $ name ++ " (" ++ show kind ++ ")"
+
+{-------------------------------------------------------------------------------
+  'Show' instances
+-------------------------------------------------------------------------------}
+
+-- | Produce human readable AST
+--
+-- This instance (as well as other 'Show' instances in the test infrastructure)
+-- is not law-abiding, as it does not generate valid Haskell code. It is used by
+-- QuickCheck for more readable output.
+instance Show a => Show (AST a) where
+  show = ("\n" ++) . Tree.drawTree . addTop . toForest . fmap show
+    where
+      -- An artificial @<top>@ node makes the output more readable
+      -- (otherwise top-level siblings seem unrelated)
+      addTop :: Forest String -> Tree String
+      addTop = Tree.Node "<top>"
+
+{-------------------------------------------------------------------------------
+  Conversions
+-------------------------------------------------------------------------------}
+
+fromSiblings :: Siblings a -> [Node a]
+fromSiblings (Siblings xs) = xs
+
+-- | Internal: translate to 'Forest'
+--
+-- We don't use 'Forest' and 'Tree' directly because we want to use 'Siblings'
+-- instead of @[]@ for improved type-level clarity.
+toForest :: forall a. AST a -> Forest a
+toForest = \(AST xs) -> goSiblings xs
+  where
+    goSiblings :: Siblings a -> Forest a
+    goSiblings = map goNode . fromSiblings
+
+    -- goNode :: Node a -> Tree a
+    goNode :: Node a -> Tree a
+    goNode (Node x xs) = Tree.Node x (goSiblings xs)
+
+{-------------------------------------------------------------------------------
+  Concrete ASTs
+-------------------------------------------------------------------------------}
+
+-- | Concrete AST
+--
+-- For something to be a concrete AST, we need to be able to produce a C
+-- header ('TestInput') from it, such that when we parse that C input, the
+-- resulting abstract AST is precisely the expected abstract AST.
+class IsConcrete a where
+  toTestInput   :: a -> TestInput
+  toAbstractAST :: a -> AST Descr
+
+-- | Show something as an optional C comment
+--
+-- This is sometimes helpful when implementing 'toTestInput'.
+class ShowComment a where
+  showComment :: a -> Maybe TestInput
+
+instance ShowComment () where
+  showComment _ = Nothing
+
+{-------------------------------------------------------------------------------
+  Construction
+-------------------------------------------------------------------------------}
+
+descrAt :: CXCursor -> IO Descr
+descrAt curr = do
+    mKind <- fromSimpleEnum <$> clang_getCursorKind curr
+    name  <- Text.unpack <$> clang_getCursorSpelling curr
+    case mKind of
+      Right kind -> return $ defaultDescr name kind
+      Left  err  -> error $ "Unknown kind:  " ++ show err
+
+-- | Construct the AST
+--
+-- Since this is for testing purposes, we ignore most of the contents of the
+-- AST, recording only its shape and names.
+fold :: Fold IO (Node Descr)
+fold = simpleFold $ \curr -> do
+    node <- descrAt curr
+    foldRecursePure fold (Node node . Siblings)
+
+parseUsing :: Fold IO (Node Descr) -> TestInput -> IO (AST Descr)
+parseUsing f input = AST . Siblings <$> Clang.parseUsing f input
+
+parse :: TestInput -> IO (AST Descr)
+parse = parseUsing fold
diff --git a/test/Test/Util/Clang.hs b/test/Test/Util/Clang.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/Clang.hs
@@ -0,0 +1,45 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+-- | Convenience functions around the clang bindings
+--
+-- Intended for unqualified import.
+module Test.Util.Clang (
+    -- * Top-level call into clang
+    withInput
+  , parseUsing
+  ) where
+
+import Control.Exception
+import Data.Default
+import Test.Util.Input (TestInput (..))
+
+import Clang.Enum.Simple
+import Clang.HighLevel qualified as HighLevel
+import Clang.HighLevel.Types
+import Clang.LowLevel.Core
+
+{-------------------------------------------------------------------------------
+  Top-level call into clang
+-------------------------------------------------------------------------------}
+
+withInput :: TestInput -> (CXTranslationUnit -> IO a) -> IO a
+withInput (TestInput input) onSuccess =
+    HighLevel.withUnsavedFile "test.h" input $ \file ->
+    HighLevel.withIndex DisplayDiagnostics   $ \ix   ->
+    HighLevel.withTranslationUnit2
+      ix
+      (Just "test.h")
+      def
+      [file]
+      mempty
+      onFailure
+      onSuccess
+  where
+    onFailure :: SimpleEnum CXErrorCode -> IO a
+    onFailure = throwIO . userError . show
+
+parseUsing :: Fold IO a -> TestInput -> IO [a]
+parseUsing fold input = do
+    withInput input $ \unit -> do
+      root   <- clang_getTranslationUnitCursor unit
+      HighLevel.clang_visitChildren root fold
diff --git a/test/Test/Util/FoldException.hs b/test/Test/Util/FoldException.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/FoldException.hs
@@ -0,0 +1,185 @@
+-- | Artificial exceptions in folds
+--
+-- Intended for qualified import.
+--
+-- > import Test.Util.FoldException (FoldException(..))
+-- > import Test.Util.FoldException qualified as FoldException
+module Test.Util.FoldException (
+    -- * Definition
+    FoldException(..)
+  , descrAt
+  , descrTopLevel
+  , handleAt
+  , handleTopLevel
+    -- * Instrumentation
+  , Info(..)
+  , defaultInfo
+    -- ** Execution
+  , parse
+    -- * Model
+  , model
+  ) where
+
+import Control.Exception (Exception)
+import Control.Exception qualified as Exception
+import Control.Monad
+import Control.Monad.Except
+import Data.String
+import Test.QuickCheck
+import Test.Util.AST (AST (..))
+import Test.Util.AST qualified as AST
+import Test.Util.Clang qualified as Clang
+import Test.Util.Input (TestInput)
+
+import Clang.HighLevel.Types hiding (FoldException)
+import Clang.LowLevel.Core
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Exception thrown by instrumented fold
+--
+-- The 'Int' parameter means that if we throw (and possibly catch) /multiple/
+-- exceptions from inside a fold, that we end up with the correct one.
+data FoldException = FoldException Int
+  deriving stock (Show)
+  deriving anyclass (Exception)
+
+-- | Description generated by handler somewhere during folding
+descrAt :: AST.Descr -> FoldException -> AST.Descr
+descrAt (AST.Descr context) ex = AST.Descr $
+    show ex ++ " at " ++ context
+
+-- | Description generated by top-level handler (outside the fold entirely)
+descrTopLevel :: FoldException -> AST.Descr
+descrTopLevel ex = AST.Descr $
+    show ex ++ " at top-level"
+
+-- | Handler intended for use in folds
+handleAt :: CXCursor -> FoldException -> IO (HandlerResult (Maybe (AST.Node AST.Descr)))
+handleAt curr ex = do
+    node <- AST.descrAt curr
+    return $ HandlerResult $ Just $ AST.Node (descrAt node ex) $ AST.Siblings []
+
+-- | Top-level handler
+--
+-- Since this handler is /outside/ the scope of the fold, we don't get a cursor,
+-- and so cannot report an error location within the AST.
+handleTopLevel :: FoldException -> IO (AST AST.Descr)
+handleTopLevel ex = return $ AST . AST.Siblings $ [
+      AST.Node (descrTopLevel ex) $ AST.Siblings []
+    ]
+
+{-------------------------------------------------------------------------------
+  Info
+-------------------------------------------------------------------------------}
+
+-- | Local information about exception behaviour
+--
+-- This is the /local/ information at this node: does /this/ node catch or
+-- /throw/ something. See also 'RecursiveInfo'.
+data Info = Info {
+      exceptionHandler :: Bool
+    , throwInBody      :: Maybe Int
+    , throwInSummarize :: Maybe Int
+    }
+  deriving stock (Show)
+
+defaultInfo :: Info
+defaultInfo = Info {
+      exceptionHandler = False
+    , throwInBody      = Nothing
+    , throwInSummarize = Nothing
+    }
+
+instance Arbitrary Info where
+  arbitrary =
+      pure Info
+        <*> arbitrary
+        <*> arbitrary
+        <*> arbitrary
+
+  shrink info = concat [
+        [ info{exceptionHandler = x} | x <- shrink exceptionHandler ]
+      , [ info{throwInBody      = x} | x <- shrink throwInBody      ]
+      , [ info{throwInSummarize = x} | x <- shrink throwInSummarize ]
+      ]
+    where
+      Info{exceptionHandler, throwInBody, throwInSummarize} = info
+
+instance AST.ShowComment Info where
+  showComment info = Just $ fromString $ "// " <> show info
+
+{-------------------------------------------------------------------------------
+  Execution of 'Info'
+-------------------------------------------------------------------------------}
+
+fold :: (CXCursor -> IO Info) -> Fold IO (AST.Node AST.Descr)
+fold infoForCursor = go
+  where
+    go :: Fold IO (AST.Node AST.Descr)
+    go = foldWithHandler handler $ \curr -> do
+        info <- infoForCursor curr
+        case throwInBody info of
+          Just n  -> Exception.throwIO $ FoldException n
+          Nothing -> do
+            node <- AST.descrAt curr
+            foldRecurseWith go $ \children ->
+              case throwInSummarize info of
+                Just n  -> Exception.throwIO $ FoldException n
+                Nothing -> return $ AST.Node node (AST.Siblings children)
+
+    handler :: CXCursor -> FoldException -> IO (HandlerResult (Maybe (AST.Node AST.Descr)))
+    handler curr e = do
+        info <- infoForCursor curr
+        if exceptionHandler info
+          then handleAt curr e
+          else return HandlerRethrow
+
+parse :: (CXCursor -> IO Info) -> TestInput -> IO (AST AST.Descr)
+parse infoForCursor input =
+    Exception.handle handleTopLevel $
+      AST . AST.Siblings <$> Clang.parseUsing (fold infoForCursor) input
+
+{-------------------------------------------------------------------------------
+  Model
+-------------------------------------------------------------------------------}
+
+-- | Model that tells us what should happen in the presence of exceptions
+model :: AST (AST.Descr, Info) -> AST AST.Descr
+model = \(AST siblings) ->
+    either catchTopLevel id $
+      AST <$> runExcept (goSiblings siblings)
+  where
+    -- Model equivalent of 'handleTopLevel'
+    catchTopLevel :: FoldException -> AST AST.Descr
+    catchTopLevel ex = AST . AST.Siblings $ [
+          AST.Node (descrTopLevel ex) $ AST.Siblings []
+        ]
+
+    goSiblings ::
+         AST.Siblings (AST.Descr, Info)
+      -> Except FoldException (AST.Siblings AST.Descr)
+    goSiblings (AST.Siblings siblings) = AST.Siblings <$> mapM goNode siblings
+
+    goNode ::
+         AST.Node (AST.Descr, Info)
+      -> Except FoldException (AST.Node AST.Descr)
+    goNode (AST.Node (descr, info) children) =
+        flip catchError catchAt $ do
+          -- The order here matters for /which/ exception we might throw:
+          -- first body, then children, and finally summarize
+          forM_ (throwInBody info) $ throwError . FoldException
+          children' <- goSiblings children
+          forM_ (throwInSummarize info) $ throwError . FoldException
+          return $ AST.Node descr children'
+      where
+        -- Model equivalent of 'handleAt'
+        catchAt :: FoldException -> Except FoldException (AST.Node AST.Descr)
+        catchAt ex
+          | exceptionHandler info
+          = return $ AST.Node (descrAt descr ex) $ AST.Siblings []
+
+          | otherwise
+          = throwError ex
diff --git a/test/Test/Util/Input.hs b/test/Test/Util/Input.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/Input.hs
@@ -0,0 +1,53 @@
+-- | Test inputs
+--
+-- Intended for qualified import:
+--
+-- > import Test.Util.Input (TestInput(..), ToTestInput(..), ShowComment(..))
+-- > import Test.Util.Input qualified as Input
+module Test.Util.Input (
+    TestInput(..)
+    -- * Construction
+  , unlines
+  , intercalate
+  , indent
+  ) where
+
+import Prelude hiding (unlines)
+import Prelude qualified
+
+import Data.Coerce
+import Data.List qualified as List
+import Data.String (IsString)
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | Test input (header)
+--
+-- The 'Show' instance for 'TestInput' is just the string itself, without any
+-- escaping; this results in much more readable test output.
+newtype TestInput = TestInput String
+  deriving newtype (IsString, Semigroup, Monoid)
+
+instance Show TestInput where
+  show (TestInput header) = "\n" ++ header
+
+{-------------------------------------------------------------------------------
+  Construction
+-------------------------------------------------------------------------------}
+
+unlines :: [String] -> TestInput
+unlines = coerce Prelude.unlines
+
+intercalate :: String -> [TestInput] -> TestInput
+intercalate = coerce (List.intercalate @Char)
+
+indent :: TestInput -> TestInput
+indent (TestInput input) = TestInput $
+    -- Don't define this using 'Prelude.unlines' to avoid trailing newlines
+    "  " ++ concatMap aux input
+  where
+    aux :: Char -> String
+    aux '\n' = "\n  "
+    aux c    = [c]
diff --git a/test/Test/Util/Input/Examples.hs b/test/Test/Util/Input/Examples.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/Input/Examples.hs
@@ -0,0 +1,104 @@
+-- | Example inputs
+--
+-- Intended for unqualified import.
+module Test.Util.Input.Examples (ExampleInput(..)) where
+
+import Test.Util.AST (AST (..))
+import Test.Util.AST qualified as AST
+import Test.Util.Input (TestInput)
+import Test.Util.Input qualified as TestInput
+
+import Clang.LowLevel.Core (CXCursorKind (..))
+
+{-------------------------------------------------------------------------------
+  Top-level
+-------------------------------------------------------------------------------}
+
+data ExampleInput =
+    SingleFunction
+  | SingleStruct
+  | ThreeStructs
+
+instance AST.IsConcrete ExampleInput where
+  toTestInput = \case
+      SingleFunction -> inputSingleFunction
+      SingleStruct   -> inputSingleStruct
+      ThreeStructs   -> inputThreeStructs
+
+  toAbstractAST = \case
+      SingleFunction -> astSingleFunction
+      SingleStruct   -> astSingleStruct
+      ThreeStructs   -> astThreeStructs
+
+{-------------------------------------------------------------------------------
+  Example: single function
+-------------------------------------------------------------------------------}
+
+astSingleFunction :: AST AST.Descr
+astSingleFunction = AST $ AST.Siblings [
+      AST.Node (AST.defaultDescr "f" CXCursor_FunctionDecl) $
+        AST.Siblings []
+    ]
+
+inputSingleFunction :: TestInput
+inputSingleFunction = TestInput.unlines [
+      "void f();"
+    ]
+
+{-------------------------------------------------------------------------------
+  Example: single struct
+-------------------------------------------------------------------------------}
+
+inputSingleStruct :: TestInput
+inputSingleStruct = TestInput.unlines [
+      "struct foo {"
+    , "  int x;"
+    , "  int y;"
+    , "};"
+    ]
+
+astSingleStruct :: AST AST.Descr
+astSingleStruct = AST $ AST.Siblings [
+      AST.Node (AST.defaultDescr "foo" CXCursor_StructDecl) $ AST.Siblings [
+          AST.Node (AST.defaultDescr "x" CXCursor_FieldDecl) $ AST.Siblings []
+        , AST.Node (AST.defaultDescr "y" CXCursor_FieldDecl) $ AST.Siblings []
+        ]
+    ]
+
+{-------------------------------------------------------------------------------
+  Example: three structs
+-------------------------------------------------------------------------------}
+
+inputThreeStructs :: TestInput
+inputThreeStructs = TestInput.unlines [
+      "struct foo {"
+    , "  int a;"
+    , "  int b;"
+    , "};"
+    , ""
+    , "struct bar {"
+    , "  int c;"
+    , "  int d;"
+    , "};"
+    , ""
+    , "struct baz {"
+    , "  int e;"
+    , "  int f;"
+    , "};"
+    ]
+
+astThreeStructs :: AST AST.Descr
+astThreeStructs = AST $ AST.Siblings [
+      AST.Node (AST.defaultDescr "foo" CXCursor_StructDecl) $ AST.Siblings [
+          AST.Node (AST.defaultDescr "a" CXCursor_FieldDecl) $ AST.Siblings []
+        , AST.Node (AST.defaultDescr "b" CXCursor_FieldDecl) $ AST.Siblings []
+        ]
+    , AST.Node (AST.defaultDescr "bar" CXCursor_StructDecl) $ AST.Siblings [
+          AST.Node (AST.defaultDescr "c" CXCursor_FieldDecl) $ AST.Siblings []
+        , AST.Node (AST.defaultDescr "d" CXCursor_FieldDecl) $ AST.Siblings []
+        ]
+    , AST.Node (AST.defaultDescr "baz" CXCursor_StructDecl) $ AST.Siblings [
+          AST.Node (AST.defaultDescr "e" CXCursor_FieldDecl) $ AST.Siblings []
+        , AST.Node (AST.defaultDescr "f" CXCursor_FieldDecl) $ AST.Siblings []
+        ]
+    ]
diff --git a/test/Test/Util/Input/StructForest.hs b/test/Test/Util/Input/StructForest.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/Input/StructForest.hs
@@ -0,0 +1,210 @@
+-- | Randomly generated C input: tree of structs
+--
+-- Intended for qualified import.
+--
+-- > import Test.Util.Input.StructForest (StructForest)
+-- > import Test.Util.Input.StructForest qualified as StructForest
+module Test.Util.Input.StructForest (
+    -- * Definition
+    StructForest(StructForest, structForest)
+  , StructTree(..)
+  , StructField(..)
+    -- * Query
+  , lookup
+    -- * Execution
+  , toAbstractAST
+  , toTestInput
+  ) where
+
+import Prelude hiding (lookup)
+
+import Data.Foldable (asum)
+import Data.List qualified as List
+import Data.String
+import Data.Tree (Tree (Node))
+import Test.QuickCheck
+import Test.Util.AST (AST (..))
+import Test.Util.AST qualified as AST
+import Test.Util.Input (TestInput (..))
+import Test.Util.Input qualified as Input
+import Test.Util.Shape (Shape)
+import Test.Util.Shape qualified as Shape
+
+import Clang.LowLevel.Core (CXCursorKind (..))
+
+{-------------------------------------------------------------------------------
+  Definition
+-------------------------------------------------------------------------------}
+
+-- | List of struct trees
+--
+-- The annotation type (@a@) is used for 'FoldException.Info' or @()@.
+data StructForest a =
+    StructForest {
+        structForest      :: [StructTree a]
+      , structForestShape :: Shape a
+      }
+  deriving stock (Show)
+
+-- | Tree of structs
+data StructTree a =
+    StructTree {
+        structName   :: String
+      , structFields :: [StructField a]
+      , structAnn    :: a
+      }
+  deriving stock (Show)
+
+data StructField a =
+    StructField {
+        fieldName :: String
+      , fieldType :: FieldType a
+      }
+  deriving stock (Show)
+
+data FieldType a =
+    TypeInt
+  | TypeStruct (StructTree a)
+  deriving stock (Show)
+
+{-------------------------------------------------------------------------------
+  Construction
+-------------------------------------------------------------------------------}
+
+instance Arbitrary a => Arbitrary (StructForest a) where
+  arbitrary = fromShape <$> arbitrary1
+  shrink    = map fromShape . shrink1 . structForestShape
+
+fromShape :: forall a. Shape a -> StructForest a
+fromShape structForestShape = StructForest {
+      structForest = map struct $ Shape.toForest structForestShape
+    , structForestShape
+    }
+  where
+    struct :: Tree (a, [Int]) -> StructTree a
+    struct (Node (x, path) children) = StructTree {
+          structName   = mkStructName path
+        , structFields = map field children
+        , structAnn    = x
+        }
+
+    field :: Tree (a, [Int]) -> StructField a
+    field node@(Node (_x, path) children) = StructField {
+          fieldName = mkFieldName path
+        , fieldType = case children of
+                        [] -> TypeInt
+                        _  -> TypeStruct (struct node)
+        }
+
+{-------------------------------------------------------------------------------
+  Query
+-------------------------------------------------------------------------------}
+
+-- | Get annotation of specified struct
+lookup :: forall a. String -> StructForest a -> Maybe a
+lookup key StructForest{structForest} =
+    asum $ map goStruct structForest
+  where
+    goStruct :: StructTree a -> Maybe a
+    goStruct StructTree{structName, structFields, structAnn}
+      | structName == key = Just structAnn
+      | otherwise         = asum $ map goField structFields
+
+    goField :: StructField a -> Maybe a
+    goField StructField{fieldType} =
+        case fieldType of
+          TypeInt           -> Nothing
+          TypeStruct struct -> goStruct struct
+
+{-------------------------------------------------------------------------------
+  Expected AST
+-------------------------------------------------------------------------------}
+
+toAbstractAST :: forall a.
+     a -- ^ Annotation on fields
+  -> StructForest a -> AST (AST.Descr, a)
+toAbstractAST fieldAnn =
+    AST . AST.Siblings . map goStruct . structForest
+  where
+    goStruct :: StructTree a -> AST.Node (AST.Descr, a)
+    goStruct StructTree{structName, structFields, structAnn} =
+        AST.Node (descr, structAnn) $
+          AST.Siblings (concatMap goField structFields)
+      where
+        descr :: AST.Descr
+        descr = AST.defaultDescr structName CXCursor_StructDecl
+
+    goField :: StructField a -> [AST.Node (AST.Descr, a)]
+    goField StructField{fieldName, fieldType} =
+        case fieldType of
+          TypeInt -> [
+              AST.Node (descr, fieldAnn) $ AST.Siblings []
+            ]
+          -- The clang AST has a weird quirk, where the struct is repeated (or
+          -- at least visited) /twice/: once before the field, and once as a
+          -- child /of/ the field.
+          TypeStruct struct -> [
+              goStruct struct
+            , AST.Node (descr, fieldAnn) $ AST.Siblings [goStruct struct]
+            ]
+      where
+        descr :: AST.Descr
+        descr = AST.defaultDescr fieldName CXCursor_FieldDecl
+
+{-------------------------------------------------------------------------------
+  Generate test input
+-------------------------------------------------------------------------------}
+
+toTestInput :: forall a. AST.ShowComment a => StructForest a -> TestInput
+toTestInput StructForest{structForest} = mconcat [
+      Input.unlines [
+          "#ifndef STRUCT_TREE"
+        , "#define STRUCT_TREE"
+        , ""
+        ]
+    , Input.intercalate "\n\n" $ map (goStruct Nothing) structForest
+    , Input.unlines [
+            ""
+          , "#endif // STRUCT_TREE"
+          ]
+    ]
+  where
+    goStruct :: Maybe String -> StructTree a -> TestInput
+    goStruct mFieldName StructTree{structName, structFields, structAnn} =
+        Input.intercalate "\n" . mconcat $ [
+            [ comment
+            | Just comment <- [AST.showComment structAnn]
+            ]
+          , [ fromString $ "struct " ++ structName ++ " {"
+            , Input.indent $ Input.intercalate "\n" $ map goField structFields
+            , fromString $ "}" ++ maybe "" (" " ++) mFieldName ++ ";"
+            ]
+          ]
+
+    goField :: StructField a -> TestInput
+    goField StructField{fieldName, fieldType} =
+        case fieldType of
+          TypeInt           -> fromString $ "int " ++ fieldName ++ ";"
+          TypeStruct struct -> goStruct (Just fieldName) struct
+
+{-------------------------------------------------------------------------------
+  'IsConcrete'
+-------------------------------------------------------------------------------}
+
+instance AST.IsConcrete (StructForest ()) where
+  toAbstractAST = fmap fst . toAbstractAST ()
+  toTestInput   = toTestInput
+
+{-------------------------------------------------------------------------------
+  Internal auxiliary
+-------------------------------------------------------------------------------}
+
+renderPath :: [Int] -> String
+renderPath = List.intercalate "_" . map show
+
+mkStructName :: [Int] -> [Char]
+mkStructName path = "s" ++ renderPath path
+
+mkFieldName :: [Int] -> String
+mkFieldName path = "f" ++ renderPath path
+
diff --git a/test/Test/Util/Shape.hs b/test/Test/Util/Shape.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Util/Shape.hs
@@ -0,0 +1,135 @@
+-- | Working with trees of specific shapes
+--
+-- Intended for qualified import.
+--
+-- > import Test.Util.Shape (Shape)
+-- > import Test.Util.Shape qualified as Shape
+module Test.Util.Shape (
+    Shape -- opaque
+    -- * Relate trees and shapes
+  , toForest
+  , toForest_
+  , fromForest
+  ) where
+
+import Control.Monad
+import Data.List qualified as List
+import Data.Tree (Forest, Tree (Node))
+import Data.Tree qualified as Tree
+import Test.QuickCheck
+
+{-------------------------------------------------------------------------------
+  Internal auxiliary: shape of a tree
+-------------------------------------------------------------------------------}
+
+-- | Tree shape
+--
+-- We refer to this as the /shape/ of a tree because although we can have
+-- annotations in the tree (of type @a@, generation and shrinking of these
+-- values is entirely independent from generation and shrinking of the
+-- shape of the tree.
+newtype Shape a = Shape (Forest a)
+
+instance Show a => Show (Shape a) where
+  show = Tree.drawTree . Node "" . map (fmap show) . toForest
+
+instance Arbitrary1 Shape where
+  liftArbitrary :: forall a. Gen a -> Gen (Shape a)
+  liftArbitrary f = sized $ \n -> do
+      maxDepth <- choose (0, 5)
+
+      let go :: Int -> Int -> Gen (Forest a)
+          go curDepth numElems | curDepth == maxDepth =
+              replicateM numElems $ Node <$> f <*> pure []
+          go curDepth numElems = do
+              partitioned <- arbitraryPartitioning maxNumChildren numElems
+              forM partitioned $ \numInPart ->
+                Node <$> f <*> go (curDepth + 1) (numInPart - 1)
+            where
+              maxNumChildren = 3
+
+      Shape <$> go 0 n
+
+  liftShrink :: forall a. (a -> [a]) -> Shape a -> [Shape a]
+  liftShrink f (Shape forest) = map Shape $ shrinkList (liftShrink f) forest
+
+{-------------------------------------------------------------------------------
+  Relate trees and shapes
+-------------------------------------------------------------------------------}
+
+toForest :: Shape a -> Forest (a, [Int])
+toForest = \(Shape forest) -> goForest [] forest
+  where
+    goForest :: [Int] -> Forest a -> Forest (a, [Int])
+    goForest path = zipWith (goTree path) [0..]
+
+    goTree :: [Int] -> Int -> Tree a -> Tree (a, [Int])
+    goTree path i (Node x xs) = Node (x, path') (goForest path' xs)
+      where
+        path' :: [Int]
+        path' = path ++ [i]
+
+toForest_ :: Shape () -> Forest [Int]
+toForest_ = map (fmap snd) . toForest
+
+fromForest :: Forest a -> Shape a
+fromForest = Shape
+
+{-------------------------------------------------------------------------------
+  Internal auxiliary
+-------------------------------------------------------------------------------}
+
+-- | Divide @n@ elements into random but non-empty buckets
+--
+-- For example, @arbitraryPartitioning 3 10@ might result in
+--
+-- > [1,3,6]
+-- > [1,4,5]
+-- > [1,8,1]
+-- > [1,8,1]
+-- > [10]
+-- > [2,1,7]
+-- > [2,8]
+-- > [7,3]
+arbitraryPartitioning :: Int -> Int -> Gen [Int]
+arbitraryPartitioning _ 0 =
+    return []
+arbitraryPartitioning 0 _ =
+    error "must have at least one partition"
+arbitraryPartitioning maxNumParts numElems = do
+    -- Don't choose more partitions than we have parts
+    numParts <- choose (1, min maxNumParts numElems)
+    offsets  <-
+      -- We only compute any offset if we have at least two partitions. Since we
+      -- cannot have more partitions than elements, this also means that we must
+      -- have at least two elements. Therefore this choice is well-defined.
+                 (replicateM (numParts - 1) $ choose (1, numElems - 1))
+      -- Duplicates would result in empty partitions.
+      `suchThat` noDups
+    return $ partitionSizes numElems offsets
+
+-- | Compute partition sizes from partition offsets
+--
+-- The resulting list reports the number of elements in each partition.
+--
+-- For example:
+--
+-- > partitionSizes 10 []      == [10]    -- single partition
+-- > partitionSizes 10 [0]     == [0,10]  -- two partitions, first empty
+-- > partitionSizes 10 [1]     == [1,9]
+-- > partitionSizes 10 [2]     == [2,8]
+-- > partitionSizes 10 [2,2]   == [2,0,8] -- second partition empty
+-- > partitionSizes 10 [2,3]   == [2,1,7]
+-- > partitionSizes 10 [2,4]   == [2,2,6]
+-- > partitionSizes 10 [2,4,9] == [2,2,5,1]
+partitionSizes :: Int -> [Int] -> [Int]
+partitionSizes numElems =
+    go 0 . List.sort
+  where
+    go :: Int -> [Int] -> [Int]
+    go prev []     = [numElems - prev]
+    go prev (o:os) = o - prev : go o os
+
+-- | Check that a list does not contain any duplicates
+noDups :: Eq a => [a] -> Bool
+noDups xs = length xs == length (List.nub xs)
diff --git a/test/Test/Version.hs b/test/Test/Version.hs
new file mode 100644
--- /dev/null
+++ b/test/Test/Version.hs
@@ -0,0 +1,203 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Test.Version (tests) where
+
+import Control.Monad
+import Data.Text (Text)
+import Test.Tasty
+import Test.Tasty.HUnit
+
+import Clang.Version
+
+{-------------------------------------------------------------------------------
+  List of tests
+-------------------------------------------------------------------------------}
+
+tests :: TestTree
+tests = testGroup "Test.Version" [
+      testCaseInfo "current"  testCurrent
+    , testCase     "examples" testExamples
+    ]
+
+{-------------------------------------------------------------------------------
+  Regression/sanity: test that we can parse specific version strings
+-------------------------------------------------------------------------------}
+
+testExamples :: Assertion
+testExamples =
+    forM_ examples $ \(str, expected) ->
+      assertEqual (show str) expected $ parseClangVersion str
+  where
+    examples :: [(Text, ClangVersion)]
+    examples = [
+          ( "Ubuntu clang version 14.0.0-1ubuntu1.1"
+          , ClangVersion (14, 0, 0)
+          )
+        , ( "Ubuntu clang version 18.1.3 (1ubuntu1)"
+          , ClangVersion (18, 1, 3)
+          )
+        , ( "Ubuntu clang version 19.1.1 (1ubuntu1~24.04.2)"
+          , ClangVersion (19, 1, 1)
+          )
+        , ( "clang version 14.0.6"
+          , ClangVersion (14, 0, 6)
+          )
+        , ( "clang version 14.0.6 (git@github.com:llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)"
+          , ClangVersion (14, 0, 6)
+          )
+        , ( "clang version 18.1.8 (https://github.com/llvm/llvm-project.git ad36915a8c42d51218eee4b53f2c0aae80eb17e9)"
+          , ClangVersion (18, 1, 8)
+          )
+        , ( "clang version 20.1.4 (https://github.com/llvm/llvm-project ec28b8f9cc7f2ac187d8a617a6d08d5e56f9120e)"
+          , ClangVersion (20, 1, 4)
+          )
+        ]
+
+
+{-------------------------------------------------------------------------------
+  Check that we can parse the version string for whatever version we're running.
+-------------------------------------------------------------------------------}
+
+testCurrent :: IO String
+testCurrent =
+    case runtimeClangVersion of
+      ClangVersionUnknown version ->
+        assertFailure $ "Unknown version: " ++ show version
+      ClangVersion version ->
+        if plausible version
+          then return $
+            show runtimeClangVersionString ++ " parsed as " ++ show version
+          else assertFailure $ "Unexpected clang version: " ++ show version
+
+-- | Check whether the parsed @clang@ version is plausible
+--
+-- As an additional sanity check on the parser (that we don't parse the wrong
+-- part of the version string as the clang version) we verify that the version
+-- number is plausible.
+plausible :: (Int, Int, Int) -> Bool
+plausible version@(major, _minor, _patch) = or [
+      version `elem` historicReleases
+
+      -- For the current versions we don't know which minor/patch to expect
+    , major `elem` [21, 22]
+    ]
+
+-- | Historic @llvm@ releases
+--
+-- See <https://releases.llvm.org/> (outdated), or
+-- https://github.com/llvm/llvm-project/releases/.
+historicReleases :: [(Int, Int, Int)]
+historicReleases = [
+      ( 21, 1, 0) -- 26 Aug 2025
+    , ( 20, 1, 8) -- 08 Jul 2025
+    , ( 20, 1, 7) -- 13 Jun 2025
+    , ( 20, 1, 6) -- 28 May 2025
+    , ( 20, 1, 5) -- 14 May 2025
+    , ( 20, 1, 4) -- 30 Apr 2025
+    , ( 20, 1, 3) -- 16 Apr 2025
+    , ( 20, 1, 2) -- 02 Apr 2025
+    , ( 20, 1, 1) -- 19 Mar 2025
+    , ( 20, 1, 0) -- 04 Mar 2025
+    , ( 19, 1, 7) -- 14 Jan 2025
+    , ( 19, 1, 1) -- 01 Oct 2024
+    , ( 19, 1, 0) -- 17 Sep 2024
+    , ( 18, 1, 8) -- 20 Jun 2024
+    , ( 18, 1, 7) -- 06 Jun 2024
+    , ( 18, 1, 6) -- 18 May 2024
+    , ( 18, 1, 5) -- 02 May 2024
+    , ( 18, 1, 4) -- 17 Apr 2024
+    , ( 18, 1, 3) -- 04 Apr 2024
+    , ( 18, 1, 2) -- 19 Mar 2024
+    , ( 18, 1, 1) -- 08 Mar 2024
+    , ( 18, 1, 0) -- 05 Mar 2024
+    , ( 17, 0, 6) -- 28 Nov 2023
+    , ( 17, 0, 5) -- 14 Nov 2023
+    , ( 17, 0, 4) -- 31 Oct 2023
+    , ( 17, 0, 3) -- 17 Oct 2023
+    , ( 17, 0, 2) -- 03 Oct 2023
+    , ( 17, 0, 1) -- 09 Sep 2023
+    , ( 16, 0, 6) -- 13 Jun 2023
+    , ( 16, 0, 5) -- 02 Jun 2023
+    , ( 16, 0, 4) -- 16 May 2023
+    , ( 16, 0, 3) -- 03 May 2023
+    , ( 16, 0, 2) -- 19 Apr 2023
+    , ( 16, 0, 1) -- 05 Apr 2023
+    , ( 16, 0, 0) -- 17 Mar 2023
+    , ( 15, 0, 7) -- 12 Jan 2023
+    , ( 15, 0, 6) -- 29 Nov 2022
+    , ( 15, 0, 5) -- 16 Nov 2022
+    , ( 15, 0, 4) -- 02 Nov 2022
+    , ( 15, 0, 3) -- 18 Oct 2022
+    , ( 15, 0, 2) -- 04 Oct 2022
+    , ( 15, 0, 1) -- 20 Sep 2022
+    , ( 15, 0, 0) -- 06 Sep 2022
+    , ( 14, 0, 6) -- 24 Jun 2022
+    , ( 14, 0, 5) -- 10 Jun 2022
+    , ( 14, 0, 4) -- 24 May 2022
+    , ( 14, 0, 3) -- 29 Apr 2022
+    , ( 14, 0, 2) -- 26 Apr 2022
+    , ( 14, 0, 1) -- 12 Apr 2022
+    , ( 14, 0, 0) -- 25 Mar 2022
+    , ( 13, 0, 1) -- 07 Feb 2022
+    , ( 13, 0, 0) -- 04 Oct 2021
+    , ( 12, 0, 1) -- 08 Jul 2021
+    , ( 12, 0, 0) -- 14 Apr 2021
+    , ( 11, 1, 0) -- 25 Feb 2021
+    , ( 11, 0, 1) -- 14 Jan 2021
+    , ( 11, 0, 0) -- 12 Oct 2020
+    , ( 10, 0, 1) -- 06 Aug 2020
+    , ( 10, 0, 0) -- 24 Mar 2020
+    , (  9, 0, 1) -- 20 Dec 2019
+    , (  9, 0, 0) -- 19 Sep 2019
+    , (  8, 0, 1) -- 19 Jul 2019
+    , (  7, 1, 0) -- 10 May 2019
+    , (  8, 0, 0) -- 20 Mar 2019
+    , (  7, 0, 1) -- 21 Dec 2018
+    , (  7, 0, 0) -- 19 Sep 2018
+    , (  6, 0, 1) -- 05 Jul 2018
+    , (  5, 0, 2) -- 16 May 2018
+    , (  6, 0, 0) -- 08 Mar 2018
+    , (  5, 0, 1) -- 21 Dec 2017
+    , (  5, 0, 0) -- 07 Sep 2017
+    , (  4, 0, 1) -- 04 Jul 2017
+    , (  4, 0, 0) -- 13 Mar 2017
+    , (  3, 9, 1) -- 23 Dec 2016
+    , (  3, 9, 0) -- 02 Sep 2016
+    , (  3, 8, 1) -- 11 Jul 2016
+    , (  3, 8, 0) -- 08 Mar 2016
+    , (  3, 7, 1) -- 05 Jan 2016
+    , (  3, 7, 0) -- 01 Sep 2015
+    , (  3, 6, 2) -- 16 Jul 2015
+    , (  3, 6, 1) -- 26 May 2015
+    , (  3, 6, 0) -- 27 Feb 2015
+    , (  3, 5, 2) -- 02 Apr 2015
+    , (  3, 5, 1) -- 20 Jan 2015
+    , (  3, 5, 0) -- 03 Sep 2014
+    , (  3, 4, 2) -- 19 Jun 2014
+    , (  3, 4, 1) -- 07 May 2014
+    , (  3, 4, 0) -- 02 Jan 2014
+    , (  3, 3, 0) -- 17 Jun 2013
+    , (  3, 2, 0) -- 20 Dec 2012
+    , (  3, 1, 0) -- 22 May 2012
+    , (  3, 0, 0) -- 01 Dec 2011
+    , (  2, 9, 0) -- 06 Apr 2011
+    , (  2, 8, 0) -- 05 Oct 2010
+    , (  2, 7, 0) -- 27 Apr 2010
+    , (  2, 6, 0) -- 23 Oct 2009
+    , (  2, 5, 0) -- 02 Mar 2009
+    , (  2, 4, 0) -- 09 Nov 2008
+    , (  2, 3, 0) -- 09 Jun 2008
+    , (  2, 2, 0) -- 11 Feb 2008
+    , (  2, 1, 0) -- 26 Sep 2007
+    , (  2, 0, 0) -- 23 May 2007
+    , (  1, 9, 0) -- 19 Nov 2006
+    , (  1, 8, 0) -- 09 Aug 2006
+    , (  1, 7, 0) -- 20 Apr 2006
+    , (  1, 6, 0) -- 08 Nov 2005
+    , (  1, 5, 0) -- 18 May 2005
+    , (  1, 4, 0) -- 09 Dec 2004
+    , (  1, 3, 0) -- 13 Aug 2004
+    , (  1, 2, 0) -- 19 Mar 2004
+    , (  1, 1, 0) -- 17 Dec 2003
+    , (  1, 0, 0) -- 24 Oct 2003
+    ]
+
diff --git a/test/test-clang-bindings.hs b/test/test-clang-bindings.hs
new file mode 100644
--- /dev/null
+++ b/test/test-clang-bindings.hs
@@ -0,0 +1,23 @@
+module Main (main) where
+
+import Test.Discover qualified as Discover
+import Test.Meta.IsConcrete qualified as IsConcrete
+import Test.Tasty
+import Test.Test.Exceptions qualified as Exceptions
+import Test.Version qualified as Version
+
+{-------------------------------------------------------------------------------
+  Top-level
+-------------------------------------------------------------------------------}
+
+main :: IO ()
+main = defaultMain $ testGroup "test-clang-bindings" [
+      Version.tests
+    , Discover.tests
+    , testGroup "Meta" [ -- Tests of the test infrastructure
+          IsConcrete.tests
+        ]
+    , testGroup "Tests" [
+          Exceptions.tests
+        ]
+    ]
