[libclang] Enhance logging capabilities of libclang.

-provide a "raw_ostream'ish" class to make it convenient to output logging info.
-use macros to automate a bit the logging functionality inside libclang functions
-when logging, print a stack trace if "LIBCLANG_LOGGING=2" environment is set.
-add logging to more functions.

llvm-svn: 172089
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index e3c2470..53a16ae 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -14,6 +14,7 @@
 #include "CXSourceLocation.h"
 #include "CXString.h"
 #include "CXTranslationUnit.h"
+#include "CLog.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/DeclVisitor.h"
 #include "clang/Frontend/ASTUnit.h"
@@ -968,6 +969,11 @@
                           unsigned num_unsaved_files,
                           CXTranslationUnit *out_TU,
                           unsigned TU_options) {
+  LOG_FUNC_SECTION {
+    *Log << source_filename << ": ";
+    for (int i = 0; i != num_command_line_args; ++i)
+      *Log << command_line_args[i] << " ";
+  }
 
   IndexSourceFileInfo ITUI = { idxAction, client_data, index_callbacks,
                                index_callbacks_size, index_options,
@@ -1018,6 +1024,9 @@
                                unsigned index_callbacks_size,
                                unsigned index_options,
                                CXTranslationUnit TU) {
+  LOG_FUNC_SECTION {
+    *Log << TU;
+  }
 
   IndexTranslationUnitInfo ITUI = { idxAction, client_data, index_callbacks,
                                     index_callbacks_size, index_options, TU,