Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit f1492f9

Browse files
committed
Support -frewrite-includes as an option while preprocessing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158460 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent bae2b31 commit f1492f9

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

include/clang/Driver/CC1Options.td

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ def rewrite_test : Flag<"-rewrite-test">,
332332
HelpText<"Rewriter playground">;
333333
def rewrite_macros : Flag<"-rewrite-macros">,
334334
HelpText<"Expand macros without full preprocessing">;
335-
def frewrite_includes : Flag<"-frewrite-includes">,
336-
HelpText<"Expand includes without full preprocessing">;
337335
def migrate : Flag<"-migrate">,
338336
HelpText<"Migrate source code">;
339337
}
@@ -495,6 +493,8 @@ def token_cache : Separate<"-token-cache">, MetaVarName<"<path>">,
495493
HelpText<"Use specified token cache file">;
496494
def detailed_preprocessing_record : Flag<"-detailed-preprocessing-record">,
497495
HelpText<"include a detailed record of preprocessing actions">;
496+
def frewrite_includes : Flag<"-frewrite-includes">,
497+
HelpText<"Expand includes without full preprocessing">;
498498

499499
//===----------------------------------------------------------------------===//
500500
// OpenCL Options

include/clang/Frontend/FrontendOptions.h

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace frontend {
4343
PrintPreamble, ///< Print the "preamble" of the input file
4444
PrintPreprocessedInput, ///< -E mode.
4545
RewriteMacros, ///< Expand macros but not \#includes.
46-
RewriteIncludes, ///< Expand \#includes but not macros.
4746
RewriteObjC, ///< ObjC->C Rewriter.
4847
RewriteTest, ///< Rewriter playground
4948
RunAnalysis, ///< Run one or more source code analyses.

include/clang/Frontend/PreprocessorOutputOptions.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class PreprocessorOutputOptions {
2121
unsigned ShowLineMarkers : 1; ///< Show \#line markers.
2222
unsigned ShowMacroComments : 1; ///< Show comments, even in macros.
2323
unsigned ShowMacros : 1; ///< Print macro definitions.
24+
unsigned RewriteIncludes : 1; ///< Preprocess include directives only.
2425

2526
public:
2627
PreprocessorOutputOptions() {
@@ -29,6 +30,7 @@ class PreprocessorOutputOptions {
2930
ShowLineMarkers = 1;
3031
ShowMacroComments = 0;
3132
ShowMacros = 0;
33+
RewriteIncludes = 0;
3234
}
3335
};
3436

lib/Frontend/CompilerInvocation.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ static const char *getActionName(frontend::ActionKind Kind) {
445445
case frontend::PrintPreamble: return "-print-preamble";
446446
case frontend::PrintPreprocessedInput: return "-E";
447447
case frontend::RewriteMacros: return "-rewrite-macros";
448-
case frontend::RewriteIncludes: return "-frewrite-includes";
449448
case frontend::RewriteObjC: return "-rewrite-objc";
450449
case frontend::RewriteTest: return "-rewrite-test";
451450
case frontend::RunAnalysis: return "-analyze";
@@ -1446,8 +1445,6 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
14461445
Opts.ProgramAction = frontend::PrintPreprocessedInput; break;
14471446
case OPT_rewrite_macros:
14481447
Opts.ProgramAction = frontend::RewriteMacros; break;
1449-
case OPT_frewrite_includes:
1450-
Opts.ProgramAction = frontend::RewriteIncludes; break;
14511448
case OPT_rewrite_objc:
14521449
Opts.ProgramAction = frontend::RewriteObjC; break;
14531450
case OPT_rewrite_test:
@@ -2144,6 +2141,7 @@ static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
21442141
Opts.ShowLineMarkers = !Args.hasArg(OPT_P);
21452142
Opts.ShowMacroComments = Args.hasArg(OPT_CC);
21462143
Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
2144+
Opts.RewriteIncludes = Args.hasArg(OPT_frewrite_includes);
21472145
}
21482146

21492147
static void ParseTargetArgs(TargetOptions &Opts, ArgList &Args) {

lib/FrontendTool/ExecuteCompilerInvocation.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
7171

7272
case PrintDeclContext: return new DeclContextPrintAction();
7373
case PrintPreamble: return new PrintPreambleAction();
74-
case PrintPreprocessedInput: return new PrintPreprocessedAction();
74+
case PrintPreprocessedInput: {
75+
if (CI.getPreprocessorOutputOpts().RewriteIncludes)
76+
return new RewriteIncludesAction();
77+
return new PrintPreprocessedAction();
78+
}
79+
7580
case RewriteMacros: return new RewriteMacrosAction();
76-
case RewriteIncludes: return new RewriteIncludesAction();
7781
case RewriteObjC: return new RewriteObjCAction();
7882
case RewriteTest: return new RewriteTestAction();
7983
case RunAnalysis: return new ento::AnalysisAction();

0 commit comments

Comments
 (0)