]> granicus.if.org Git - clang/commitdiff
When LIBCLANG_CODE_COMPLETION_LOGGING is set in the environment, log code-completion...
authorDouglas Gregor <dgregor@apple.com>
Mon, 26 Jul 2010 16:29:14 +0000 (16:29 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 26 Jul 2010 16:29:14 +0000 (16:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109395 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
tools/libclang/CIndexCodeCompletion.cpp

index 36fdbf74d935d873f2cd75b4e9adc1e815c6ae89..b17af4b8c8cb418ae46810957d5d49dea8dbd2f8 100644 (file)
@@ -505,6 +505,9 @@ def include_pch : Separate<"-include-pch">, MetaVarName<"<file>">,
   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>">,
index 277fadf683bc7168a3e5712fcee8c6145d04b012..2df5241d022575fb40fb77d454011838bfbf0203 100644 (file)
@@ -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 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
 #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 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
       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 @@ CXCodeCompleteResults *clang_codeComplete(CXIndex CIdx,
   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).