[all-commits] [llvm/llvm-project] 8e3230: [clang][cli] Port DiagnosticOpts to new option par...

Jan Svoboda via All-commits all-commits at lists.llvm.org
Fri Jan 8 01:45:22 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8e3230ffa3ad2994c3bbddffc3e53b3bccb2ee41
      https://github.com/llvm/llvm-project/commit/8e3230ffa3ad2994c3bbddffc3e53b3bccb2ee41
  Author: Jan Svoboda <jan_svoboda at apple.com>
  Date:   2021-01-08 (Fri, 08 Jan 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticOptions.h
    M clang/include/clang/Driver/Options.td
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/unittests/Frontend/CompilerInvocationTest.cpp
    M llvm/include/llvm/Option/OptParser.td
    M llvm/utils/TableGen/OptParserEmitter.cpp

  Log Message:
  -----------
  [clang][cli] Port DiagnosticOpts to new option parsing system

This patch introduces additional infrastructure necessary to accommodate DiagnosticOptions.

DiagnosticOptions are unique in that they are parsed by the same function in cc1 AND in the Clang driver. The call to the parsing function from the driver occurs early on in the compilation process, where no proper DiagnosticEngine exists, because the diagnostic options (passed through command line) are not known yet.

To preserve the current behavior, we need to be able to selectively parse:
* all options (for -cc1),
* only diagnostic options (for driver).

This patch achieves that in the following way:
* new MacroPrefix field is added to the Option TableGen class,
* new IsDiag TableGen mixin sets MacroPrefix to "DIAG_",
* TableGen backend serializes option records into a macro with the prefix,
* CompilerInvocation parse/generate methods define the [DIAG_]OPTION_WITH_MARSHALLING macros to handle diagnostic options separately.

Depends on D93700, D93701 & D93702.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D84673




More information about the All-commits mailing list