diff options
-rw-r--r-- | clang/docs/UsersManual.rst | 11 | ||||
-rw-r--r-- | clang/include/clang/Driver/CC1Options.td | 8 | ||||
-rw-r--r-- | clang/include/clang/Driver/Options.td | 10 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 8 | ||||
-rw-r--r-- | clang/test/Frontend/system-header-prefix.c | 3 |
5 files changed, 22 insertions, 18 deletions
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 43a8717c9be..5b761a83263 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -700,17 +700,18 @@ the pragma onwards within the same file. char b = 'ab'; // no warning -The :option:`-isystem-prefix` and :option:`-ino-system-prefix` command-line -arguments can be used to override whether subsets of an include path are -treated as system headers. When the name in a ``#include`` directive is -found within a header search path and starts with a system prefix, the +The :option:`--system-header-prefix=` and :option:`--no-system-header-prefix=` +command-line arguments can be used to override whether subsets of an include +path are treated as system headers. When the name in a ``#include`` directive +is found within a header search path and starts with a system prefix, the header is treated as a system header. The last prefix on the command-line which matches the specified header name takes precedence. For instance: .. code-block:: console - $ clang -Ifoo -isystem bar -isystem-prefix x/ -ino-system-prefix x/y/ + $ clang -Ifoo -isystem bar --system-header-prefix=x/ \ + --no-system-header-prefix=x/y/ Here, ``#include "x/a.h"`` is treated as including a system header, even if the header is found in ``foo``, and ``#include "x/y/b.h"`` is treated diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td index c6963816220..2792e20f1d7 100644 --- a/clang/include/clang/Driver/CC1Options.td +++ b/clang/include/clang/Driver/CC1Options.td @@ -508,14 +508,6 @@ def internal_externc_isystem : JoinedOrSeparate<["-"], "internal-externc-isystem "implicit extern \"C\" semantics; these are assumed to not be " "user-provided and are used to model system and standard headers' " "paths.">; -def isystem_prefix : JoinedOrSeparate<["-"], "isystem-prefix">, - MetaVarName<"<prefix>">, - HelpText<"Treat all #include paths starting with <prefix> as including a " - "system header.">; -def ino_system_prefix : JoinedOrSeparate<["-"], "ino-system-prefix">, - MetaVarName<"<prefix>">, - HelpText<"Treat all #include paths starting with <prefix> as not including a " - "system header.">; //===----------------------------------------------------------------------===// // Preprocessor Options diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 781ec2b74a5..efe98189575 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1297,6 +1297,16 @@ def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">; +def system_header_prefix : Joined<["--"], "system-header-prefix=">, + Group<clang_i_Group>, Flags<[CC1Option]>, MetaVarName<"<prefix>">, + HelpText<"Treat all #include paths starting with <prefix> as including a " + "system header.">; +def : Separate<["--"], "system-header-prefix">, Alias<system_header_prefix>; +def no_system_header_prefix : Joined<["--"], "no-system-header-prefix=">, + Group<clang_i_Group>, Flags<[CC1Option]>, MetaVarName<"<prefix>">, + HelpText<"Treat all #include paths starting with <prefix> as not including a " + "system header.">; +def : Separate<["--"], "no-system-header-prefix">, Alias<no_system_header_prefix>; def s : Flag<["-"], "s">; def target : Joined<["--"], "target=">, Flags<[DriverOption]>, HelpText<"Generate code for the given target">; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f31c8c09336..d744865159e 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1019,12 +1019,12 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { } // Add the path prefixes which are implicitly treated as being system headers. - for (arg_iterator I = Args.filtered_begin(OPT_isystem_prefix, - OPT_ino_system_prefix), + for (arg_iterator I = Args.filtered_begin(OPT_system_header_prefix, + OPT_no_system_header_prefix), E = Args.filtered_end(); I != E; ++I) - Opts.AddSystemHeaderPrefix((*I)->getValue(), - (*I)->getOption().matches(OPT_isystem_prefix)); + Opts.AddSystemHeaderPrefix( + (*I)->getValue(), (*I)->getOption().matches(OPT_system_header_prefix)); for (arg_iterator I = Args.filtered_begin(OPT_ivfsoverlay), E = Args.filtered_end(); I != E; ++I) diff --git a/clang/test/Frontend/system-header-prefix.c b/clang/test/Frontend/system-header-prefix.c index 449804579fe..55b954fc1b2 100644 --- a/clang/test/Frontend/system-header-prefix.c +++ b/clang/test/Frontend/system-header-prefix.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -isystem-prefix libs/ -ino-system-prefix libs/mylib/ -I%S/Inputs/SystemHeaderPrefix -Wundef -E %s 2>&1 | FileCheck %s +// RUN: %clang --system-header-prefix=libs/ --no-system-header-prefix=libs/mylib/ -I%S/Inputs/SystemHeaderPrefix -Wundef -E %s 2>&1 | FileCheck %s +// RUN: %clang --system-header-prefix libs/ --no-system-header-prefix libs/mylib/ -I%S/Inputs/SystemHeaderPrefix -Wundef -E %s 2>&1 | FileCheck %s #include "src/all.h" |