diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-07 01:42:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-07 01:42:56 +0000 |
commit | f7449346006d6b94b14a303eb82cad52c8e75413 (patch) | |
tree | 2520b21b97a00c1ff8827ec0031f4e2ec133537d /lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | be1ea44be73facdb60edae34c2fb1a38dafcb28c (diff) |
some code cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | lib/Frontend/PrintPreprocessedOutput.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index ff8dfcd3c8..e0186abeb4 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -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); |