#pragma once #include "position.h" #include #include #include #include // Simple RAII wrapper about CXIndex. // Note: building a ClangIndex instance acquires a global lock, since libclang // API does not appear to be thread-safe here. class ClangIndex { public: ClangIndex(); ClangIndex(int exclude_declarations_from_pch, int display_diagnostics); ~ClangIndex(); CXIndex cx_index; }; // RAII wrapper around CXTranslationUnit which also makes it much more // challenging to use a CXTranslationUnit instance that is not correctly // initialized. struct ClangTranslationUnit { static std::unique_ptr Create( ClangIndex* index, const std::string& filepath, const std::vector& arguments, std::vector& unsaved_files, unsigned flags); static std::unique_ptr Reparse( std::unique_ptr tu, std::vector& unsaved); explicit ClangTranslationUnit(CXTranslationUnit tu); ~ClangTranslationUnit(); CXTranslationUnit cx_tu; };