aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2022-11-16 14:20:23 -0800
committerAkira Hatanaka <ahatanaka@apple.com>2022-12-07 15:30:19 -0800
commit3738ce05a70cf97fc73a07b158a1726f61aed28b (patch)
tree9eb6899ba3d2924b69b037af42b3ed84453a3203 /clang/lib/Frontend/CompilerInvocation.cpp
parent49e75ebd854dee1fcf5729c264f4cfadf76e952d (diff)
downloadllvm-3738ce05a70cf97fc73a07b158a1726f61aed28b.zip
llvm-3738ce05a70cf97fc73a07b158a1726f61aed28b.tar.gz
llvm-3738ce05a70cf97fc73a07b158a1726f61aed28b.tar.bz2
Add support for a backdoor driver option that enables emitting header
usage information in JSON to a file Each line in the file is a JSON object that has the name of the main source file followed by the list of system header files included directly or indirectly from that file. For example: {"source":"/tmp/foo.c", "includes":["/usr/include/stdio.h", "/usr/include/stdlib.h"]} To reduce the amount of data written to the file, only the system headers that are directly included from a non-system header file are recorded. In order to emit the header information in JSON, it is necessary to set the following environment variables: CC_PRINT_HEADERS_FORMAT=json CC_PRINT_HEADERS_FILTERING=only-direct-system The following combination is equivalent to setting CC_PRINT_HEADERS=1: CC_PRINT_HEADERS_FORMAT=textual CC_PRINT_HEADERS_FILTERING=none Differential Revision: https://reviews.llvm.org/D137996
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 5a8e921..06a8815 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2151,6 +2151,16 @@ static bool ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
Opts.ExtraDeps.emplace_back(std::string(Val), EDK_ModuleFile);
}
+ // Check for invalid combinations of header-include-format
+ // and header-include-filtering.
+ if ((Opts.HeaderIncludeFormat == HIFMT_Textual &&
+ Opts.HeaderIncludeFiltering != HIFIL_None) ||
+ (Opts.HeaderIncludeFormat == HIFMT_JSON &&
+ Opts.HeaderIncludeFiltering != HIFIL_Only_Direct_System))
+ Diags.Report(diag::err_drv_print_header_env_var_combination_cc1)
+ << Args.getLastArg(OPT_header_include_format_EQ)->getValue()
+ << Args.getLastArg(OPT_header_include_filtering_EQ)->getValue();
+
return Diags.getNumErrors() == NumErrorsBefore;
}