[all-commits] [llvm/llvm-project] fbea5a: [Driver] Add ClangFlags::TargetSpecific to simplif...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue May 30 11:21:30 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fbea5aada14315da14c2e296831b1cb1cc1ddd61
      https://github.com/llvm/llvm-project/commit/fbea5aada14315da14c2e296831b1cb1cc1ddd61
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-05-30 (Tue, 30 May 2023)

  Changed paths:
    M clang/include/clang/Driver/Options.h
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/Driver.cpp
    M clang/lib/Driver/ToolChains/AIX.cpp
    M clang/lib/Driver/ToolChains/AIX.h
    M clang/lib/Driver/ToolChains/Arch/PPC.cpp
    M clang/lib/Driver/ToolChains/Arch/Sparc.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/CommonArgs.cpp
    M clang/test/Driver/mdefault-visibility-export-mapping.c

  Log Message:
  -----------
  [Driver] Add ClangFlags::TargetSpecific to simplify err_drv_unsupported_opt_for_target processing

clang/lib/Driver/ToolChains/Clang.cpp has a lot of fragments like the following:
```
if (const Arg *A = Args.getLastArg(...)) {
  if (Triple is xxx)
    A->render(Args, CmdArgs);
  else
    D.Diag(diag::err_drv_unsupported_opt_for_target) << ...;
}
```

The problem is more apparent with a recent surge of AIX-specific options.

Introduce the TargetSpecific flag so that we can move the target-specific
options to ToolChains/*.cpp and ToolChains/Arch/*.cpp and overload the
warn_drv_unused_argument mechanism to give an err_drv_unsupported_opt_for_target
error.

Migrate -march=/-mcpu= and some AIX-specific options to use this simplified pattern.

Reviewed By: jansvoboda11

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




More information about the All-commits mailing list