#pragma once #include "position.h" #include "working_files.h" #include #include #include #include #include #include #include std::vector GetRemapped(const WorkingFiles::Snapshot &snapshot); Range FromCharRange(const clang::SourceManager &SM, const clang::LangOptions &LangOpts, clang::SourceRange R, llvm::sys::fs::UniqueID *UniqueID = nullptr); Range FromTokenRange(const clang::SourceManager &SM, const clang::LangOptions &LangOpts, clang::SourceRange R, llvm::sys::fs::UniqueID *UniqueID = nullptr); template bool RunSafely(llvm::CrashRecoveryContext &CRC, Fn &&fn) { const char *env = getenv("CCLS_CRASH_RECOVERY"); if (env && strcmp(env, "0") == 0) { fn(); return true; } return CRC.RunSafely(fn); } struct ClangTranslationUnit { static std::unique_ptr Create(const std::string &filepath, const std::vector &arguments, const WorkingFiles::Snapshot &snapshot); int Reparse(llvm::CrashRecoveryContext &CRC, const WorkingFiles::Snapshot &snapshot); std::shared_ptr PCHCO; std::unique_ptr Unit; };