[cfe-commits] r90732 - /cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Chris Lattner sabre at nondot.org
Sun Dec 6 17:42:56 PST 2009


Author: lattner
Date: Sun Dec  6 19:42:56 2009
New Revision: 90732

URL: http://llvm.org/viewvc/llvm-project?rev=90732&view=rev
Log:
some code cleanup.

Modified:
    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=90732&r1=90731&r2=90732&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Sun Dec  6 19:42:56 2009
@@ -94,6 +94,7 @@
   bool Initialized;
   bool DisableLineMarkers;
   bool DumpDefines;
+  bool UseLineDirective;
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, llvm::raw_ostream &os,
                            bool lineMarkers, bool defines)
@@ -105,6 +106,9 @@
     EmittedMacroOnThisLine = false;
     FileType = SrcMgr::C_User;
     Initialized = false;
+         
+    // If we're in microsoft mode, use normal #line instead of line markers.
+    UseLineDirective = PP.getLangOptions().Microsoft;
   }
 
   void SetEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
@@ -141,15 +145,16 @@
     EmittedMacroOnThisLine = false;
   }
 
-  OS << '#';
-  if (PP.getLangOptions().Microsoft)
-    OS << "line";
-  OS << ' ' << LineNo << ' ' << '"';
-  
-  OS.write(&CurFilename[0], CurFilename.size());
-  OS << '"';
-
-  if (!PP.getLangOptions().Microsoft) {
+  // Emit #line directives or GNU line markers depending on what mode we're in.
+  if (UseLineDirective) {
+    OS << "#line" << ' ' << LineNo << ' ' << '"';
+    OS.write(&CurFilename[0], CurFilename.size());
+    OS << '"';
+  } else {
+    OS << '#' << ' ' << LineNo << ' ' << '"';
+    OS.write(&CurFilename[0], CurFilename.size());
+    OS << '"';
+    
     if (ExtraLen)
       OS.write(Extra, ExtraLen);
 





More information about the cfe-commits mailing list