llvm::OwningPtr<ASTUnit> AST(new ASTUnit(true));
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- ASTUnitCleanup(llvm::CrashRecoveryContextCleanup::
- create<ASTUnit>(AST.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
+ ASTUnitCleanup(AST.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<Diagnostic,
+ llvm::CrashRecoveryContextReleaseRefCleanup<Diagnostic> >
+ DiagCleanup(Diags.getPtr());
ConfigureDiags(Diags, 0, 0, *AST, CaptureDiagnostics);
llvm::OwningPtr<CompilerInstance> Clang(new CompilerInstance());
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- CICleanup(llvm::CrashRecoveryContextCleanup::
- create<CompilerInstance>(Clang.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
+ CICleanup(Clang.get());
Clang->setInvocation(&*Invocation);
OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].second;
PreprocessorOpts.PrecompiledPreambleBytes.second = false;
}
- llvm::OwningPtr<TopLevelDeclTrackerAction> Act;
- Act.reset(new TopLevelDeclTrackerAction(*this));
+ llvm::OwningPtr<TopLevelDeclTrackerAction> Act(
+ new TopLevelDeclTrackerAction(*this));
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
+ ActCleanup(Act.get());
+
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0].second,
Clang->getFrontendOpts().Inputs[0].first))
goto error;
llvm::OwningPtr<CompilerInstance> Clang(new CompilerInstance());
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- CICleanup(llvm::CrashRecoveryContextCleanup::
- create<CompilerInstance>(Clang.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
+ CICleanup(Clang.get());
Clang->setInvocation(&PreambleInvocation);
OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].second;
SimpleTimer ParsingTimer(WantTiming);
ParsingTimer.setOutput("Parsing " + getMainFileName());
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar<llvm::MemoryBuffer>
+ MemBufferCleanup(OverrideMainBuffer);
+
return Parse(OverrideMainBuffer);
}
AST->Invocation = CI;
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- ASTUnitCleanup(llvm::CrashRecoveryContextCleanup::
- create<ASTUnit>(AST.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
+ ASTUnitCleanup(AST.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<Diagnostic,
+ llvm::CrashRecoveryContextReleaseRefCleanup<Diagnostic> >
+ DiagCleanup(Diags.getPtr());
return AST->LoadFromCompilerInvocation(PrecompilePreamble)? 0 : AST.take();
}
ArgBegin);
}
- llvm::SmallVector<const char *, 16> Args;
- Args.push_back("<clang>"); // FIXME: Remove dummy argument.
- Args.insert(Args.end(), ArgBegin, ArgEnd);
+ llvm::OwningPtr<std::vector<const char *> >
+ Args(new std::vector<const char*>);
+
+ // Recover resources if we crash before exiting this function.
+ llvm::CrashRecoveryContextCleanupRegistrar<
+ std::vector<const char *> > CleanupArgs(Args.get());
+
+ Args->push_back("<clang>"); // FIXME: Remove dummy argument.
+ Args->insert(Args->end(), ArgBegin, ArgEnd);
// FIXME: Find a cleaner way to force the driver into restricted modes. We
// also want to force it to use clang.
- Args.push_back("-fsyntax-only");
+ Args->push_back("-fsyntax-only");
llvm::SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
TheDriver.setCheckInputsExist(false);
llvm::OwningPtr<driver::Compilation> C(
- TheDriver.BuildCompilation(Args.size(), Args.data()));
+ TheDriver.BuildCompilation(Args->size(), Args->data()));
// Just print the cc1 options if -### was present.
if (C->getArgs().hasArg(driver::options::OPT__HASH_HASH_HASH)) {
AST->Invocation = CI;
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- ASTUnitCleanup(llvm::CrashRecoveryContextCleanup::
- create<ASTUnit>(AST.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<ASTUnit>
+ ASTUnitCleanup(AST.get());
+ llvm::CrashRecoveryContextCleanupRegistrar<CompilerInvocation,
+ llvm::CrashRecoveryContextReleaseRefCleanup<CompilerInvocation> >
+ CICleanup(CI.getPtr());
+ llvm::CrashRecoveryContextCleanupRegistrar<Diagnostic,
+ llvm::CrashRecoveryContextReleaseRefCleanup<Diagnostic> >
+ DiagCleanup(Diags.getPtr());
return AST->LoadFromCompilerInvocation(PrecompilePreamble) ? 0 : AST.take();
}
llvm::OwningPtr<CompilerInstance> Clang(new CompilerInstance());
// Recover resources if we crash before exiting this method.
- llvm::CrashRecoveryContextCleanupRegistrar
- CICleanup(llvm::CrashRecoveryContextCleanup::
- create<CompilerInstance>(Clang.get()));
+ llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
+ CICleanup(Clang.get());
Clang->setInvocation(&*CCInvocation);
OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].second;
// Configure the diagnostics.
DiagnosticOptions DiagOpts;
- llvm::IntrusiveRefCntPtr<Diagnostic> Diags;
- Diags = CompilerInstance::createDiagnostics(DiagOpts, num_command_line_args,
- command_line_args);
+ llvm::IntrusiveRefCntPtr<Diagnostic>
+ Diags(CompilerInstance::createDiagnostics(DiagOpts, num_command_line_args,
+ command_line_args));
+
+ // Recover resources if we crash before exiting this function.
+ llvm::CrashRecoveryContextCleanupRegistrar<Diagnostic,
+ llvm::CrashRecoveryContextReleaseRefCleanup<Diagnostic> >
+ DiagCleanup(Diags.getPtr());
+
+ llvm::OwningPtr<std::vector<ASTUnit::RemappedFile> >
+ RemappedFiles(new std::vector<ASTUnit::RemappedFile>());
+
+ // Recover resources if we crash before exiting this function.
+ llvm::CrashRecoveryContextCleanupRegistrar<
+ std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
- llvm::SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
for (unsigned I = 0; I != num_unsaved_files; ++I) {
llvm::StringRef Data(unsaved_files[I].Contents, unsaved_files[I].Length);
const llvm::MemoryBuffer *Buffer
= llvm::MemoryBuffer::getMemBufferCopy(Data, unsaved_files[I].Filename);
- RemappedFiles.push_back(std::make_pair(unsaved_files[I].Filename,
- Buffer));
+ RemappedFiles->push_back(std::make_pair(unsaved_files[I].Filename,
+ Buffer));
}
- llvm::SmallVector<const char *, 16> Args;
-
+ llvm::OwningPtr<std::vector<const char *> >
+ Args(new std::vector<const char*>());
+
+ // Recover resources if we crash before exiting this method.
+ llvm::CrashRecoveryContextCleanupRegistrar<std::vector<const char*> >
+ ArgsCleanup(Args.get());
+
// Since the Clang C library is primarily used by batch tools dealing with
// (often very broken) source code, where spell-checking can have a
// significant negative impact on performance (particularly when
}
}
if (!FoundSpellCheckingArgument)
- Args.push_back("-fno-spell-checking");
+ Args->push_back("-fno-spell-checking");
- Args.insert(Args.end(), command_line_args,
- command_line_args + num_command_line_args);
+ Args->insert(Args->end(), command_line_args,
+ command_line_args + num_command_line_args);
// The 'source_filename' argument is optional. If the caller does not
// specify it then it is assumed that the source file is specified
// Put the source file after command_line_args otherwise if '-x' flag is
// present it will be unused.
if (source_filename)
- Args.push_back(source_filename);
+ Args->push_back(source_filename);
// Do we need the detailed preprocessing record?
if (options & CXTranslationUnit_DetailedPreprocessingRecord) {
- Args.push_back("-Xclang");
- Args.push_back("-detailed-preprocessing-record");
+ Args->push_back("-Xclang");
+ Args->push_back("-detailed-preprocessing-record");
}
unsigned NumErrors = Diags->getClient()->getNumErrors();
llvm::OwningPtr<ASTUnit> Unit(
- ASTUnit::LoadFromCommandLine(Args.data(), Args.data() + Args.size(),
+ ASTUnit::LoadFromCommandLine(Args->data(), Args->data() + Args->size(),
Diags,
CXXIdx->getClangResourcesPath(),
CXXIdx->getOnlyLocalDecls(),
/*CaptureDiagnostics=*/true,
- RemappedFiles.data(),
- RemappedFiles.size(),
+ RemappedFiles->data(),
+ RemappedFiles->size(),
/*RemappedFilesKeepOriginalName=*/true,
PrecompilePreamble,
CompleteTranslationUnit,
ASTUnit *CXXUnit = static_cast<ASTUnit *>(TU->TUData);
ASTUnit::ConcurrencyCheck Check(*CXXUnit);
- llvm::SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
+ llvm::OwningPtr<std::vector<ASTUnit::RemappedFile> >
+ RemappedFiles(new std::vector<ASTUnit::RemappedFile>());
+
+ // Recover resources if we crash before exiting this function.
+ llvm::CrashRecoveryContextCleanupRegistrar<
+ std::vector<ASTUnit::RemappedFile> > RemappedCleanup(RemappedFiles.get());
+
for (unsigned I = 0; I != num_unsaved_files; ++I) {
llvm::StringRef Data(unsaved_files[I].Contents, unsaved_files[I].Length);
const llvm::MemoryBuffer *Buffer
= llvm::MemoryBuffer::getMemBufferCopy(Data, unsaved_files[I].Filename);
- RemappedFiles.push_back(std::make_pair(unsaved_files[I].Filename,
- Buffer));
+ RemappedFiles->push_back(std::make_pair(unsaved_files[I].Filename,
+ Buffer));
}
- if (!CXXUnit->Reparse(RemappedFiles.data(), RemappedFiles.size()))
+ if (!CXXUnit->Reparse(RemappedFiles->data(), RemappedFiles->size()))
RTUI->result = 0;
}