[PATCH] D31544: Add AllowReparse parameter to ASTUnit::Reparse

2017-03-31 Thread Igor Bronshteyn via Phabricator via cfe-commits
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


[PATCH] D31544: Add AllowRebuild parameter to ASTUnit::Reparse()

2017-04-04 Thread Igor Bronshteyn via Phabricator via cfe-commits
ibronstein added inline comments.



Comment at: lib/Frontend/ASTUnit.cpp:2068
+if (!AllowRebuild && !OverrideMainBuffer)
+  return false;
+  }

Can we leave ASTUnit in such state?


https://reviews.llvm.org/D31544



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits