add Directive.
This commit is contained in:
@@ -9,11 +9,10 @@
|
||||
#include <clang/Tooling/CompilationDatabase.h>
|
||||
#include <clang/Tooling/Syntax/Tokens.h>
|
||||
|
||||
|
||||
namespace clice {
|
||||
|
||||
using llvm::StringRef;
|
||||
|
||||
using PathRef = StringRef;
|
||||
using clang::CompilerInstance;
|
||||
using clang::CompilerInvocation;
|
||||
|
||||
|
||||
27
include/Clang/Directive.h
Normal file
27
include/Clang/Directive.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <Clang/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
struct MacroDefinition {
|
||||
std::string name;
|
||||
std::string definition;
|
||||
clang::SourceRange range;
|
||||
};
|
||||
|
||||
struct MacroExpansion {
|
||||
std::string name;
|
||||
std::string expansion;
|
||||
};
|
||||
|
||||
class Directive {
|
||||
private:
|
||||
std::string name;
|
||||
clang::SourceRange range;
|
||||
std::vector<MacroDefinition> definitions;
|
||||
std::vector<MacroExpansion> expansions;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<Directive> create(clang::SourceManager& sourceManager, clang::SourceRange range);
|
||||
};
|
||||
|
||||
} // namespace clice
|
||||
@@ -9,7 +9,6 @@ namespace clice {
|
||||
class ParsedAST {
|
||||
private:
|
||||
using Decl = clang::Decl*;
|
||||
using PathRef = llvm::StringRef;
|
||||
using TokenBuffer = clang::syntax::TokenBuffer;
|
||||
using ASTConsumer = std::unique_ptr<clang::ASTConsumer>;
|
||||
|
||||
@@ -32,8 +31,6 @@ private:
|
||||
clang::SyntaxOnlyAction action;
|
||||
CompilerInstance instance;
|
||||
|
||||
ParsedAST() = default;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<ParsedAST> build(std::string_view path, std::string_view content);
|
||||
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "Clang.h"
|
||||
#include "Directive.h"
|
||||
|
||||
namespace clice {
|
||||
|
||||
class Preamble {
|
||||
private:
|
||||
clang::PrecompiledPreamble* preamble;
|
||||
Directive directive;
|
||||
clang::PrecompiledPreamble data;
|
||||
|
||||
Preamble(clang::PrecompiledPreamble* preamble) : preamble(preamble) {}
|
||||
Preamble(clang::PrecompiledPreamble&& preamble) : data(std::move(preamble)) {}
|
||||
|
||||
public:
|
||||
Preamble() = default;
|
||||
|
||||
static Preamble
|
||||
build(std::string_view path, std::string_view content, const CompilerInvocation& invocation);
|
||||
static std::unique_ptr<Preamble>
|
||||
build(PathRef path, StringRef content, const CompilerInvocation& invocation);
|
||||
};
|
||||
|
||||
} // namespace clice
|
||||
|
||||
Reference in New Issue
Block a user