ibronstein created this revision.
ibronstein added a project: clang-c.
An idea behind the commit is to have an option (AllowReparse = false) in
ASTUnit::Reparse() which will disallow rebuilding the precompiled preamble.
https://reviews.llvm.org/D31544
Files:
include/clang/Frontend/ASTUnit.h
lib/Frontend/ASTUnit.cpp
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -2037,7 +2037,8 @@
}
bool ASTUnit::Reparse(std::shared_ptr PCHContainerOps,
- ArrayRef RemappedFiles) {
+ ArrayRef RemappedFiles,
+ bool AllowRebuild) {
if (!Invocation)
return true;
@@ -2060,9 +2061,12 @@
// If we have a preamble file lying around, or if we might try to
// build a precompiled preamble, do so now.
std::unique_ptr OverrideMainBuffer;
- if (!getPreambleFile(this).empty() || PreambleRebuildCounter > 0)
+ if (!getPreambleFile(this).empty() || PreambleRebuildCounter > 0) {
OverrideMainBuffer =
-getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation);
+getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation,
AllowRebuild);
+if (!AllowRebuild && !OverrideMainBuffer)
+ return false;
+ }
// Clear out the diagnostics state.
FileMgr.reset();
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -856,7 +856,8 @@
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool Reparse(std::shared_ptr PCHContainerOps,
- ArrayRef RemappedFiles = None);
+ ArrayRef RemappedFiles = None,
+ bool AllowRebuild = true);
/// \brief Perform code completion at the given file, line, and
/// column within this translation unit.
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -2037,7 +2037,8 @@
}
bool ASTUnit::Reparse(std::shared_ptr PCHContainerOps,
- ArrayRef RemappedFiles) {
+ ArrayRef RemappedFiles,
+ bool AllowRebuild) {
if (!Invocation)
return true;
@@ -2060,9 +2061,12 @@
// If we have a preamble file lying around, or if we might try to
// build a precompiled preamble, do so now.
std::unique_ptr OverrideMainBuffer;
- if (!getPreambleFile(this).empty() || PreambleRebuildCounter > 0)
+ if (!getPreambleFile(this).empty() || PreambleRebuildCounter > 0) {
OverrideMainBuffer =
-getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation);
+getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation, AllowRebuild);
+if (!AllowRebuild && !OverrideMainBuffer)
+ return false;
+ }
// Clear out the diagnostics state.
FileMgr.reset();
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -856,7 +856,8 @@
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool Reparse(std::shared_ptr PCHContainerOps,
- ArrayRef RemappedFiles = None);
+ ArrayRef RemappedFiles = None,
+ bool AllowRebuild = true);
/// \brief Perform code completion at the given file, line, and
/// column within this translation unit.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits