Some clean.
This commit is contained in:
8
include/Compiler/Clang.h
Normal file
8
include/Compiler/Clang.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <clang/Lex/Preprocessor.h>
|
||||
#include <clang/AST/ASTTypeTraits.h>
|
||||
#include <clang/AST/RecursiveASTVisitor.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
#include <clang/Frontend/FrontendActions.h>
|
||||
#include <clang/Tooling/Syntax/Tokens.h>
|
||||
@@ -1,21 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <Support/ADT.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
// TODO:
|
||||
|
||||
class Preamble;
|
||||
|
||||
// std::unique_ptr<clang::CompilerInvocation> createInvocation(StringRef filename,
|
||||
// StringRef content,
|
||||
// llvm::ArrayRef<const char*> args,
|
||||
// Preamble* preamble = nullptr);
|
||||
//
|
||||
// std::unique_ptr<clang::CompilerInstance> createInstance(std::shared_ptr<clang::CompilerInvocation> invocation);
|
||||
|
||||
class Compiler {
|
||||
public:
|
||||
Compiler(llvm::StringRef filepath,
|
||||
@@ -34,7 +22,7 @@ public:
|
||||
|
||||
bool applyPCM(llvm::StringRef filepath, llvm::StringRef name);
|
||||
|
||||
/// build AST.
|
||||
/// Build AST.
|
||||
void buildAST();
|
||||
|
||||
/// Generate the PCH(PreCompiledHeader) to output path. Generally execute `clang::GeneratePCHAction`.
|
||||
@@ -45,6 +33,7 @@ public:
|
||||
/// `clang::GenerateReducedModuleInterfaceAction`.
|
||||
void generatePCM(llvm::StringRef outpath);
|
||||
|
||||
/// Run code complete in given file and location.
|
||||
void codeCompletion(llvm::StringRef filepath,
|
||||
std::uint32_t line,
|
||||
std::uint32_t column,
|
||||
@@ -54,6 +43,10 @@ public:
|
||||
return instance->getSema();
|
||||
}
|
||||
|
||||
clang::FileManager& fileMgr() {
|
||||
return instance->getFileManager();
|
||||
}
|
||||
|
||||
clang::SourceManager& srcMgr() {
|
||||
return instance->getSourceManager();
|
||||
}
|
||||
@@ -66,6 +59,10 @@ public:
|
||||
return instance->getASTContext().getTranslationUnitDecl();
|
||||
}
|
||||
|
||||
clang::syntax::TokenBuffer& tokBuf() {
|
||||
return *buffer;
|
||||
}
|
||||
|
||||
private:
|
||||
void ExecuteAction();
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <Support/ADT.h>
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice::dependencies {
|
||||
|
||||
void load(ArrayRef<StringRef> dirs);
|
||||
void load(llvm::ArrayRef<llvm::StringRef> dirs);
|
||||
|
||||
/// Record the include graph of the translation unit.
|
||||
struct IncludeGraph {};
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <clang/AST/RecursiveASTVisitor.h>
|
||||
#include <clang/Basic/Diagnostic.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
#include <clang/Frontend/FrontendActions.h>
|
||||
#include <clang/Frontend/TextDiagnosticPrinter.h>
|
||||
#include <clang/Sema/Sema.h>
|
||||
#include <clang/Tooling/CompilationDatabase.h>
|
||||
#include <clang/Tooling/Syntax/Tokens.h>
|
||||
#include <clang/Lex/PPCallbacks.h>
|
||||
#include "clang/Sema/TemplateDeduction.h"
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
class Diagnostic : public clang::DiagnosticConsumer {
|
||||
class DiagnosticCollector : public clang::DiagnosticConsumer {
|
||||
public:
|
||||
void BeginSourceFile(const clang::LangOptions& Opts, const clang::Preprocessor* PP) override;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "Diagnostic.h"
|
||||
#pragma once
|
||||
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Preamble.h"
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
@@ -11,12 +11,10 @@ struct ParsedAST {
|
||||
clang::FileManager& fileManager;
|
||||
clang::SourceManager& sourceManager;
|
||||
clang::syntax::TokenBuffer tokenBuffer;
|
||||
std::unique_ptr<Directives> directive;
|
||||
// std::unique_ptr<Directives> directive;
|
||||
std::unique_ptr<clang::FrontendAction> action;
|
||||
std::unique_ptr<clang::CompilerInstance> instance;
|
||||
|
||||
|
||||
|
||||
clang::FileID getFileID(llvm::StringRef filename) const {
|
||||
auto entry = fileManager.getFileRef(filename);
|
||||
if(!entry) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Directive.h"
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "ParsedAST.h"
|
||||
#include <clang/Sema/Lookup.h>
|
||||
#include <clang/Sema/Template.h>
|
||||
#include <stack>
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
@@ -21,6 +18,7 @@ public:
|
||||
|
||||
// TODO:
|
||||
// use a relative clear way to resolve `UnresolvedLookupExpr`.
|
||||
|
||||
private:
|
||||
clang::Sema& sema;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ParsedAST.h"
|
||||
#include <clang/AST/ASTTypeTraits.h>
|
||||
#pragma once
|
||||
|
||||
#include <Compiler/Clang.h>
|
||||
|
||||
namespace clice {
|
||||
|
||||
|
||||
@@ -19,28 +19,28 @@ struct Occurrence;
|
||||
/// [SemanticDB](https://scalameta.org/docs/semanticdb/specification.html).
|
||||
struct CSIF {
|
||||
/// The version of the CSIF format.
|
||||
StringRef version;
|
||||
llvm::StringRef version;
|
||||
/// The language of the source code, currently only supports "c" and "c++".
|
||||
StringRef language;
|
||||
llvm::StringRef language;
|
||||
/// The URI of the source file.
|
||||
StringRef uri;
|
||||
llvm::StringRef uri;
|
||||
/// The context of the source file, used to check whether need to re-index the source file.
|
||||
StringRef content;
|
||||
llvm::StringRef content;
|
||||
/// The commands used to compile the source file.
|
||||
ArrayRef<StringRef> commands;
|
||||
llvm::ArrayRef<llvm::StringRef> commands;
|
||||
|
||||
/// The symbols in the source file.
|
||||
ArrayRef<Symbol> symbols;
|
||||
llvm::ArrayRef<Symbol> symbols;
|
||||
/// The occurrences in the source file.
|
||||
ArrayRef<Occurrence> occurrences;
|
||||
llvm::ArrayRef<Occurrence> occurrences;
|
||||
/// The semantic tokens in the source file.
|
||||
ArrayRef<std::uint32_t> semanticTokens;
|
||||
llvm::ArrayRef<std::uint32_t> semanticTokens;
|
||||
|
||||
// FIXME:
|
||||
/// The diagnostics in the source file.
|
||||
// ArrayRef<Diagnostic> diagnostics;
|
||||
// llvm::ArrayRef<Diagnostic> diagnostics;
|
||||
/// The inlay hints in the source file.
|
||||
// ArrayRef<InlayHint> inlayHints;
|
||||
// llvm::ArrayRef<InlayHint> inlayHints;
|
||||
};
|
||||
|
||||
enum Role {
|
||||
@@ -69,12 +69,12 @@ struct Symbol {
|
||||
/// The ID of the symbol.
|
||||
SymbolID id;
|
||||
/// display when hover.
|
||||
StringRef document;
|
||||
llvm::StringRef document;
|
||||
|
||||
// TODO: append more useful information.
|
||||
|
||||
/// The relations of the symbol.
|
||||
ArrayRef<Relation> relations;
|
||||
llvm::ArrayRef<Relation> relations;
|
||||
};
|
||||
|
||||
struct Occurrence {
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
#include <llvm/ADT/SmallVector.h>
|
||||
#include <llvm/ADT/SmallString.h>
|
||||
|
||||
#include <llvm/ADT/StringExtras.h>
|
||||
|
||||
namespace clice {
|
||||
using llvm::ArrayRef;
|
||||
using llvm::StringRef;
|
||||
using llvm::SmallVector;
|
||||
using llvm::SmallString;
|
||||
} // namespace clice
|
||||
|
||||
Reference in New Issue
Block a user