diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-04 21:50:01 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-04 21:50:01 +0000 |
| commit | bc308b5da782d5489b8da68ea3b03b67082812ed (patch) | |
| tree | 9c5b52c59fb04ad293f25a6cff801eecf53e2e52 /lib/Frontend/CompilerInstance.cpp | |
| parent | 05b8601701dd734048994f6f93fa9b4cac945a81 (diff) | |
| download | clang-bc308b5da782d5489b8da68ea3b03b67082812ed.tar.gz clang-bc308b5da782d5489b8da68ea3b03b67082812ed.tar.bz2 clang-bc308b5da782d5489b8da68ea3b03b67082812ed.tar.xz | |
[C++11] Simplify a callback to use a lambda.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
| -rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 4ab7f00e5a..e07eb5295d 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -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 |
