summaryrefslogtreecommitdiff
path: root/lib/Frontend/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-02-26 00:17:25 +0000
committerReid Kleckner <reid@kleckner.net>2015-02-26 00:17:25 +0000
commit91a68a7abe24a6925ea1f90105694c08917e21c8 (patch)
tree51d68cb5e3d7c91b917b2e6e2f656b2e42377750 /lib/Frontend/PrintPreprocessedOutput.cpp
parent2f65d8ce60ce6ab201aa10bfbbd8c2a64c78fdf7 (diff)
downloadclang-91a68a7abe24a6925ea1f90105694c08917e21c8.tar.gz
Add -fuse-line-directive flag to control usage of #line with -E
Currently -fms-extensions controls this behavior, which doesn't make much sense. It means we can't identify what is and isn't a system header when compiling our own preprocessed output, because #line doesn't represent this information. If someone is feeding Clang's preprocessed output to another compiler, they can use this flag. Fixes PR20553. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D5217 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230587 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r--lib/Frontend/PrintPreprocessedOutput.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp
index 7c1d9a5688..6507f8e4b6 100644
--- a/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -94,14 +94,14 @@ private:
bool Initialized;
bool DisableLineMarkers;
bool DumpDefines;
- bool UseLineDirective;
+ bool UseLineDirectives;
bool IsFirstFileEntered;
public:
- PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os,
- bool lineMarkers, bool defines)
- : PP(pp), SM(PP.getSourceManager()),
- ConcatInfo(PP), OS(os), DisableLineMarkers(lineMarkers),
- DumpDefines(defines) {
+ PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
+ bool defines, bool UseLineDirectives)
+ : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
+ DisableLineMarkers(lineMarkers), DumpDefines(defines),
+ UseLineDirectives(UseLineDirectives) {
CurLine = 0;
CurFilename += "<uninit>";
EmittedTokensOnThisLine = false;
@@ -109,9 +109,6 @@ public:
FileType = SrcMgr::C_User;
Initialized = false;
IsFirstFileEntered = false;
-
- // If we're in microsoft mode, use normal #line instead of line markers.
- UseLineDirective = PP.getLangOpts().MicrosoftExt;
}
void setEmittedTokensOnThisLine() { EmittedTokensOnThisLine = true; }
@@ -183,7 +180,7 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
startNewLineIfNeeded(/*ShouldUpdateCurrentLine=*/false);
// Emit #line directives or GNU line markers depending on what mode we're in.
- if (UseLineDirective) {
+ if (UseLineDirectives) {
OS << "#line" << ' ' << LineNo << ' ' << '"';
OS.write_escaped(CurFilename);
OS << '"';
@@ -719,9 +716,8 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
// to -C or -CC.
PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments);
- PrintPPOutputPPCallbacks *Callbacks =
- new PrintPPOutputPPCallbacks(PP, *OS, !Opts.ShowLineMarkers,
- Opts.ShowMacros);
+ PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks(
+ PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros, Opts.UseLineDirectives);
PP.AddPragmaHandler(new UnknownPragmaHandler("#pragma", Callbacks));
PP.AddPragmaHandler("GCC", new UnknownPragmaHandler("#pragma GCC",Callbacks));
PP.AddPragmaHandler("clang",