mirror of
https://github.com/intel/llvm.git
synced 2026-01-24 00:20:25 +08:00
Frontend: Replace -nostdinc by -nostdsysteminc (which is just system include
paths). The -nostdinc behavior is now -nostdsysteminc + -nobuiltininc. llvm-svn: 141691
This commit is contained in:
@@ -602,8 +602,8 @@ def fno_deprecated_macro : Flag<"-fno-deprecated-macro">,
|
||||
// Header Search Options
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def nostdinc : Flag<"-nostdinc">,
|
||||
HelpText<"Disable standard #include directories">;
|
||||
def nostdsysteminc : Flag<"-nostdsysteminc">,
|
||||
HelpText<"Disable standard system #include directories">;
|
||||
def nostdincxx : Flag<"-nostdinc++">,
|
||||
HelpText<"Disable standard #include directories for the C++ standard library">;
|
||||
def nobuiltininc : Flag<"-nobuiltininc">,
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
unsigned UseBuiltinIncludes : 1;
|
||||
|
||||
/// Include the system standard include search directories.
|
||||
unsigned UseStandardIncludes : 1;
|
||||
unsigned UseStandardSystemIncludes : 1;
|
||||
|
||||
/// Include the system standard C++ library include search directories.
|
||||
unsigned UseStandardCXXIncludes : 1;
|
||||
@@ -93,8 +93,8 @@ public:
|
||||
public:
|
||||
HeaderSearchOptions(StringRef _Sysroot = "/")
|
||||
: Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true),
|
||||
UseStandardIncludes(true), UseStandardCXXIncludes(true), UseLibcxx(false),
|
||||
Verbose(false) {}
|
||||
UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
|
||||
UseLibcxx(false), Verbose(false) {}
|
||||
|
||||
/// AddPath - Add the \arg Path path to the specified \arg Group list.
|
||||
void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
|
||||
|
||||
@@ -1481,9 +1481,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
}
|
||||
}
|
||||
|
||||
Args.AddLastArg(CmdArgs, options::OPT_nostdinc);
|
||||
Args.AddLastArg(CmdArgs, options::OPT_nostdincxx);
|
||||
Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc);
|
||||
// Pass options for controlling the default header search paths.
|
||||
if (Args.hasArg(options::OPT_nostdinc)) {
|
||||
CmdArgs.push_back("-nostdsysteminc");
|
||||
CmdArgs.push_back("-nobuiltininc");
|
||||
} else {
|
||||
Args.AddLastArg(CmdArgs, options::OPT_nostdincxx);
|
||||
Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc);
|
||||
}
|
||||
|
||||
// Pass the path to compiler resource files.
|
||||
CmdArgs.push_back("-resource-dir");
|
||||
|
||||
@@ -585,8 +585,8 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
|
||||
Res.push_back("-fmodule-cache-path");
|
||||
Res.push_back(Opts.ModuleCachePath);
|
||||
}
|
||||
if (!Opts.UseStandardIncludes)
|
||||
Res.push_back("-nostdinc");
|
||||
if (!Opts.UseStandardSystemIncludes)
|
||||
Res.push_back("-nostdsysteminc");
|
||||
if (!Opts.UseStandardCXXIncludes)
|
||||
Res.push_back("-nostdinc++");
|
||||
if (Opts.UseLibcxx)
|
||||
@@ -1394,7 +1394,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
|
||||
Opts.Sysroot = Args.getLastArgValue(OPT_isysroot, "/");
|
||||
Opts.Verbose = Args.hasArg(OPT_v);
|
||||
Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
|
||||
Opts.UseStandardIncludes = !Args.hasArg(OPT_nostdinc);
|
||||
Opts.UseStandardSystemIncludes = !Args.hasArg(OPT_nostdsysteminc);
|
||||
Opts.UseStandardCXXIncludes = !Args.hasArg(OPT_nostdincxx);
|
||||
if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ))
|
||||
Opts.UseLibcxx = (strcmp(A->getValue(Args), "libc++") == 0);
|
||||
|
||||
@@ -92,9 +92,9 @@ public:
|
||||
|
||||
/// AddDefaultSystemIncludePaths - Adds the default system include paths so
|
||||
/// that e.g. stdio.h is found.
|
||||
void AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||
const llvm::Triple &triple,
|
||||
const HeaderSearchOptions &HSOpts);
|
||||
void AddDefaultIncludePaths(const LangOptions &Lang,
|
||||
const llvm::Triple &triple,
|
||||
const HeaderSearchOptions &HSOpts);
|
||||
|
||||
/// Realize - Merges all search path lists into one list and send it to
|
||||
/// HeaderSearch.
|
||||
@@ -424,14 +424,16 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
|
||||
const HeaderSearchOptions &HSOpts) {
|
||||
llvm::Triple::OSType os = triple.getOS();
|
||||
|
||||
switch (os) {
|
||||
case llvm::Triple::FreeBSD:
|
||||
case llvm::Triple::NetBSD:
|
||||
break;
|
||||
default:
|
||||
// FIXME: temporary hack: hard-coded paths.
|
||||
AddPath("/usr/local/include", System, true, false, false);
|
||||
break;
|
||||
if (HSOpts.UseStandardSystemIncludes) {
|
||||
switch (os) {
|
||||
case llvm::Triple::FreeBSD:
|
||||
case llvm::Triple::NetBSD:
|
||||
break;
|
||||
default:
|
||||
// FIXME: temporary hack: hard-coded paths.
|
||||
AddPath("/usr/local/include", System, true, false, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Builtin includes use #include_next directives and should be positioned
|
||||
@@ -444,6 +446,11 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
|
||||
AddPath(P.str(), System, false, false, false, /*IgnoreSysRoot=*/ true);
|
||||
}
|
||||
|
||||
// All remaining additions are for system include directories, early exit if
|
||||
// we aren't using them.
|
||||
if (!HSOpts.UseStandardSystemIncludes)
|
||||
return;
|
||||
|
||||
// Add dirs specified via 'configure --with-c-include-dirs'.
|
||||
StringRef CIncludeDirs(C_INCLUDE_DIRS);
|
||||
if (CIncludeDirs != "") {
|
||||
@@ -932,10 +939,11 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp
|
||||
}
|
||||
}
|
||||
|
||||
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||
const llvm::Triple &triple,
|
||||
void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
|
||||
const llvm::Triple &triple,
|
||||
const HeaderSearchOptions &HSOpts) {
|
||||
if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) {
|
||||
if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes &&
|
||||
HSOpts.UseStandardSystemIncludes) {
|
||||
if (HSOpts.UseLibcxx) {
|
||||
if (triple.isOSDarwin()) {
|
||||
// On Darwin, libc++ may be installed alongside the compiler in
|
||||
@@ -953,17 +961,19 @@ void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||
}
|
||||
|
||||
AddPath("/usr/include/c++/v1", CXXSystem, true, false, false);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
AddDefaultCPlusPlusIncludePaths(triple, HSOpts);
|
||||
}
|
||||
}
|
||||
|
||||
AddDefaultCIncludePaths(triple, HSOpts);
|
||||
|
||||
// Add the default framework include paths on Darwin.
|
||||
if (triple.isOSDarwin()) {
|
||||
AddPath("/System/Library/Frameworks", System, true, false, true);
|
||||
AddPath("/Library/Frameworks", System, true, false, true);
|
||||
if (HSOpts.UseStandardSystemIncludes) {
|
||||
if (triple.isOSDarwin()) {
|
||||
AddPath("/System/Library/Frameworks", System, true, false, true);
|
||||
AddPath("/Library/Frameworks", System, true, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1138,8 +1148,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
|
||||
E.IgnoreSysRoot);
|
||||
}
|
||||
|
||||
if (HSOpts.UseStandardIncludes)
|
||||
Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts);
|
||||
Init.AddDefaultIncludePaths(Lang, Triple, HSOpts);
|
||||
|
||||
Init.Realize(Lang);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -Wconversion -nostdinc -isystem %S/Inputs -triple x86_64-apple-darwin %s -Wno-unreachable-code
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -Wconversion \
|
||||
// RUN: -nostdsysteminc -nobuiltininc -isystem %S/Inputs \
|
||||
// RUN: -triple x86_64-apple-darwin %s -Wno-unreachable-code
|
||||
|
||||
#include <conversion.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user