MaskRay created this revision. MaskRay added reviewers: jansvoboda11, theuni. Herald added a project: All. MaskRay requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
With only a link action, we claim all CompileOnly_Group options (including -f*, -m*, -i*, etc). It makes sense to claim -nostdinc family options as well. We can achieve this by placing these options into IncludePath_Group, a derivative of CompileOnly_Group. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D151944 Files: clang/include/clang/Driver/Options.td clang/test/Driver/linker-opts.c Index: clang/test/Driver/linker-opts.c =================================================================== --- clang/test/Driver/linker-opts.c +++ clang/test/Driver/linker-opts.c @@ -15,7 +15,7 @@ // // Make sure that we don't warn on unused compiler arguments. // RUN: %clang -Xclang -I. -x c %s -c -o %t/tmp.o -// RUN: %clang -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s --check-prefix=NO-UNUSED +// RUN: %clang -I. -ibuiltininc -nostdinc -nostdinc++ -nostdlibinc -nogpuinc -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s --check-prefix=NO-UNUSED // NO-UNUSED-NOT: warning:{{.*}}unused // // Make sure that we do warn in other cases. Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -3391,7 +3391,7 @@ def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option, FlangOption]>, HelpText<"Display available options">, MarshallingInfoFlag<FrontendOpts<"ShowHelp">>; -def ibuiltininc : Flag<["-"], "ibuiltininc">, +def ibuiltininc : Flag<["-"], "ibuiltininc">, Group<clang_i_Group>, HelpText<"Enable builtin #include directories even when -nostdinc is used " "before or after -ibuiltininc. " "Using -nobuiltininc after the option disables it">; @@ -4197,9 +4197,10 @@ def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>, HelpText<"Disable builtin #include directories">, MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseBuiltinIncludes">>; -def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for CUDA/HIP and" +def nogpuinc : Flag<["-"], "nogpuinc">, Group<IncludePath_Group>, + HelpText<"Do not add include paths for CUDA/HIP and" " do not include the default CUDA/HIP wrapper headers">; -def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, +def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, Group<IncludePath_Group>, HelpText<"Do not include the default HIP wrapper headers and include paths">; def : Flag<["-"], "nocudainc">, Alias<nogpuinc>; def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">>, @@ -4216,9 +4217,9 @@ def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; def nostartfiles : Flag<["-"], "nostartfiles">, Group<Link_Group>; -def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>; -def nostdlibinc : Flag<["-"], "nostdlibinc">; -def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>, +def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>, Group<IncludePath_Group>; +def nostdlibinc : Flag<["-"], "nostdlibinc">, Group<IncludePath_Group>; +def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>, Group<IncludePath_Group>, HelpText<"Disable standard #include directories for the C++ standard library">, MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseStandardCXXIncludes">>; def nostdlib : Flag<["-"], "nostdlib">, Group<Link_Group>;
Index: clang/test/Driver/linker-opts.c =================================================================== --- clang/test/Driver/linker-opts.c +++ clang/test/Driver/linker-opts.c @@ -15,7 +15,7 @@ // // Make sure that we don't warn on unused compiler arguments. // RUN: %clang -Xclang -I. -x c %s -c -o %t/tmp.o -// RUN: %clang -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s --check-prefix=NO-UNUSED +// RUN: %clang -I. -ibuiltininc -nostdinc -nostdinc++ -nostdlibinc -nogpuinc -Xclang -I. %t/tmp.o -o %t/tmp -### 2>&1 | FileCheck %s --check-prefix=NO-UNUSED // NO-UNUSED-NOT: warning:{{.*}}unused // // Make sure that we do warn in other cases. Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -3391,7 +3391,7 @@ def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option, FlangOption]>, HelpText<"Display available options">, MarshallingInfoFlag<FrontendOpts<"ShowHelp">>; -def ibuiltininc : Flag<["-"], "ibuiltininc">, +def ibuiltininc : Flag<["-"], "ibuiltininc">, Group<clang_i_Group>, HelpText<"Enable builtin #include directories even when -nostdinc is used " "before or after -ibuiltininc. " "Using -nobuiltininc after the option disables it">; @@ -4197,9 +4197,10 @@ def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>, HelpText<"Disable builtin #include directories">, MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseBuiltinIncludes">>; -def nogpuinc : Flag<["-"], "nogpuinc">, HelpText<"Do not add include paths for CUDA/HIP and" +def nogpuinc : Flag<["-"], "nogpuinc">, Group<IncludePath_Group>, + HelpText<"Do not add include paths for CUDA/HIP and" " do not include the default CUDA/HIP wrapper headers">; -def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, +def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, Group<IncludePath_Group>, HelpText<"Do not include the default HIP wrapper headers and include paths">; def : Flag<["-"], "nocudainc">, Alias<nogpuinc>; def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">>, @@ -4216,9 +4217,9 @@ def noprofilelib : Flag<["-"], "noprofilelib">; def noseglinkedit : Flag<["-"], "noseglinkedit">; def nostartfiles : Flag<["-"], "nostartfiles">, Group<Link_Group>; -def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>; -def nostdlibinc : Flag<["-"], "nostdlibinc">; -def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>, +def nostdinc : Flag<["-"], "nostdinc">, Flags<[CoreOption]>, Group<IncludePath_Group>; +def nostdlibinc : Flag<["-"], "nostdlibinc">, Group<IncludePath_Group>; +def nostdincxx : Flag<["-"], "nostdinc++">, Flags<[CC1Option]>, Group<IncludePath_Group>, HelpText<"Disable standard #include directories for the C++ standard library">, MarshallingInfoNegativeFlag<HeaderSearchOpts<"UseStandardCXXIncludes">>; def nostdlib : Flag<["-"], "nostdlib">, Group<Link_Group>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits