Optionally store a PreprocessingRecord in the preprocessor itself, and
tie its creation to a CC1 flag -detailed-preprocessing-record.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98963 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index c51ca7f..f20bb75 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -430,11 +430,11 @@
       return true;
 
     // Walk the preprocessing record.
-    if (CXXUnit->hasPreprocessingRecord()) {
+    if (PreprocessingRecord *PPRec
+                       = CXXUnit->getPreprocessor().getPreprocessingRecord()) {
       // FIXME: Once we have the ability to deserialize a preprocessing record,
       // do so.
-      PreprocessingRecord &PPRec = CXXUnit->getPreprocessingRecord();
-      for (PreprocessingRecord::iterator E = PPRec.begin(), EEnd = PPRec.end();
+      for (PreprocessingRecord::iterator E = PPRec->begin(),EEnd = PPRec->end();
            E != EEnd; ++E) {
         if (MacroInstantiation *MI = dyn_cast<MacroInstantiation>(*E)) {
           if (Visit(MakeMacroInstantiationCursor(MI, CXXUnit)))
@@ -1014,7 +1014,8 @@
       Args.push_back(source_filename);
     Args.insert(Args.end(), command_line_args,
                 command_line_args + num_command_line_args);
-
+    Args.push_back("-Xclang");
+    Args.push_back("-detailed-preprocessing-record");
     unsigned NumErrors = Diags->getNumErrors();
 
 #ifdef USE_CRASHTRACER
@@ -1028,8 +1029,7 @@
                                    CXXIdx->getOnlyLocalDecls(),
                                    RemappedFiles.data(),
                                    RemappedFiles.size(),
-                                   /*CaptureDiagnostics=*/true,
-                                   /*WantPreprocessingRecord=*/true));
+                                   /*CaptureDiagnostics=*/true));
 
     // FIXME: Until we have broader testing, just drop the entire AST if we
     // encountered an error.
@@ -1114,6 +1114,9 @@
   TemporaryFiles.push_back(DiagnosticsFile);
   argv.push_back("-fdiagnostics-binary");
 
+  argv.push_back("-Xclang");
+  argv.push_back("-detailed-preprocessing-record");
+
   // Add the null terminator.
   argv.push_back(NULL);