diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-06-03 22:59:17 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-06-03 22:59:17 +0000 |
commit | 6e2d36b60b401a0fd5a25f8eb98cddfd3a7b92b4 (patch) | |
tree | 852ca7da741315e7c7fa68bd08b31d81ab7bb015 /clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | |
parent | 1f8030630be6c5b75c4c2a1edf7658472ff9c0c1 (diff) | |
download | bcm5719-llvm-6e2d36b60b401a0fd5a25f8eb98cddfd3a7b92b4.tar.gz bcm5719-llvm-6e2d36b60b401a0fd5a25f8eb98cddfd3a7b92b4.zip |
Add clang source minimizer that reduces source to directives
that might affect the dependency list for a compilation
This commit introduces a dependency directives source minimizer to clang
that minimizes header and source files to the minimum necessary preprocessor
directives for evaluating includes. It reduces the source down to #define, #include,
The source minimizer works by lexing the input with a custom fast lexer that recognizes
the preprocessor directives it cares about, and emitting those directives in the minimized source.
It ignores source code, comments, and normalizes whitespace. It gives up and fails if seems
any directives that it doesn't recognize as valid (e.g. #define 0).
In addition to the source minimizer this patch adds a
-print-dependency-directives-minimized-source CC1 option that allows you to invoke the minimizer
from clang directly.
Differential Revision: https://reviews.llvm.org/D55463
llvm-svn: 362459
Diffstat (limited to 'clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp')
-rw-r--r-- | clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index da7aa7b82a3..b6a20a7bb6c 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -116,6 +116,8 @@ CreateFrontendBaseAction(CompilerInstance &CI) { case RunAnalysis: Action = "RunAnalysis"; break; #endif case RunPreprocessorOnly: return llvm::make_unique<PreprocessOnlyAction>(); + case PrintDependencyDirectivesSourceMinimizerOutput: + return llvm::make_unique<PrintDependencyDirectivesSourceMinimizerAction>(); } #if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ |