Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Lex/InitHeaderSearch.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | void AddDefaultCIncludePaths(const llvm::Triple &triple, | ||||
const HeaderSearchOptions &HSOpts); | const HeaderSearchOptions &HSOpts); | ||||
// AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when | // AddDefaultCPlusPlusIncludePaths - Add paths that should be searched when | ||||
// compiling c++. | // compiling c++. | ||||
void AddDefaultCPlusPlusIncludePaths(const LangOptions &LangOpts, | void AddDefaultCPlusPlusIncludePaths(const LangOptions &LangOpts, | ||||
const llvm::Triple &triple, | const llvm::Triple &triple, | ||||
const HeaderSearchOptions &HSOpts); | const HeaderSearchOptions &HSOpts); | ||||
/// ShouldAddDefaultIncludePaths - Returns true iff AddDefaultIncludePaths | |||||
MaskRay: Drop `ShouldAddDefaultIncludePaths - `. It is not recommended for new code.
| |||||
/// should actually do anything. If this returns false, include management | |||||
MaskRayUnsubmitted multiple spaces => one space MaskRay: multiple spaces => one space | |||||
MaskRayUnsubmitted not done. /// => /// MaskRay: not done. `/// ` => `/// ` | |||||
/// should instead be handled in the driver. | |||||
bool ShouldAddDefaultIncludePaths(const llvm::Triple &triple); | |||||
/// 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 AddDefaultIncludePaths(const LangOptions &Lang, | void AddDefaultIncludePaths(const LangOptions &Lang, | ||||
const llvm::Triple &triple, | const llvm::Triple &triple, | ||||
const HeaderSearchOptions &HSOpts); | const HeaderSearchOptions &HSOpts); | ||||
/// 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. | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base, | ||||
AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, | AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, | ||||
CXXSystem, false); | CXXSystem, false); | ||||
AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", | AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", | ||||
CXXSystem, false); | CXXSystem, false); | ||||
} | } | ||||
void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, | void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, | ||||
const HeaderSearchOptions &HSOpts) { | const HeaderSearchOptions &HSOpts) { | ||||
llvm::Triple::OSType os = triple.getOS(); | if (!ShouldAddDefaultIncludePaths(triple)) { | ||||
if (triple.isOSDarwin()) { | |||||
llvm_unreachable("Include management is handled in the driver."); | llvm_unreachable("Include management is handled in the driver."); | ||||
drop braces around simple single statements MaskRay: drop braces around simple single statements | |||||
} | } | ||||
llvm::Triple::OSType os = triple.getOS(); | |||||
if (HSOpts.UseStandardSystemIncludes) { | if (HSOpts.UseStandardSystemIncludes) { | ||||
switch (os) { | switch (os) { | ||||
case llvm::Triple::CloudABI: | case llvm::Triple::CloudABI: | ||||
case llvm::Triple::FreeBSD: | |||||
case llvm::Triple::NetBSD: | case llvm::Triple::NetBSD: | ||||
case llvm::Triple::OpenBSD: | |||||
case llvm::Triple::NaCl: | case llvm::Triple::NaCl: | ||||
case llvm::Triple::PS4: | case llvm::Triple::PS4: | ||||
case llvm::Triple::PS5: | case llvm::Triple::PS5: | ||||
case llvm::Triple::ELFIAMCU: | case llvm::Triple::ELFIAMCU: | ||||
case llvm::Triple::Fuchsia: | case llvm::Triple::Fuchsia: | ||||
break; | break; | ||||
case llvm::Triple::Win32: | case llvm::Triple::Win32: | ||||
if (triple.getEnvironment() != llvm::Triple::Cygnus) | if (triple.getEnvironment() != llvm::Triple::Cygnus) | ||||
Show All 27 Lines | if (CIncludeDirs != "") { | ||||
SmallVector<StringRef, 5> dirs; | SmallVector<StringRef, 5> dirs; | ||||
CIncludeDirs.split(dirs, ":"); | CIncludeDirs.split(dirs, ":"); | ||||
for (StringRef dir : dirs) | for (StringRef dir : dirs) | ||||
AddPath(dir, ExternCSystem, false); | AddPath(dir, ExternCSystem, false); | ||||
return; | return; | ||||
} | } | ||||
switch (os) { | switch (os) { | ||||
case llvm::Triple::Linux: | |||||
case llvm::Triple::Hurd: | |||||
case llvm::Triple::Solaris: | |||||
case llvm::Triple::OpenBSD: | |||||
llvm_unreachable("Include management is handled in the driver."); | |||||
case llvm::Triple::CloudABI: { | case llvm::Triple::CloudABI: { | ||||
// <sysroot>/<triple>/include | // <sysroot>/<triple>/include | ||||
SmallString<128> P = StringRef(HSOpts.ResourceDir); | SmallString<128> P = StringRef(HSOpts.ResourceDir); | ||||
llvm::sys::path::append(P, "../../..", triple.str(), "include"); | llvm::sys::path::append(P, "../../..", triple.str(), "include"); | ||||
AddPath(P, System, false); | AddPath(P, System, false); | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | default: | ||||
AddPath("/usr/include", ExternCSystem, false); | AddPath("/usr/include", ExternCSystem, false); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths( | void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths( | ||||
const LangOptions &LangOpts, const llvm::Triple &triple, | const LangOptions &LangOpts, const llvm::Triple &triple, | ||||
const HeaderSearchOptions &HSOpts) { | const HeaderSearchOptions &HSOpts) { | ||||
llvm::Triple::OSType os = triple.getOS(); | if (!ShouldAddDefaultIncludePaths(triple)) { | ||||
// FIXME: temporary hack: hard-coded paths. | |||||
if (triple.isOSDarwin()) { | |||||
llvm_unreachable("Include management is handled in the driver."); | llvm_unreachable("Include management is handled in the driver."); | ||||
} | } | ||||
llvm::Triple::OSType os = triple.getOS(); | |||||
move the variable immediately before switch os and move the comment before the variable? Avoid unneeded blank lines MaskRay: move the variable immediately before switch `os` and move the comment before the variable? | |||||
// FIXME: temporary hack: hard-coded paths. | |||||
switch (os) { | switch (os) { | ||||
case llvm::Triple::Linux: | |||||
case llvm::Triple::Hurd: | |||||
case llvm::Triple::Solaris: | |||||
case llvm::Triple::AIX: | |||||
llvm_unreachable("Include management is handled in the driver."); | |||||
break; | |||||
case llvm::Triple::Win32: | case llvm::Triple::Win32: | ||||
switch (triple.getEnvironment()) { | switch (triple.getEnvironment()) { | ||||
default: llvm_unreachable("Include management is handled in the driver."); | default: llvm_unreachable("Include management is handled in the driver."); | ||||
case llvm::Triple::Cygnus: | case llvm::Triple::Cygnus: | ||||
// Cygwin-1.7 | // Cygwin-1.7 | ||||
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.7.3"); | AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.7.3"); | ||||
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.5.3"); | AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.5.3"); | ||||
AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4"); | AddMinGWCPlusPlusIncludePaths("/usr/lib/gcc", "i686-pc-cygwin", "4.3.4"); | ||||
Show All 9 Lines | case llvm::Triple::Minix: | ||||
AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", | AddGnuCPlusPlusIncludePaths("/usr/gnu/include/c++/4.4.3", | ||||
"", "", "", triple); | "", "", "", triple); | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, | bool InitHeaderSearch::ShouldAddDefaultIncludePaths( | ||||
const llvm::Triple &triple, | const llvm::Triple &triple) { | ||||
const HeaderSearchOptions &HSOpts) { | llvm::Triple::OSType os = triple.getOS(); | ||||
// NB: This code path is going away. All of the logic is moving into the | |||||
// driver which has the information necessary to do target-specific | |||||
// selections of default include paths. Each target which moves there will be | |||||
// exempted from this logic here until we can delete the entire pile of code. | |||||
switch (triple.getOS()) { | |||||
default: | |||||
break; // Everything else continues to use this routine's logic. | |||||
switch (triple.getOS()) { | |||||
case llvm::Triple::AIX: | |||||
case llvm::Triple::Emscripten: | case llvm::Triple::Emscripten: | ||||
case llvm::Triple::Linux: | case llvm::Triple::FreeBSD: | ||||
case llvm::Triple::Hurd: | case llvm::Triple::Hurd: | ||||
case llvm::Triple::Linux: | |||||
case llvm::Triple::OpenBSD: | case llvm::Triple::OpenBSD: | ||||
case llvm::Triple::Solaris: | case llvm::Triple::Solaris: | ||||
case llvm::Triple::WASI: | case llvm::Triple::WASI: | ||||
case llvm::Triple::AIX: | return false; | ||||
return; | |||||
case llvm::Triple::Win32: | case llvm::Triple::Win32: | ||||
if (triple.getEnvironment() != llvm::Triple::Cygnus || | if (triple.getEnvironment() != llvm::Triple::Cygnus || | ||||
triple.isOSBinFormatMachO()) | triple.isOSBinFormatMachO()) | ||||
return; | return false; | ||||
break; | break; | ||||
case llvm::Triple::UnknownOS: | case llvm::Triple::UnknownOS: | ||||
if (triple.isWasm()) | if (triple.isWasm()) | ||||
return; | return false; | ||||
break; | break; | ||||
} | } | ||||
// All header search logic is handled in the Driver for Darwin. | return true; // Everything else uses AddDefaultIncludePaths(). | ||||
} | |||||
void InitHeaderSearch::AddDefaultIncludePaths( | |||||
const LangOptions &Lang, const llvm::Triple &triple, | |||||
const HeaderSearchOptions &HSOpts) { | |||||
// NB: This code path is going away. All of the logic is moving into the | |||||
// driver which has the information necessary to do target-specific | |||||
// selections of default include paths. Each target which moves there will be | |||||
// exempted from this logic in ShouldAddDefaultIncludePaths() until we can | |||||
// delete the entire pile of code. | |||||
if (!ShouldAddDefaultIncludePaths(triple)) | |||||
return; | |||||
// NOTE: some additional header search logic is handled in the driver for | |||||
// Darwin. | |||||
if (triple.isOSDarwin()) { | if (triple.isOSDarwin()) { | ||||
if (HSOpts.UseStandardSystemIncludes) { | if (HSOpts.UseStandardSystemIncludes) { | ||||
// Add the default framework include paths on Darwin. | // Add the default framework include paths on Darwin. | ||||
if (triple.isDriverKit()) { | if (triple.isDriverKit()) { | ||||
AddPath("/System/DriverKit/System/Library/Frameworks", System, true); | AddPath("/System/DriverKit/System/Library/Frameworks", System, true); | ||||
} | } else { | ||||
else { | |||||
AddPath("/System/Library/Frameworks", System, true); | AddPath("/System/Library/Frameworks", System, true); | ||||
AddPath("/Library/Frameworks", System, true); | AddPath("/Library/Frameworks", System, true); | ||||
} | } | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
if (Lang.CPlusPlus && !Lang.AsmPreprocessor && | if (Lang.CPlusPlus && !Lang.AsmPreprocessor && | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |
Drop ShouldAddDefaultIncludePaths - . It is not recommended for new code.