2017-11-11 19:31:05 +00:00
|
|
|
#pragma once
|
2018-02-22 07:34:32 +00:00
|
|
|
#include "position.h"
|
2018-07-14 23:02:59 +00:00
|
|
|
#include "working_files.h"
|
2018-01-01 07:27:33 +00:00
|
|
|
|
2018-07-14 23:02:59 +00:00
|
|
|
#include <clang/Frontend/ASTUnit.h>
|
|
|
|
#include <clang/Frontend/CompilerInstance.h>
|
|
|
|
#include <llvm/Support/CrashRecoveryContext.h>
|
2017-11-11 19:31:05 +00:00
|
|
|
|
2018-05-28 00:50:02 +00:00
|
|
|
#include <memory>
|
2017-11-11 19:31:05 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2018-07-14 23:02:59 +00:00
|
|
|
#include <stdlib.h>
|
2017-11-11 19:31:05 +00:00
|
|
|
|
2018-07-14 23:02:59 +00:00
|
|
|
std::vector<clang::ASTUnit::RemappedFile>
|
|
|
|
GetRemapped(const WorkingFiles::Snapshot &snapshot);
|
2018-05-28 00:50:02 +00:00
|
|
|
|
2018-07-14 23:02:59 +00:00
|
|
|
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);
|
2018-05-28 00:50:02 +00:00
|
|
|
|
2018-07-14 23:02:59 +00:00
|
|
|
template <typename Fn>
|
|
|
|
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<ClangTranslationUnit>
|
|
|
|
Create(const std::string &filepath, const std::vector<std::string> &arguments,
|
|
|
|
const WorkingFiles::Snapshot &snapshot);
|
2018-05-28 00:50:02 +00:00
|
|
|
|
2018-07-14 23:02:59 +00:00
|
|
|
int Reparse(llvm::CrashRecoveryContext &CRC,
|
|
|
|
const WorkingFiles::Snapshot &snapshot);
|
2018-05-28 00:50:02 +00:00
|
|
|
|
2018-07-14 23:02:59 +00:00
|
|
|
std::shared_ptr<clang::PCHContainerOperations> PCHCO;
|
|
|
|
std::unique_ptr<clang::ASTUnit> Unit;
|
2018-05-28 00:50:02 +00:00
|
|
|
};
|