[PATCH] D31544: Add AllowReparse parameter to ASTUnit::Reparse
Igor Bronshteyn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 31 10:53:16 PDT 2017
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<PCHContainerOperations> PCHContainerOps,
- ArrayRef<RemappedFile> RemappedFiles) {
+ ArrayRef<RemappedFile> 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<llvm::MemoryBuffer> 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<PCHContainerOperations> PCHContainerOps,
- ArrayRef<RemappedFile> RemappedFiles = None);
+ ArrayRef<RemappedFile> RemappedFiles = None,
+ bool AllowRebuild = true);
/// \brief Perform code completion at the given file, line, and
/// column within this translation unit.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31544.93682.patch
Type: text/x-patch
Size: 1833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170331/0482dec4/attachment.bin>
More information about the cfe-commits
mailing list