[cfe-commits] r38571 - in /cfe/cfe/trunk: Driver/clang.cpp README.txt

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:22:49 PDT 2007


Author: sabre
Date: Wed Jul 11 11:22:48 2007
New Revision: 38571

URL: http://llvm.org/viewvc/llvm-project?rev=38571&view=rev
Log:
Implement -P mode.

Modified:
    cfe/cfe/trunk/Driver/clang.cpp
    cfe/cfe/trunk/README.txt

Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=38571&r1=38570&r2=38571&view=diff

==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:22:48 2007
@@ -589,6 +589,9 @@
 // Preprocessed output mode.
 //===----------------------------------------------------------------------===//
 
+static cl::opt<bool>
+DisableLineMarkers("P", cl::desc("Disable linemarker output in -E mode"));
+
 static unsigned EModeCurLine;
 static std::string EModeCurFilename;
 static Preprocessor *EModePP;
@@ -606,6 +609,9 @@
       std::cout << "\n";
       EmodeEmittedTokensOnThisLine = false;
     }
+
+    EModeCurLine = LineNo;
+    if (DisableLineMarkers) return;
     
     std::cout << "# " << LineNo << " " << EModeCurFilename;
 
@@ -613,9 +619,7 @@
       std::cout << " 3";
     else if (EmodeFileType == DirectoryLookup::ExternCSystemHeaderDir)
       std::cout << " 3 4";
-    
     std::cout << "\n";
-    EModeCurLine = LineNo;
   } 
 }
 
@@ -634,10 +638,9 @@
   } else if (Reason == Preprocessor::SystemHeaderPragma) {
     MoveToLine(SourceMgr.getLineNumber(Loc));
     
-    // GCC emits the # directive for this directive on the line AFTER the
+    // TODO GCC emits the # directive for this directive on the line AFTER the
     // directive and emits a bunch of spaces that aren't needed.  Emulate this
     // strange behavior.
-    //std::cout << "       \n";
   }
   
   EModeCurLine = SourceMgr.getLineNumber(Loc);
@@ -649,6 +652,9 @@
     std::cout << "\n";
     EmodeEmittedTokensOnThisLine = false;
   }
+  
+  if (DisableLineMarkers) return;
+  
   std::cout << "# " << EModeCurLine << " " << EModeCurFilename;
   switch (Reason) {
   case Preprocessor::EnterFile:

Modified: cfe/cfe/trunk/README.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/README.txt?rev=38571&r1=38570&r2=38571&view=diff

==============================================================================
--- cfe/cfe/trunk/README.txt (original)
+++ cfe/cfe/trunk/README.txt Wed Jul 11 11:22:48 2007
@@ -46,7 +46,7 @@
  * #line / #file directives
  * Detection of "atomic" headers (#ifndef/#define).
  * Function-style #define & macro expansion
- * -C & -P output modes.
+ * -C output mode in -E mode.
 
 Traditional Preprocessor:
  * All.





More information about the cfe-commits mailing list