clang 20.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/Support/Error.h"
18
19#include <list>
20#include <memory>
21
22namespace clang {
23class ASTConsumer;
24class CodeGenerator;
25class CompilerInstance;
26class Parser;
27class Sema;
28class TranslationUnitDecl;
29
30/// Provides support for incremental compilation. Keeps track of the state
31/// changes between the subsequent incremental input.
32///
34protected:
35 /// The Sema performing the incremental compilation.
37
38 /// Parser.
39 std::unique_ptr<Parser> P;
40
41 /// Consumer to process the produced top level decls. Owned by Act.
43
44 /// Counts the number of direct user input lines that have been parsed.
45 unsigned InputCount = 0;
46
47 // IncrementalParser();
48
49public:
50 IncrementalParser(CompilerInstance &Instance, llvm::Error &Err);
51 virtual ~IncrementalParser();
52
53 /// Parses incremental input by creating an in-memory file.
54 ///\returns a \c PartialTranslationUnit which holds information about the
55 /// \c TranslationUnitDecl.
56 virtual llvm::Expected<TranslationUnitDecl *> Parse(llvm::StringRef Input);
57
58 void CleanUpPTU(TranslationUnitDecl *MostRecentTU);
59
60private:
61 llvm::Expected<TranslationUnitDecl *> ParseOrWrapTopLevelDecl();
62};
63} // end namespace clang
64
65#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:34
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Provides support for incremental compilation.
unsigned InputCount
Counts the number of direct user input lines that have been parsed.
void CleanUpPTU(TranslationUnitDecl *MostRecentTU)
virtual llvm::Expected< TranslationUnitDecl * > Parse(llvm::StringRef Input)
Parses incremental input by creating an in-memory file.
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.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:463
The top declaration context.
Definition: Decl.h:84
The JSON file list parser is used to communicate input to InstallAPI.