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///
33class IncrementalParser {
34protected:
35 /// The Sema performing the incremental compilation.
36 Sema &S;
37
38 /// Parser.
39 std::unique_ptr<Parser> P;
40
41 /// Consumer to process the produced top level decls. Owned by Act.
42 ASTConsumer *Consumer = nullptr;
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
66

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of clang/lib/Interpreter/IncrementalParser.h