aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/clang-c/Index.h44
-rw-r--r--include/clang/Frontend/ASTUnit.h15
-rw-r--r--include/clang/Frontend/PreprocessorOptions.h39
3 files changed, 82 insertions, 16 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 467a9826eb..30feb41f33 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -634,13 +634,13 @@ CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnitFromSourceFile(
CINDEX_LINKAGE CXTranslationUnit clang_createTranslationUnit(CXIndex,
const char *ast_filename);
- /**
- * \brief Flags that control the creation of translation units.
- *
- * The enumerators in this enumeration type are meant to be bitwise
- * ORed together to specify which options should be used when
- * constructing the translation unit.
- */
+/**
+ * \brief Flags that control the creation of translation units.
+ *
+ * The enumerators in this enumeration type are meant to be bitwise
+ * ORed together to specify which options should be used when
+ * constructing the translation unit.
+ */
enum CXTranslationUnit_Flags {
/**
* \brief Used to indicate that no special translation-unit options are
@@ -658,7 +658,35 @@ enum CXTranslationUnit_Flags {
* applications that require more detailed information about the
* behavior of the preprocessor.
*/
- CXTranslationUnit_DetailedPreprocessingRecord = 0x01
+ CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
+
+ /**
+ * \brief A flag that indicates that the intent of parsing the
+ * given translation unit is for live editing of the file.
+ *
+ * This flag is essentially a meta-flag that callers can use to indicate
+ * that the translation unit is being edited and, therefore, is likely to
+ * be reparsed many times. It enables an unspecified set of optimizations
+ * (e.g., the precompiled preamble) geared toward improving the performance
+ * of \c clang_reparseTranslationUnit().
+ */
+ CXTranslationUnit_Editing = 0x02,
+
+ /**
+ * \brief Used to indicate that the translation unit should be built with an
+ * implicit precompiled header for the preamble.
+ *
+ * An implicit precompiled header is used as an optimization when a
+ * particular translation unit is likely to be reparsed many times
+ * when the sources aren't changing that often. In this case, an
+ * implicit precompiled header will be built containing all of the
+ * initial includes at the top of the main file (what we refer to as
+ * the "preamble" of the file). In subsequent parses, if the
+ * preamble or the files in it have not changed, \c
+ * clang_reparseTranslationUnit() will re-use the implicit
+ * precompiled header to improve parsing performance.
+ */
+ CXTranslationUnit_PrecompiledPreamble = 0x04
};
/**
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index b7a48881ef..950da64c22 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -46,6 +46,14 @@ class TargetInfo;
using namespace idx;
+class PrecompiledPreamble {
+ llvm::sys::Path PreambleFile;
+
+public:
+ ~PrecompiledPreamble();
+
+};
+
/// \brief Utility class for loading a ASTContext from a PCH file.
///
class ASTUnit {
@@ -125,6 +133,7 @@ private:
void CleanTemporaryFiles();
bool Parse();
+ void BuildPrecompiledPreamble();
public:
class ConcurrencyCheck {
@@ -241,7 +250,8 @@ public:
static ASTUnit *LoadFromCompilerInvocation(CompilerInvocation *CI,
llvm::IntrusiveRefCntPtr<Diagnostic> Diags,
bool OnlyLocalDecls = false,
- bool CaptureDiagnostics = false);
+ bool CaptureDiagnostics = false,
+ bool PrecompilePreamble = false);
/// LoadFromCommandLine - Create an ASTUnit from a vector of command line
/// arguments, which must specify exactly one source file.
@@ -264,7 +274,8 @@ public:
bool OnlyLocalDecls = false,
RemappedFile *RemappedFiles = 0,
unsigned NumRemappedFiles = 0,
- bool CaptureDiagnostics = false);
+ bool CaptureDiagnostics = false,
+ bool PrecompilePreamble = false);
/// \brief Reparse the source files using the same command-line options that
/// were originally used to produce this translation unit.
diff --git a/include/clang/Frontend/PreprocessorOptions.h b/include/clang/Frontend/PreprocessorOptions.h
index e2c1ca25a2..05159335ad 100644
--- a/include/clang/Frontend/PreprocessorOptions.h
+++ b/include/clang/Frontend/PreprocessorOptions.h
@@ -62,21 +62,37 @@ public:
std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >
RemappedFileBuffers;
- typedef std::vector<std::pair<std::string, std::string> >::const_iterator
+ typedef std::vector<std::pair<std::string, std::string> >::iterator
remapped_file_iterator;
- remapped_file_iterator remapped_file_begin() const {
+ typedef std::vector<std::pair<std::string, std::string> >::const_iterator
+ const_remapped_file_iterator;
+ remapped_file_iterator remapped_file_begin() {
return RemappedFiles.begin();
}
- remapped_file_iterator remapped_file_end() const {
+ const_remapped_file_iterator remapped_file_begin() const {
+ return RemappedFiles.begin();
+ }
+ remapped_file_iterator remapped_file_end() {
+ return RemappedFiles.end();
+ }
+ const_remapped_file_iterator remapped_file_end() const {
return RemappedFiles.end();
}
typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >::
- const_iterator remapped_file_buffer_iterator;
- remapped_file_buffer_iterator remapped_file_buffer_begin() const {
+ iterator remapped_file_buffer_iterator;
+ typedef std::vector<std::pair<std::string, const llvm::MemoryBuffer *> >::
+ const_iterator const_remapped_file_buffer_iterator;
+ remapped_file_buffer_iterator remapped_file_buffer_begin() {
+ return RemappedFileBuffers.begin();
+ }
+ const_remapped_file_buffer_iterator remapped_file_buffer_begin() const {
return RemappedFileBuffers.begin();
}
- remapped_file_buffer_iterator remapped_file_buffer_end() const {
+ remapped_file_buffer_iterator remapped_file_buffer_end() {
+ return RemappedFileBuffers.end();
+ }
+ const_remapped_file_buffer_iterator remapped_file_buffer_end() const {
return RemappedFileBuffers.end();
}
@@ -92,9 +108,20 @@ public:
void addRemappedFile(llvm::StringRef From, llvm::StringRef To) {
RemappedFiles.push_back(std::make_pair(From, To));
}
+
+ remapped_file_iterator eraseRemappedFile(remapped_file_iterator Remapped) {
+ return RemappedFiles.erase(Remapped);
+ }
+
void addRemappedFile(llvm::StringRef From, const llvm::MemoryBuffer * To) {
RemappedFileBuffers.push_back(std::make_pair(From, To));
}
+
+ remapped_file_buffer_iterator
+ eraseRemappedFile(remapped_file_buffer_iterator Remapped) {
+ return RemappedFileBuffers.erase(Remapped);
+ }
+
void clearRemappedFiles() {
RemappedFiles.clear();
RemappedFileBuffers.clear();