From: Bruno Cardoso Lopes Date: Fri, 28 Oct 2016 17:02:10 +0000 (+0000) Subject: Revert "[Preprocessor] Support for '-dI' flag" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b380aaeb15b3f62ba5f936dd541ee5eb8bfd484;p=clang Revert "[Preprocessor] Support for '-dI' flag" This reverts r285411. Tests failing on http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/141 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285416 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 602560ee0c..b74897c756 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -429,8 +429,6 @@ def fno_cuda_approx_transcendentals : Flag<["-"], "fno-cuda-approx-transcendenta def dA : Flag<["-"], "dA">, Group; def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>, HelpText<"Print macro definitions in -E mode in addition to normal output">; -def dI : Flag<["-"], "dI">, Group, Flags<[CC1Option]>, - HelpText<"Print include directives in -E mode in addition to normal output">; def dM : Flag<["-"], "dM">, Group, Flags<[CC1Option]>, HelpText<"Print macro definitions in -E mode instead of normal output">; def dead__strip : Flag<["-"], "dead_strip">; diff --git a/include/clang/Frontend/PreprocessorOutputOptions.h b/include/clang/Frontend/PreprocessorOutputOptions.h index 3261b66538..f86c49039e 100644 --- a/include/clang/Frontend/PreprocessorOutputOptions.h +++ b/include/clang/Frontend/PreprocessorOutputOptions.h @@ -22,7 +22,6 @@ public: unsigned UseLineDirectives : 1; ///< Use \#line instead of GCC-style \# N. unsigned ShowMacroComments : 1; ///< Show comments, even in macros. unsigned ShowMacros : 1; ///< Print macro definitions. - unsigned ShowIncludeDirectives : 1; ///< Print includes, imports etc. within preprocessed output. unsigned RewriteIncludes : 1; ///< Preprocess include directives only. public: @@ -33,7 +32,6 @@ public: UseLineDirectives = 0; ShowMacroComments = 0; ShowMacros = 0; - ShowIncludeDirectives = 0; RewriteIncludes = 0; } }; diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 571327b806..8588fa3781 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -2353,7 +2353,6 @@ static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts, Opts.ShowLineMarkers = !Args.hasArg(OPT_P); Opts.ShowMacroComments = Args.hasArg(OPT_CC); Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD); - Opts.ShowIncludeDirectives = Args.hasArg(OPT_dI); Opts.RewriteIncludes = Args.hasArg(OPT_frewrite_includes); Opts.UseLineDirectives = Args.hasArg(OPT_fuse_line_directives); } diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index d48b952ef2..77b80e612f 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -93,16 +93,13 @@ private: bool Initialized; bool DisableLineMarkers; bool DumpDefines; - bool DumpIncludeDirectives; bool UseLineDirectives; bool IsFirstFileEntered; public: PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers, - bool defines, bool DumpIncludeDirectives, - bool UseLineDirectives) + bool defines, bool UseLineDirectives) : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os), DisableLineMarkers(lineMarkers), DumpDefines(defines), - DumpIncludeDirectives(DumpIncludeDirectives), UseLineDirectives(UseLineDirectives) { CurLine = 0; CurFilename += ""; @@ -323,10 +320,10 @@ void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc, StringRef SearchPath, StringRef RelativePath, const Module *Imported) { + // When preprocessing, turn implicit imports into @imports. + // FIXME: This is a stop-gap until a more comprehensive "preprocessing with + // modules" solution is introduced. if (Imported) { - // When preprocessing, turn implicit imports into @imports. - // FIXME: This is a stop-gap until a more comprehensive "preprocessing with - // modules" solution is introduced. startNewLineIfNeeded(); MoveToLine(HashLoc); if (PP.getLangOpts().ObjC2) { @@ -334,9 +331,9 @@ void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc, << " /* clang -E: implicit import for \"" << File->getName() << "\" */"; } else { - const std::string TokenText = PP.getSpelling(IncludeTok); - assert(!TokenText.empty()); - OS << "#" << TokenText << " " + // FIXME: Preseve whether this was a + // #include/#include_next/#include_macros/#import. + OS << "#include " << (IsAngled ? '<' : '"') << FileName << (IsAngled ? '>' : '"') @@ -347,20 +344,6 @@ void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc, // line immediately. EmittedTokensOnThisLine = true; startNewLineIfNeeded(); - } else { - // Not a module import; it's a more vanilla inclusion of some file using one - // of: #include, #import, #include_next, #include_macros. - if (DumpIncludeDirectives) { - startNewLineIfNeeded(); - MoveToLine(HashLoc); - const std::string TokenText = PP.getSpelling(IncludeTok); - assert(!TokenText.empty()); - OS << "#" << TokenText << " " - << (IsAngled ? '<' : '"') << FileName << (IsAngled ? '>' : '"') - << " /* clang -E -dI */"; - setEmittedDirectiveOnThisLine(); - startNewLineIfNeeded(); - } } } @@ -768,8 +751,7 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments); PrintPPOutputPPCallbacks *Callbacks = new PrintPPOutputPPCallbacks( - PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros, - Opts.ShowIncludeDirectives, Opts.UseLineDirectives); + PP, *OS, !Opts.ShowLineMarkers, Opts.ShowMacros, Opts.UseLineDirectives); // Expand macros in pragmas with -fms-extensions. The assumption is that // the majority of pragmas in such a file will be Microsoft pragmas. diff --git a/test/Preprocessor/dump_import.h b/test/Preprocessor/dump_import.h deleted file mode 100644 index fded1e52cb..0000000000 --- a/test/Preprocessor/dump_import.h +++ /dev/null @@ -1 +0,0 @@ -#define DUMP_IMPORT_TESTVAL 1 diff --git a/test/Preprocessor/dump_import.m b/test/Preprocessor/dump_import.m deleted file mode 100644 index 20424ad507..0000000000 --- a/test/Preprocessor/dump_import.m +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -E -dI %s -o - | FileCheck %s -// CHECK: {{^}}#import "dump_ - -// See also `dump_include.c` which tests other inclusion cases with `-dI`. - -#import "dump_import.h" diff --git a/test/Preprocessor/dump_include.c b/test/Preprocessor/dump_include.c deleted file mode 100644 index b98b5df7b7..0000000000 --- a/test/Preprocessor/dump_include.c +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -w -E -dI -isystem %S -imacros %S/dump_include.h %s -o - | FileCheck %s -// CHECK: {{^}}#__include_macros "/{{([^/]+/)+}}dump_ -// CHECK: {{^}}#include -#include "dump_include.h" -#include_next "dump_include.h" diff --git a/test/Preprocessor/dump_include.h b/test/Preprocessor/dump_include.h deleted file mode 100644 index 9dafaa50b5..0000000000 --- a/test/Preprocessor/dump_include.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -#define DUMP_INCLUDE_TESTVAL 1