Introduce debugging/testing hook clang_enableStackTraces() into
CIndex, so that c-index-test to use it to call
lvm::sys::PrintStackTraceOnErrorSignal().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96607 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index eeb76a3..0130b72 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -507,7 +507,7 @@
  * \returns A set of display options suitable for use with \c
  * clang_displayDiagnostic().
  */
-CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions();
+CINDEX_LINKAGE unsigned clang_defaultDiagnosticDisplayOptions(void);
 
 /**
  * \brief Print a diagnostic to the given file.
@@ -1322,7 +1322,7 @@
                                           unsigned *startColumn,
                                           unsigned *endLine,
                                           unsigned *endColumn);
-
+CINDEX_LINKAGE void clang_enableStackTraces(void);
 /**
  * @}
  */
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index 128b3b6..6e07ece 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -27,6 +27,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/System/Program.h"
+#include "llvm/System/Signals.h"
 
 // Needed to define L_TMPNAM on some systems.
 #include <cstdio>
@@ -1935,6 +1936,10 @@
   *endColumn = SM.getSpellingColumnNumber(Body->getRBracLoc());
 }
 
+void clang_enableStackTraces(void) {
+  llvm::sys::PrintStackTraceOnErrorSignal();
+}
+
 } // end: extern "C"
 
 //===----------------------------------------------------------------------===//
diff --git a/tools/CIndex/CIndex.exports b/tools/CIndex/CIndex.exports
index 0b4ef21..449bb95 100644
--- a/tools/CIndex/CIndex.exports
+++ b/tools/CIndex/CIndex.exports
@@ -13,6 +13,7 @@
 _clang_disposeString
 _clang_disposeTokens
 _clang_disposeTranslationUnit
+_clang_enableStackTraces
 _clang_equalCursors
 _clang_equalLocations
 _clang_getClangVersion
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index f5492b7..c5f8431 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1009,6 +1009,7 @@
 }
 
 int main(int argc, const char **argv) {
+  clang_enableStackTraces();
   if (argc > 2 && strstr(argv[1], "-code-completion-at=") == argv[1])
     return perform_code_completion(argc, argv);
   if (argc > 2 && strstr(argv[1], "-cursor-at=") == argv[1])