r318142 - [libclang] Allow crash recovery with LIBCLANG_NOTHREADS
Erik Verbruggen via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 14 01:34:39 PST 2017
Author: erikjv
Date: Tue Nov 14 01:34:39 2017
New Revision: 318142
URL: http://llvm.org/viewvc/llvm-project?rev=318142&view=rev
Log:
[libclang] Allow crash recovery with LIBCLANG_NOTHREADS
Enabled crash recovery for some libclang operations on a calling thread even
when LIBCLANG_NOTHREAD is specified.
Previously it would only run under crash recovery if LIBCLANG_NOTHREAD is not
set. Moved handling of LIBCLANG_NOTHREAD env variable into RunSafely from its
call sites.
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/Indexing.cpp
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=318142&r1=318141&r2=318142&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Nov 14 01:34:39 2017
@@ -3508,11 +3508,6 @@ enum CXErrorCode clang_parseTranslationU
llvm::makeArrayRef(unsaved_files, num_unsaved_files), options, out_TU);
};
- if (getenv("LIBCLANG_NOTHREADS")) {
- ParseTranslationUnitImpl();
- return result;
- }
-
llvm::CrashRecoveryContext CRC;
if (!RunSafely(CRC, ParseTranslationUnitImpl)) {
@@ -3921,8 +3916,7 @@ int clang_saveTranslationUnit(CXTranslat
result = clang_saveTranslationUnit_Impl(TU, FileName, options);
};
- if (!CXXUnit->getDiagnostics().hasUnrecoverableErrorOccurred() ||
- getenv("LIBCLANG_NOTHREADS")) {
+ if (!CXXUnit->getDiagnostics().hasUnrecoverableErrorOccurred()) {
SaveTranslationUnitImpl();
if (getenv("LIBCLANG_RESOURCE_USAGE"))
@@ -4045,11 +4039,6 @@ int clang_reparseTranslationUnit(CXTrans
TU, llvm::makeArrayRef(unsaved_files, num_unsaved_files), options);
};
- if (getenv("LIBCLANG_NOTHREADS")) {
- ReparseTranslationUnitImpl();
- return result;
- }
-
llvm::CrashRecoveryContext CRC;
if (!RunSafely(CRC, ReparseTranslationUnitImpl)) {
@@ -8164,7 +8153,7 @@ bool RunSafely(llvm::CrashRecoveryContex
unsigned Size) {
if (!Size)
Size = GetSafetyThreadStackSize();
- if (Size)
+ if (Size && !getenv("LIBCLANG_NOTHREADS"))
return CRC.RunSafelyOnThread(Fn, Size);
return CRC.RunSafely(Fn);
}
Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=318142&r1=318141&r2=318142&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Tue Nov 14 01:34:39 2017
@@ -806,11 +806,6 @@ CXCodeCompleteResults *clang_codeComplet
llvm::makeArrayRef(unsaved_files, num_unsaved_files), options);
};
- if (getenv("LIBCLANG_NOTHREADS")) {
- CodeCompleteAtImpl();
- return result;
- }
-
llvm::CrashRecoveryContext CRC;
if (!RunSafely(CRC, CodeCompleteAtImpl)) {
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=318142&r1=318141&r2=318142&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Tue Nov 14 01:34:39 2017
@@ -880,11 +880,6 @@ int clang_indexSourceFileFullArgv(
TU_options);
};
- if (getenv("LIBCLANG_NOTHREADS")) {
- IndexSourceFileImpl();
- return result;
- }
-
llvm::CrashRecoveryContext CRC;
if (!RunSafely(CRC, IndexSourceFileImpl)) {
@@ -934,11 +929,6 @@ int clang_indexTranslationUnit(CXIndexAc
index_options, TU);
};
- if (getenv("LIBCLANG_NOTHREADS")) {
- IndexTranslationUnitImpl();
- return result;
- }
-
llvm::CrashRecoveryContext CRC;
if (!RunSafely(CRC, IndexTranslationUnitImpl)) {
More information about the cfe-commits
mailing list