[C++11] Simplify a callback to use a lambda.

llvm-svn: 202897
This commit is contained in:
Richard Smith
2014-03-04 21:50:01 +00:00
parent cfcdd23339
commit 841f1c782e

View File

@@ -763,21 +763,6 @@ static InputKind getSourceInputKindFromOptions(const LangOptions &LangOpts) {
return LangOpts.CPlusPlus? IK_CXX : IK_C;
}
namespace {
struct CompileModuleMapData {
CompilerInstance &Instance;
GenerateModuleAction &CreateModuleAction;
};
}
/// \brief Helper function that executes the module-generating action under
/// a crash recovery context.
static void doCompileMapModule(void *UserData) {
CompileModuleMapData &Data
= *reinterpret_cast<CompileModuleMapData *>(UserData);
Data.Instance.ExecuteAction(Data.CreateModuleAction);
}
/// \brief Compile a module file for the given module, using the options
/// provided by the importing compiler instance.
static void compileModule(CompilerInstance &ImportingInstance,
@@ -908,10 +893,9 @@ static void compileModule(CompilerInstance &ImportingInstance,
// thread so that we get a stack large enough.
const unsigned ThreadStackSize = 8 << 20;
llvm::CrashRecoveryContext CRC;
CompileModuleMapData Data = { Instance, CreateModuleAction };
CRC.RunSafelyOnThread(&doCompileMapModule, &Data, ThreadStackSize);
CRC.RunSafelyOnThread([&]() { Instance.ExecuteAction(CreateModuleAction); },
ThreadStackSize);
// Delete the temporary module map file.
// FIXME: Even though we're executing under crash protection, it would still
// be nice to do this with RemoveFileOnSignal when we can. However, that