forked from OSchip/llvm-project
Implement support for -nostdc++. Fixes PR6446.
llvm-svn: 99417
This commit is contained in:
parent
8e404fe769
commit
64b046fce4
|
@ -407,6 +407,8 @@ def fwritable_strings : Flag<"-fwritable-strings">,
|
||||||
|
|
||||||
def nostdinc : Flag<"-nostdinc">,
|
def nostdinc : Flag<"-nostdinc">,
|
||||||
HelpText<"Disable standard #include directories">;
|
HelpText<"Disable standard #include directories">;
|
||||||
|
def nostdincxx : Flag<"-nostdinc++">,
|
||||||
|
HelpText<"Disable standard #include directories for the C++ standard library">;
|
||||||
def nobuiltininc : Flag<"-nobuiltininc">,
|
def nobuiltininc : Flag<"-nobuiltininc">,
|
||||||
HelpText<"Disable builtin #include directories">;
|
HelpText<"Disable builtin #include directories">;
|
||||||
def F : JoinedOrSeparate<"-F">, MetaVarName<"<directory>">,
|
def F : JoinedOrSeparate<"-F">, MetaVarName<"<directory>">,
|
||||||
|
|
|
@ -470,6 +470,7 @@ def noprebind : Flag<"-noprebind">;
|
||||||
def noseglinkedit : Flag<"-noseglinkedit">;
|
def noseglinkedit : Flag<"-noseglinkedit">;
|
||||||
def nostartfiles : Flag<"-nostartfiles">;
|
def nostartfiles : Flag<"-nostartfiles">;
|
||||||
def nostdinc : Flag<"-nostdinc">;
|
def nostdinc : Flag<"-nostdinc">;
|
||||||
|
def nostdincxx : Flag<"-nostdinc++">;
|
||||||
def nostdlib : Flag<"-nostdlib">;
|
def nostdlib : Flag<"-nostdlib">;
|
||||||
def object : Flag<"-object">;
|
def object : Flag<"-object">;
|
||||||
def o : JoinedOrSeparate<"-o">, Flags<[DriverOption, RenderAsInput]>,
|
def o : JoinedOrSeparate<"-o">, Flags<[DriverOption, RenderAsInput]>,
|
||||||
|
|
|
@ -71,13 +71,17 @@ public:
|
||||||
/// Include the system standard include search directories.
|
/// Include the system standard include search directories.
|
||||||
unsigned UseStandardIncludes : 1;
|
unsigned UseStandardIncludes : 1;
|
||||||
|
|
||||||
|
/// Include the system standard C++ library include search directories.
|
||||||
|
unsigned UseStandardCXXIncludes : 1;
|
||||||
|
|
||||||
/// Whether header search information should be output as for -v.
|
/// Whether header search information should be output as for -v.
|
||||||
unsigned Verbose : 1;
|
unsigned Verbose : 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HeaderSearchOptions(llvm::StringRef _Sysroot = "/")
|
HeaderSearchOptions(llvm::StringRef _Sysroot = "/")
|
||||||
: Sysroot(_Sysroot), UseBuiltinIncludes(true),
|
: Sysroot(_Sysroot), UseBuiltinIncludes(true),
|
||||||
UseStandardIncludes(true), Verbose(false) {}
|
UseStandardIncludes(true), UseStandardCXXIncludes(true),
|
||||||
|
Verbose(false) {}
|
||||||
|
|
||||||
/// AddPath - Add the \arg Path path to the specified \arg Group list.
|
/// AddPath - Add the \arg Path path to the specified \arg Group list.
|
||||||
void AddPath(llvm::StringRef Path, frontend::IncludeDirGroup Group,
|
void AddPath(llvm::StringRef Path, frontend::IncludeDirGroup Group,
|
||||||
|
|
|
@ -948,6 +948,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
CmdArgs.push_back("-g");
|
CmdArgs.push_back("-g");
|
||||||
|
|
||||||
Args.AddLastArg(CmdArgs, options::OPT_nostdinc);
|
Args.AddLastArg(CmdArgs, options::OPT_nostdinc);
|
||||||
|
Args.AddLastArg(CmdArgs, options::OPT_nostdincxx);
|
||||||
Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc);
|
Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc);
|
||||||
|
|
||||||
// Pass the path to compiler resource files.
|
// Pass the path to compiler resource files.
|
||||||
|
@ -1706,6 +1707,7 @@ void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args,
|
||||||
if (!Args.hasArg(options::OPT_Q))
|
if (!Args.hasArg(options::OPT_Q))
|
||||||
CmdArgs.push_back("-quiet");
|
CmdArgs.push_back("-quiet");
|
||||||
Args.AddAllArgs(CmdArgs, options::OPT_nostdinc);
|
Args.AddAllArgs(CmdArgs, options::OPT_nostdinc);
|
||||||
|
Args.AddAllArgs(CmdArgs, options::OPT_nostdincxx);
|
||||||
Args.AddLastArg(CmdArgs, options::OPT_v);
|
Args.AddLastArg(CmdArgs, options::OPT_v);
|
||||||
Args.AddAllArgs(CmdArgs, options::OPT_I_Group, options::OPT_F);
|
Args.AddAllArgs(CmdArgs, options::OPT_I_Group, options::OPT_F);
|
||||||
Args.AddLastArg(CmdArgs, options::OPT_P);
|
Args.AddLastArg(CmdArgs, options::OPT_P);
|
||||||
|
|
|
@ -436,6 +436,8 @@ static void HeaderSearchOptsToArgs(const HeaderSearchOptions &Opts,
|
||||||
}
|
}
|
||||||
if (!Opts.UseStandardIncludes)
|
if (!Opts.UseStandardIncludes)
|
||||||
Res.push_back("-nostdinc");
|
Res.push_back("-nostdinc");
|
||||||
|
if (!Opts.UseStandardCXXIncludes)
|
||||||
|
Res.push_back("-nostdinc++");
|
||||||
if (Opts.Verbose)
|
if (Opts.Verbose)
|
||||||
Res.push_back("-v");
|
Res.push_back("-v");
|
||||||
}
|
}
|
||||||
|
@ -1014,6 +1016,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
|
||||||
Opts.Verbose = Args.hasArg(OPT_v);
|
Opts.Verbose = Args.hasArg(OPT_v);
|
||||||
Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
|
Opts.UseBuiltinIncludes = !Args.hasArg(OPT_nobuiltininc);
|
||||||
Opts.UseStandardIncludes = !Args.hasArg(OPT_nostdinc);
|
Opts.UseStandardIncludes = !Args.hasArg(OPT_nostdinc);
|
||||||
|
Opts.UseStandardCXXIncludes = !Args.hasArg(OPT_nostdincxx);
|
||||||
Opts.ResourceDir = getLastArgValue(Args, OPT_resource_dir);
|
Opts.ResourceDir = getLastArgValue(Args, OPT_resource_dir);
|
||||||
|
|
||||||
// Add -I... and -F... options in order.
|
// Add -I... and -F... options in order.
|
||||||
|
|
|
@ -82,7 +82,8 @@ public:
|
||||||
/// AddDefaultSystemIncludePaths - Adds the default system include paths so
|
/// AddDefaultSystemIncludePaths - Adds the default system include paths so
|
||||||
/// that e.g. stdio.h is found.
|
/// that e.g. stdio.h is found.
|
||||||
void AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
void AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||||
const llvm::Triple &triple);
|
const llvm::Triple &triple,
|
||||||
|
bool UseStandardCXXIncludes);
|
||||||
|
|
||||||
/// Realize - Merges all search path lists into one list and send it to
|
/// Realize - Merges all search path lists into one list and send it to
|
||||||
/// HeaderSearch.
|
/// HeaderSearch.
|
||||||
|
@ -594,8 +595,9 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(const llvm::Triple &tripl
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang,
|
||||||
const llvm::Triple &triple) {
|
const llvm::Triple &triple,
|
||||||
if (Lang.CPlusPlus)
|
bool UseStandardCXXIncludes) {
|
||||||
|
if (Lang.CPlusPlus && UseStandardCXXIncludes)
|
||||||
AddDefaultCPlusPlusIncludePaths(triple);
|
AddDefaultCPlusPlusIncludePaths(triple);
|
||||||
|
|
||||||
AddDefaultCIncludePaths(triple);
|
AddDefaultCIncludePaths(triple);
|
||||||
|
@ -765,7 +767,8 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HSOpts.UseStandardIncludes)
|
if (HSOpts.UseStandardIncludes)
|
||||||
Init.AddDefaultSystemIncludePaths(Lang, Triple);
|
Init.AddDefaultSystemIncludePaths(Lang, Triple,
|
||||||
|
HSOpts.UseStandardCXXIncludes);
|
||||||
|
|
||||||
Init.Realize();
|
Init.Realize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
// RUN: %clangxx -nostdinc++ %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
// CHECK: file not found
|
||||||
|
#include <vector>
|
Loading…
Reference in New Issue