[cfe-commits] r165021 - in /cfe/trunk/tools: c-index-test/c-index-test.c libclang/Indexing.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Oct 2 09:10:41 PDT 2012


Author: akirtzidis
Date: Tue Oct  2 11:10:41 2012
New Revision: 165021

URL: http://llvm.org/viewvc/llvm-project?rev=165021&view=rev
Log:
[libclang] Even though we disable the preprocessing record during indexing,
make sure that it gets enabled for when a module needs to be created.

Modified:
    cfe/trunk/tools/c-index-test/c-index-test.c
    cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=165021&r1=165020&r2=165021&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Oct  2 11:10:41 2012
@@ -2552,7 +2552,8 @@
   idxAction = clang_IndexAction_create(Idx);
   result = clang_indexSourceFile(idxAction, &index_data,
                                  &IndexCB,sizeof(IndexCB), index_opts,
-                                 0, argv, argc, 0, 0, 0, 0);
+                                 0, argv, argc, 0, 0, 0,
+                                 getDefaultParsingOptions());
   if (index_data.fail_for_error)
     result = -1;
 

Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=165021&r1=165020&r2=165021&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Tue Oct  2 11:10:41 2012
@@ -192,10 +192,20 @@
                          unsigned indexOptions,
                          CXTranslationUnit cxTU)
     : IndexCtx(clientData, indexCallbacks, indexOptions, cxTU),
-      CXTU(cxTU) { }
+      CXTU(cxTU), EnablePPDetailedRecordForModules(false) { }
+
+  bool EnablePPDetailedRecordForModules;
 
   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                          StringRef InFile) {
+    // We usually disable the preprocessing record for indexing even if the
+    // original preprocessing options had it enabled. Now that the indexing
+    // Preprocessor has been created (without a preprocessing record), re-enable
+    // the option in case modules are enabled, so that the detailed record
+    // option can be propagated when the module file is generated.
+    if (CI.getLangOpts().Modules && EnablePPDetailedRecordForModules)
+      CI.getPreprocessorOpts().DetailedRecord = true;
+
     IndexCtx.setASTContext(CI.getASTContext());
     Preprocessor &PP = CI.getPreprocessor();
     PP.addPPCallbacks(new IndexPPCallbacks(PP, IndexCtx));
@@ -353,9 +363,6 @@
   // precompiled headers are involved), we disable it.
   CInvok->getLangOpts()->SpellChecking = false;
 
-  if (!requestedToGetTU)
-    CInvok->getPreprocessorOpts().DetailedRecord = false;
-
   if (index_options & CXIndexOpt_SuppressWarnings)
     CInvok->getDiagnosticOpts().IgnoreWarnings = true;
 
@@ -381,7 +388,6 @@
   bool PrecompilePreamble = false;
   bool CacheCodeCompletionResults = false;
   PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts(); 
-  PPOpts.DetailedRecord = false;
   PPOpts.AllowPCHWithCompilerErrors = true;
 
   if (requestedToGetTU) {
@@ -395,6 +401,13 @@
     }
   }
 
+  IndexAction->EnablePPDetailedRecordForModules
+    = PPOpts.DetailedRecord ||
+      (TU_options & CXTranslationUnit_DetailedPreprocessingRecord);
+
+  if (!requestedToGetTU)
+    PPOpts.DetailedRecord = false;
+
   DiagnosticErrorTrap DiagTrap(*Diags);
   bool Success = ASTUnit::LoadFromCompilerInvocationAction(CInvok.getPtr(), Diags,
                                                        IndexAction.get(),





More information about the cfe-commits mailing list