ccls/src/clang_tu.h

41 lines
1.1 KiB
C
Raw Normal View History

#pragma once
2018-02-22 07:34:32 +00:00
#include "position.h"
#include <clang-c/Index.h>
2018-05-28 00:50:02 +00:00
#include <memory>
#include <string>
#include <vector>
2018-03-31 05:05:21 +00:00
// 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;
};
2018-05-28 00:50:02 +00:00
// 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<ClangTranslationUnit> Create(
ClangIndex* index,
const std::string& filepath,
const std::vector<std::string>& arguments,
std::vector<CXUnsavedFile>& unsaved_files,
unsigned flags);
static std::unique_ptr<ClangTranslationUnit> Reparse(
std::unique_ptr<ClangTranslationUnit> tu,
std::vector<CXUnsavedFile>& unsaved);
explicit ClangTranslationUnit(CXTranslationUnit tu);
~ClangTranslationUnit();
CXTranslationUnit cx_tu;
};