]> granicus.if.org Git - clang/commitdiff
some code cleanup.
authorChris Lattner <sabre@nondot.org>
Mon, 7 Dec 2009 01:42:56 +0000 (01:42 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 7 Dec 2009 01:42:56 +0000 (01:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90732 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PrintPreprocessedOutput.cpp

index ff8dfcd3c843cb8440512ca3ab275172d656fdcd..e0186abeb49cbcdf5e74bbf1220b690df42bac99 100644 (file)
@@ -94,6 +94,7 @@ private:
   bool Initialized;
   bool DisableLineMarkers;
   bool DumpDefines;
+  bool UseLineDirective;
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, llvm::raw_ostream &os,
                            bool lineMarkers, bool defines)
@@ -105,6 +106,9 @@ public:
     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 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
     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);