llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Bob Wilson (bob-wilson)

<details>
<summary>Changes</summary>

If you specify -header-include-format=json, the only filtering option currently 
supported is -header-include-filtering=only-direct-system. If you specify some 
other filtering option, Clang gives an error message. But, if you do not 
specify the filtering option at all, Clang crashes when producing the error 
message, since it tries to get the value of the unused option.

---
Full diff: https://github.com/llvm/llvm-project/pull/136232.diff


2 Files Affected:

- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+2-2) 
- (modified) clang/test/Preprocessor/print-header-json.c (+1) 


``````````diff
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index cfc5c069b0849..f0b487299fc6e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2440,8 +2440,8 @@ static bool 
ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
       (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();
+        << headerIncludeFormatKindToString(Opts.HeaderIncludeFormat)
+        << headerIncludeFilteringKindToString(Opts.HeaderIncludeFiltering);
 
   return Diags.getNumErrors() == NumErrorsBefore;
 }
diff --git a/clang/test/Preprocessor/print-header-json.c 
b/clang/test/Preprocessor/print-header-json.c
index d0d5e6b6f7d9e..bb41337d4c7cf 100644
--- a/clang/test/Preprocessor/print-header-json.c
+++ b/clang/test/Preprocessor/print-header-json.c
@@ -2,6 +2,7 @@
 // RUN: cat %t.txt | FileCheck %s --check-prefix=SUPPORTED
 // RUN: not %clang_cc1 -E -header-include-format=textual 
-header-include-filtering=only-direct-system -header-include-file %t.txt -I 
%S/Inputs/print-header-json -isystem %S/Inputs/print-header-json/system %s -o 
/dev/null 2>&1 | FileCheck %s --check-prefix=UNSUPPORTED0
 // RUN: not %clang_cc1 -E -header-include-format=json 
-header-include-filtering=none -header-include-file %t.txt -I 
%S/Inputs/print-header-json -isystem %S/Inputs/print-header-json/system %s -o 
/dev/null 2>&1 | FileCheck %s --check-prefix=UNSUPPORTED1
+// RUN: not %clang_cc1 -E -header-include-format=json -header-include-file 
%t.txt -I %S/Inputs/print-header-json -isystem 
%S/Inputs/print-header-json/system %s -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=UNSUPPORTED1
 // RUN: rm %t.txt
 // RUN: env CC_PRINT_HEADERS_FORMAT=json 
CC_PRINT_HEADERS_FILTERING=only-direct-system CC_PRINT_HEADERS_FILE=%t.txt 
%clang -fsyntax-only -I %S/Inputs/print-header-json -isystem 
%S/Inputs/print-header-json/system %s -o /dev/null
 // RUN: env CC_PRINT_HEADERS_FORMAT=textual 
CC_PRINT_HEADERS_FILTERING=only-direct-system CC_PRINT_HEADERS_FILE=%t.txt not 
%clang -fsyntax-only -I %S/Inputs/print-header-json -isystem 
%S/Inputs/print-header-json/system %s -o /dev/null 2>&1 | FileCheck %s 
--check-prefix=UNSUPPORTED2

``````````

</details>


https://github.com/llvm/llvm-project/pull/136232
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to