clang 23.0.0git
IncrementalParser.h
Go to the documentation of this file.
1//===--- IncrementalParser.h - Incremental Compilation ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the class which performs incremental code compilation.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALPARSER_H
14#define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALPARSER_H
15
16#include "llvm/ADT/StringRef.h"
17#include "llvm/IR/Module.h"
18#include "llvm/Support/Error.h"
19
20#include <list>
21#include <memory>
22
23namespace clang {
24class ASTConsumer;
26class Parser;
27class Sema;
31
32/// Provides support for incremental compilation. Keeps track of the state
33/// changes between the subsequent incremental input.
34///
36protected:
37 /// The Sema performing the incremental compilation.
39
40 /// Parser.
41 std::unique_ptr<Parser> P;
42
43 /// Consumer to process the produced top level decls. Owned by Act.
45
46 /// Counts the number of direct user input lines that have been parsed.
47 unsigned InputCount = 0;
48
49 /// The FrontendAction used during incremental parsing.
51
52 std::list<PartialTranslationUnit> &PTUs;
53
54public:
56 llvm::Error &Err, std::list<PartialTranslationUnit> &PTUs);
57 virtual ~IncrementalParser();
58
59 /// Parses incremental input by creating an in-memory file.
60 ///\returns a \c PartialTranslationUnit which holds information about the
61 /// \c TranslationUnitDecl.
62 virtual llvm::Expected<TranslationUnitDecl *> Parse(llvm::StringRef Input);
63
64 void CleanUpPTU(TranslationUnitDecl *MostRecentTU);
65
66 /// Register a PTU produced by Parse.
68 std::unique_ptr<llvm::Module> M = {});
69
70private:
71 llvm::Expected<TranslationUnitDecl *> ParseOrWrapTopLevelDecl();
72};
73} // end namespace clang
74
75#endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALPARSER_H
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition ASTConsumer.h:35
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
A custom action enabling the incremental processing functionality.
IncrementalParser(CompilerInstance &Instance, IncrementalAction *Act, llvm::Error &Err, std::list< PartialTranslationUnit > &PTUs)
IncrementalAction * Act
The FrontendAction used during incremental parsing.
std::list< PartialTranslationUnit > & PTUs
unsigned InputCount
Counts the number of direct user input lines that have been parsed.
void CleanUpPTU(TranslationUnitDecl *MostRecentTU)
PartialTranslationUnit & RegisterPTU(TranslationUnitDecl *TU, std::unique_ptr< llvm::Module > M={})
Register a PTU produced by Parse.
std::unique_ptr< Parser > P
Parser.
ASTConsumer * Consumer
Consumer to process the produced top level decls. Owned by Act.
Sema & S
The Sema performing the incremental compilation.
Parser - This implements a parser for the C family of languages.
Definition Parser.h:256
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:868
The top declaration context.
Definition Decl.h:105
The JSON file list parser is used to communicate input to InstallAPI.
@ Parse
Parse the block; this code is always used.
Definition Parser.h:137
The class keeps track of various objects created as part of processing incremental inputs.