[cfe-commits] r109395 - in /cfe/trunk: include/clang/Driver/CC1Options.td tools/libclang/CIndexCodeCompletion.cpp

Douglas Gregor dgregor at apple.com
Mon Jul 26 09:29:14 PDT 2010


Author: dgregor
Date: Mon Jul 26 11:29:14 2010
New Revision: 109395

URL: http://llvm.org/viewvc/llvm-project?rev=109395&view=rev
Log:
When LIBCLANG_CODE_COMPLETION_LOGGING is set in the environment, log code-completion command lines to stderr

Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=109395&r1=109394&r2=109395&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jul 26 11:29:14 2010
@@ -505,6 +505,9 @@
   HelpText<"Include precompiled header file">;
 def include_pth : Separate<"-include-pth">, MetaVarName<"<file>">,
   HelpText<"Include file before parsing">;
+def use_preamble_EQ : Joined<"-use-preamble=">,
+  HelpText<"Assume that the precompiled header is a precompiled preamble "
+           "covering the first N bytes of the main file">;
 def token_cache : Separate<"-token-cache">, MetaVarName<"<path>">,
   HelpText<"Use specified token cache file">;
 def U : JoinedOrSeparate<"-U">, MetaVarName<"<macro>">,

Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=109395&r1=109394&r2=109395&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Mon Jul 26 11:29:14 2010
@@ -22,6 +22,8 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/System/Program.h"
+#include <cstdlib>
+#include <cstdio>
 
 #ifdef UDP_CODE_COMPLETION_LOGGER
 #include "clang/Basic/Version.h"
@@ -273,6 +275,8 @@
 #endif
 #endif
 
+  bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != 0;
+  
   // The indexer, which is mainly used to determine where diagnostics go.
   CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
 
@@ -348,6 +352,15 @@
       argv.push_back(arg);
     }
 
+  if (EnableLogging) {
+    std::string Log = ClangPath.str();
+    for (unsigned I = 0, N = argv.size(); I != N; ++I) {
+      Log += ' ';
+      Log += argv[I];
+    }
+    fprintf(stderr, "libclang (Code Completion): %s\n", Log.c_str());
+  }
+  
   // Add the null terminator.
   argv.push_back(NULL);
 
@@ -363,6 +376,8 @@
   llvm::sys::Path DiagnosticsFile(tmpResultsFileName);
   TemporaryFiles.push_back(DiagnosticsFile);
 
+  
+  
   // Invoke 'clang'.
   llvm::sys::Path DevNull; // leave empty, causes redirection to /dev/null
                            // on Unix or NUL (Windows).





More information about the cfe-commits mailing list