/// \brief When non-NULL, this is the buffer used to store the contents of
/// the main file when it has been padded for use with the precompiled
/// preamble.
- llvm::MemoryBuffer *SavedMainFileBuffer;
+ std::unique_ptr<llvm::MemoryBuffer> SavedMainFileBuffer;
/// \brief When non-NULL, this is the buffer used to store the
/// contents of the preamble when it has been padded to build the
/// precompiled preamble.
- llvm::MemoryBuffer *PreambleBuffer;
+ std::unique_ptr<llvm::MemoryBuffer >PreambleBuffer;
/// \brief The number of warnings that occurred while parsing the preamble.
///
OwnsRemappedFileBuffers(true),
NumStoredDiagnosticsFromDriver(0),
PreambleRebuildCounter(0), SavedMainFileBuffer(nullptr),
- PreambleBuffer(nullptr), NumWarningsInPreamble(0),
+ NumWarningsInPreamble(0),
ShouldCacheCodeCompletionResults(false),
IncludeBriefCommentsInCodeCompletion(false), UserFilesAreVolatile(false),
CompletionCacheTopLevelHashValue(0),
for (const auto &RB : PPOpts.RemappedFileBuffers)
delete RB.second;
}
-
- delete SavedMainFileBuffer;
- delete PreambleBuffer;
ClearCachedCompletionResults();
/// \returns True if a failure occurred that causes the ASTUnit not to
/// contain any translation-unit information, false otherwise.
bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
- delete SavedMainFileBuffer;
- SavedMainFileBuffer = nullptr;
+ SavedMainFileBuffer.reset(nullptr);
if (!Invocation) {
delete OverrideMainBuffer;
checkAndSanitizeDiags(StoredDiagnostics, getSourceManager());
// Keep track of the override buffer;
- SavedMainFileBuffer = OverrideMainBuffer;
+ SavedMainFileBuffer.reset(OverrideMainBuffer);
}
std::unique_ptr<TopLevelDeclTrackerAction> Act(
+ NewPreamble.second.first);
PreambleEndsAtStartOfLine = NewPreamble.second.second;
- delete PreambleBuffer;
- PreambleBuffer
- = llvm::MemoryBuffer::getMemBufferCopy(
- NewPreamble.first->getBuffer().slice(0, Preamble.size()), MainFilename);
+ PreambleBuffer.reset(llvm::MemoryBuffer::getMemBufferCopy(
+ NewPreamble.first->getBuffer().slice(0, Preamble.size()), MainFilename));
// Remap the main source file to the preamble buffer.
StringRef MainFilePath = FrontendOpts.Inputs[0].getFile();
- PreprocessorOpts.addRemappedFile(MainFilePath, PreambleBuffer);
+ PreprocessorOpts.addRemappedFile(MainFilePath, PreambleBuffer.get());
// Tell the compiler invocation to generate a temporary precompiled header.
FrontendOpts.ProgramAction = frontend::GeneratePCH;